wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Object is not of remote type error in GlassFish v3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Object is not of remote type error in GlassFish v3" Watch "Object is not of remote type error in GlassFish v3" New topic
Author

Object is not of remote type error in GlassFish v3

Stu Quinn
Ranch Hand

Joined: Feb 27, 2009
Posts: 35
Good day,

After using GlassFish v2 and JEE 5 I have decided to give GlassFish V3 and JEE 6 a go. I am using Eclipse V3.4 and have configured the GlassFish v3 JEE 6 Server Adapter. My server and client side apps are referencing the new libraries and I am ready to go. I have deployed my EJB 3 application successfully to the server, however I will be a son-of-a-gun if my client is having problems connecting via JNDI. The stacktrace indicates I am trying to grab an object that is not Remote, but that seems rather odd to me as this has not changed and it is in fact my @Remote interface to my session bean.

Quick view of the implementation code:



Now the remote interface:


Now the client (this is JUnit)



And here is the error I get when attempting to run the JUnit (again, this same code worked find under GlassFish v2)

javax.naming.CommunicationException: Can't find SerialContextProvider [Root exception is java.lang.ClassCastException]
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:164)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:409)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.quintessential.ub3.bam.IUB3Session_Physical_MeterReadPostingTest.setUp(IUB3Session_Physical_MeterReadPostingTest.java:46)
at junit.framework.TestCase.runBare(TestCase.java:128)
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:120)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassCastException
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:258)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.java:136)
at com.sun.enterprise.naming.SerialContext.getCachedProvider(SerialContext.java:259)
at com.sun.enterprise.naming.SerialContext.getRemoteProvider(SerialContext.java:204)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:159)
... 14 more
Caused by: java.lang.ClassCastException: Object is not of remote type com.sun.enterprise.naming.SerialContextProvider
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:250)
... 19 more


Thanks for any clues here,
Stu
Prasad Kumbhare
Greenhorn

Joined: Oct 18, 2007
Posts: 26
If I understood your client correctly, you are trying to access EJB via JNDI looktup thorough JUnit test case. But JUnit runs out of container. Are you using Cactus or something or is this plain out of container JUnit client ?
If this is out of container JUnit you will not be able to access EJB vis JNDI lookup. No Initial context would be available in that case.


Thanks,
Prasad Kumbhare
SCJP 5.0, SCWCD 5.0, SCBCD 5.0
Stu Quinn
Ranch Hand

Joined: Feb 27, 2009
Posts: 35
Prasad,

I regularly test this way from JUnit running in Eclipse. Below are samples that are working just fine in JBOSS and GlassFish V2. The problem seems to be when attempting to narrow the remote object, but I am away from the laptop where I am having the problem at the moment. I need to see what it is trying to return.

Samples that work:


Thanks,
Stu
Tony Paul
Greenhorn

Joined: May 01, 2012
Posts: 1
Hi Stu-
I know its been a old post.
But just wanted to check if you were able to find a solution for the issue?

Because I just migrated application from Glassfish 2.1 to Glassfish 3.1.1 and am facing the exact same issue where the remote ejb invocation fails with the exception:

Caused by: java.lang.ClassCastException
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:258)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at com.sun.enterprise.naming.SerialContext.narrowProvider(SerialContext.java:136)
at com.sun.enterprise.naming.SerialContext.getRemoteProvider(SerialContext.java:220)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:159)
... 17 more
Caused by: java.lang.ClassCastException: Object is not of remote type com.sun.enterprise.naming.SerialContextProvider
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:250)
... 21 more

Any help on this is appreciated
 
jQuery in Action, 2nd edition
 
subject: Object is not of remote type error in GlassFish v3
 
Similar Threads
NoClassDefFoundError exception in InitialContext()
WSAD 5.0 EJB Client jndi lookup problem
Problem with jndi lookup for remote bean in EJB 3.x
Class cast exception when grabbing remote EJB 3 interface
Problem with JNDI lookup in Glassfish V3