-
1. Client for Ejb 3.1 session bean
wolfc Apr 13, 2011 8:33 AM (in response to mcatalin23)See EJB 3.1 Embeddable.
I agree the error isn't really helpful, you can create a Jira for that bit. Basically it means that no EJB 3.1 Embeddable implementation was found on the class path.
-
2. Re: Client for Ejb 3.1 session bean
mcatalin23 Apr 14, 2011 8:19 AM (in response to wolfc)Creating with ejb 3.1 and deploying into jboss 6 stateless session beans is pretty easy.
In Jboss log I have:
15:07:14,861 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
MyTestBean/remote - EJB3.x Default Remote Business Interface
MyTestBean/remote-com.creon.ejb.TestBeanRemote - EJB3.x Remote Business Interface
MyTestBean/local - EJB3.x Default Local Business Interface
MyTestBean/local-com.creon.ejb.TestBeanLocal - EJB3.x Local Business Interface
I'm trying to call methods using clients from the session bean deployed into jboss 6.0.0 final but with no success until now.
Can someone recomands some documentation to help me create local and remote client to access the deployed sb?
-
3. Client for Ejb 3.1 session bean
wdfink Apr 14, 2011 8:31 AM (in response to mcatalin23)From a plain (remote) Java app:
Properties p = new Properties( );
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
Context context = new InitialContext(p);
MyTestRemote bean = context.lookup("<your EAR name>/MyTestBean/remote")
Inside the container (e.g. other SLSB):
@EJB
MyTest bean; //injected
-
4. Re: Client for Ejb 3.1 session bean
mcatalin23 Apr 14, 2011 10:41 AM (in response to wdfink)This helps me go further but I have another issue now with the following line of code:
MyTestRemote bean = context.lookup("<your EAR name>/MyTestBean/remote")
In my client context.lookup returns Reference and I tryed the following instead of line above
Object bean = context.lookup("<your EAR name>/MyTestBean/remote")
MyTestRemote myTR = (MyTestRemote) PortableRemoteObject.narrow(bean , MyTestRemote.class);
where MyTestRemote is the remote interface
but I get following error:
Exception in thread "main" java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at com.creon.ejbclient.TestBeanClient2.callSB(TestBeanClient2.java:90)
at com.creon.ejbclient.TestBeanClient2.main(TestBeanClient2.java:30)
Caused by: java.lang.ClassCastException: javax.naming.Reference cannot be cast to org.omg.CORBA.Object
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
... 3 more
PS. I have found what the problem is
jbossall-client.jar should be added to classpath from client folder
-
5. Client for Ejb 3.1 session bean
wdfink Apr 14, 2011 1:21 PM (in response to mcatalin23)As you use EJB3 forget narrowing, you can use the remoteIF direct without this stuff
Does your example work?
If yes you should set the thread as 'answered'