Hi all,
I have recently attempted to connect to a stateful session bean on my jboss server that I created from the jboss tutorial.
Their client I used (only with package name changes) gives me the following error:
Exception in thread "main" java.lang.ClassCastException: javax.naming.Reference
at testEjb3.Client.main(Client.java:17)
code for line 16-17:
InitialContext ctx = new javax.naming.InitialContext();
ShoppingCart cart = (ShoppingCart)ctx.lookup(ShoppingCart.class.getName());
I use the eclipse jboss ide and jboss version 4.0.2
I'm sure this is a classpath error. I was wondering if any one else had tried this example and what they put in their classpath.
-
JBOSS EJB 3 JNDI Problem (4 messages)
- Posted by: Tinus Lourens
- Posted on: June 28 2005 09:08 EDT
Threaded Messages (4)
- JBOSS EJB 3 JNDI Problem by Arik Kfir on July 18 2005 10:28 EDT
- Subcontext look failed from web container by george chen on July 26 2005 21:53 EDT
- JBOSS EJB 3 JNDI Problem by Bernd Dutkowski on September 01 2005 17:38 EDT
- Re: JBOSS EJB 3 JNDI Problem by mujoko wiyono on May 04 2007 03:45 EDT
-
JBOSS EJB 3 JNDI Problem[ Go to top ]
- Posted by: Arik Kfir
- Posted on: July 18 2005 10:28 EDT
- in response to Tinus Lourens
This happens to me too. Does this work for anyone? -
Subcontext look failed from web container[ Go to top ]
- Posted by: george chen
- Posted on: July 26 2005 21:53 EDT
- in response to Tinus Lourens
It seems there is a bug with JBoss 4.0.2. I deployed the same example ear file to version 4.0 and 4.0.2 but version 4.0.2 failed. When I lookuped the home of a bean deployed from a web servlet using InitialContext JBoss Server 4.0.2 always appended additional "Home" to the end of bound JNDI subcontext, which caused ClassCastException. The funny thing is, if you use stand-alone client there are no such exception at all. -
JBOSS EJB 3 JNDI Problem[ Go to top ]
- Posted by: Bernd Dutkowski
- Posted on: September 01 2005 17:38 EDT
- in response to Tinus Lourens
Same problem here:
java.lang.ClassCastException: javax.naming.Reference
at org.jboss.ejb3.LocalProxy.readObject(LocalProxy.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:919)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1813)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at xxx.JNDITest.testJNDI(JNDITest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) -
Re: JBOSS EJB 3 JNDI Problem[ Go to top ]
- Posted by: mujoko wiyono
- Posted on: May 04 2007 03:45 EDT
- in response to Tinus Lourens
I found the same problem. As default, Session Bean is binding by ClassNameBean/local or ClassNameBean/remote. But if the aplliaction is deployed in .ear file then its binding by ear_name_file/Class_Name_bean/remote. example if our ear file is ojolali.ear and the Session Class name is BasoBean.class then its bind as ojolali/BasoBean/remote. but if its deploy in jar then to get the bean remote from JNDI is ; InitialContext ctx = new javax.naming.InitialContext(); ShoppingCart cart = (ShoppingCart)ctx.lookup(ShoppingCart.class.getName()+"/remote");