javax.naming.Reference
is returned to the client, hence the ClassCastException
.Some reasons why the naming manager failed to create object:
1, the object factory class responsible for creating the object is not available in the client classpath. Think of javax.naming.Reference as the raw material for creating the object. When there is no factory, no object is created, and the raw material is thrown back to the client.
In GlassFish 3, the object factory for remote EJB reference appears to be com.sun.ejb.containers.RemoteBusinessObjectFactory, packaged in ejb-container.jar. So ejb-container.jar and javax.ejb.jar should be in the client classpath by direct inclusion or by reference, along with a series of other jar files.
The following is the toString format of the returned javax.naming.Reference:
Reference Class Name: test.TestIF2, the object factory is in client classpath, but not loadable by the current thread context class loader.
Type: url
Content: ejb/TestBean__3_x_Internal_RemoteBusinessHome__
The algorithm for creating object is in javax.naming.spi.NamingManager.