On Wed, 03 Aug 2005 12:06:19 -0500, you wrote:
>I want to be able to store an object in $_SESSION so that I can retrive=20
>the object with subsequent php pages. I think the issue I'm having is=20
>due to an out of scope condition when the php page exits. I see the=20
>Cache reference in the docs and tests.php4/Cache.java in the=20
>distribution but I'm little fuzzy on what to actually do.
>
>Here is a code snippet followed by the exception that is raised when my=20
>php page exits:
>
>...
> // OrderServiceUtil() handles the context lookup, remote object=20
>narrowing and home.create calls
> $orderServiceUtil =3D new OrderServiceUtil();
>
> // get an instance of the home interface of the session bean
> $order =3D $orderServiceUtil->getInstance();
>
> // get product id 1041=20
> =
=20
>
> $product =3D $order->getProduct(1041);
> =20
> $_SESSION['product'] =3D $product;
> =20
>...
>
>=20
>java.lang.NoSuchMethodException: __sleep(). Candidates: []
> at php.java.bridge.JavaBridge.Invoke(JavaBridge.java:966)
> at php.java.bridge.Request.handleRequests(Request.java:190)
> at php.java.bridge.JavaBridge.run(JavaBridge.java:142)
> at php.java.bridge.ThreadPool$Delegate.run(ThreadPool.java:20)
>=20
>Fatal error: Exception thrown without a stack frame in Unknown on line 0
>
>Just looking over the java bridge code it appears it is performing a=20
>wait() which probably call a system specific sleep(). What I can't=20
>figure out is which class the invocation is attempted. wait() and=20
>sleep() should be in rt.jar.
>
>Any thoughts?
Well, "__sleep()" is a magical method which PHP calls to signal to any
object that it is going to be seralized soon ... it has nothing to do
with java at all. And since your $product does not have a __sleep
method, the invocation will fail. Serializing non-trivial objects in
php is not for the faint of heart, you should know exactly what
happens and when (for example the class definition needs to be loaded
when the session gets started, *before* the object gets deserialized).
Anyway, you can't just write a java object to your session. What
you'll have to do is to use a java session. Look up the php java
brigde docs at http://php-java-bridge.sourceforge.net/about about
usage of java_get_session
You could use
session_start();
$java_session =3D java_get_session(session_id());
to get what you want ..
MfG,
Kai Londenberg
-------------------------------
librics GmbH & Co. KG
G=F6ttinger Chaussee 115
D-30459 Hannover
Tel. +49 511 - 473 88 77
=46ax +49 511 - 473 88 78
mailto: K.L...@li...
|