-
1. Re: Problem looking up entity from session bean
yf Aug 26, 2001 5:57 PM (in response to jsk)Hi,
First, make sure that you have specify the reference to entity beans used in your session bean (this is the ejb-ref tag).
Secondly, since your beans are deployed in separate jar files, you will need to provide more info in the jboss.xml file. This is specified somewhere in the jboss doc., I just can't find it now. Basically in that case, you have to specify the jndi class name and other info. -
2. Re: Problem looking up entity from session bean
jsk Aug 27, 2001 4:05 PM (in response to jsk)I found something in the documentation (6. Advanced container configuration : use of jboss.xml), but it does not seem to work.
My .xml files for the session bean now looks like this
ejb-jar.xml:
<?xml version="1.0" encoding="Cp1252"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<ejb-name>ZipCode</ejb-name>
com.orwtech.ebizz.ejb.session.ZipCodeHome
com.orwtech.ebizz.ejb.session.ZipCodeRemote
<ejb-class>com.orwtech.ebizz.ejb.session.ZipCode</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/DatZipCode</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
com.orwtech.ebizz.ejb.entity.DatZipCodeHome
com.orwtech.ebizz.ejb.entity.DatZipCode
</ejb-ref>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<ejb-name>ZipCode</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
jboss.xml:
<?xml version="1.0" encoding="UTF-8"?>
<enterprise-beans>
<ejb-name>ZipCode</ejb-name>
<jndi-name>ejb/session/ZipCode</jndi-name>
<ejb-ref>
<ejb-ref-name>ejb/DatZipCode</ejb-ref-name>
<jndi-name>ejb/entity/DatZipCode</jndi-name>
</ejb-ref>
</enterprise-beans>
I even tried putting the two .jar files into an .ear file with an application.xml. But I just can't get it to work.
I get this stack trace from the session bean lookup:
"javax.naming.NamingException: ejb not bound"
Any suggestions?
Gr. Jesper -
3. Re: Problem looking up entity from session bean
jsk Aug 27, 2001 7:40 PM (in response to jsk)I have tried printing stack trace inside the session bean but I cannot decifer it. Someone else might?
Gr. Jesper
[Default] javax.naming.CommunicationException. Root exception is
[Default] java.lang.ClassNotFoundException: com.orwtech.ebizz.ejb.entity.DatZipC
odeHome
[Default] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
[Default]
[Default] at java.security.AccessController.doPrivileged(Native Method)
[Default]
[Default] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[Default]
[Default] at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
[Default]
[Default] at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
[Default]
[Default] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
[Default]
[Default] at java.lang.Class.forName0(Native Method)
[Default]
[Default] at java.lang.Class.forName(Class.java:195)
[Default]
[Default] at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalIn
putStream.java:183)
[Default]
[Default] at java.io.ObjectInputStream.inputProxyClassDescriptor(ObjectInp
utStream.java:982)
[Default]
[Default] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:3
70)
[Default]
[Default] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2
36)
[Default]
[Default] at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:
1186)
[Default]
[Default] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:3
86)
[Default]
[Default] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2
36)
[Default]
[Default] at java.rmi.MarshalledObject.get(MarshalledObject.java:138)
[Default]
[Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:35
3)
[Default]
[Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:33
3)
[Default]
[Default] at javax.naming.InitialContext.lookup(InitialContext.java:350)
[Default]
[Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:42
1)
[Default]
[Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:45
7)
[Default]
[Default] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:33
3)
[Default]
[Default] at javax.naming.InitialContext.lookup(InitialContext.java:350)
[Default]
[Default] at com.orwtech.ebizz.ejb.session.ZipCode.getDatZipCodeHome(ZipCo
de.java:89)
[Default]
[Default] at com.orwtech.ebizz.ejb.session.ZipCode.getAllZipCodes(ZipCode.
java:44)
[Default]
[Default] at java.lang.reflect.Method.invoke(Native Method)
[Default]
[Default] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.
invoke(StatelessSessionContainer.java:543)
[Default]
[Default] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.inv
oke(StatelessSessionInstanceInterceptor.java:87)
[Default]
[Default] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxIntercept
orCMT.java:133)
[Default]
[Default] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(Tx
InterceptorCMT.java:307)
[Default]
[Default] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCM
T.java:99)
[Default]
[Default] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInte
rceptor.java:128)
[Default]
[Default] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.ja
va:195)
[Default]
[Default] at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessi
onContainer.java:286)
[Default]
[Default] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke
(JRMPContainerInvoker.java:393)
[Default]
[Default] at java.lang.reflect.Method.invoke(Native Method)
[Default]
[Default] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.jav
a:241)
[Default]
[Default] at sun.rmi.transport.Transport$1.run(Transport.java:142)
[Default]
[Default] at java.security.AccessController.doPrivileged(Native Method)
[Default]
[Default] at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
[Default]
[Default] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTranspor
t.java:443)
[Default]
[Default] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPT
ransport.java:643)
[Default]
[Default] at java.lang.Thread.run(Thread.java:484)
[Default] -
4. Re: Problem looking up entity from session bean
seven Aug 28, 2001 3:27 AM (in response to jsk)Try to do something like this:
Context ctx = new javax.naming.InitialContext();
System.out.println("got InitialContext()!");
Object ref = ctx.lookup("java:comp/env/ejb/DatZipCode");
System.out.println("done lookup");
return (DatZipCodeHome) javax.rmi.PortableRemoteObject.narrow(ref, DatZipCodeHome.class);
And be sure to declare an ejb ref in the session bean section of the ejb-jar.xml
<ejb-ref>
<ejb-ref-name>ejb/DatZipCode</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
your.package.DatZipCodeHome
your.package.DatZipCode
<ejb-link>The name of the entity bean</ejb-link>
</ejb-ref>
I think the lookup made from the session bean doesn't work 'cause the jndi context is different from the jndi context obtained in the standalone client. So if u want to solve your problem u have to include an <ejb-ref> section in your session bean decriptor 'cause I guess at deployment the jboss will do an automatic bind of the entity bean ref in the jndi context of the session bean. -
5. Re: Problem looking up entity from session bean
jsk Aug 31, 2001 6:20 PM (in response to jsk)Hi seven
Thank you for your good answer. I now got it to work thanks to your guidance.
Just to make this usefull to others I will add this comment to your reply.
Comment: To make it all work the entity bean and session bean has to be deployed in the same .ear file including application.xml
Sample of session bean ejb-jar.xml
<ejb-jar>
<enterprise-beans>
<ejb-name>ZipCode</ejb-name>
com.orwtech.ebizz.ejb.session.ZipCodeHome
com.orwtech.ebizz.ejb.session.ZipCodeRemote
<ejb-class>com.orwtech.ebizz.ejb.session.ZipCode</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/DatZipCode</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
com.orwtech.ebizz.ejb.entity.DatZipCodeHome
com.orwtech.ebizz.ejb.entity.DatZipCodeRemote
<ejb-link>ebizz/ejb/entity/DatZipCode</ejb-link>
</ejb-ref>
</enterprise-beans>
...
</ejb-jar>
Sample of session bean jboss.xml
<enterprise-beans>
<ejb-name>ZipCode</ejb-name>
<jndi-name>ebizz/ejb/session/ZipCode</jndi-name>
<ejb-ref>
<ejb-ref-name>ejb/DatZipCode</ejb-ref-name>
<jndi-name>ebizz/ejb/entity/DatZipCode</jndi-name>
</ejb-ref>
</enterprise-beans>
Sample of .ear application.xml
<display-name>ZipCode test</display-name>
DatZipCode.jar
ZipCode.jar
Thank you all for your help!
Jesper