reference external JAR's
kometen Feb 20, 2002 10:05 AMHi.
I have installed JBoss 2.4.4 and is trying to implement the cabin- and travelagent- examples in Richard Monson-Haefel's Enterprise JavaBeans.
Running the CabinEJB goes fine, I'm able to connect to postgresql (ver. 7.1 and 7.2) and insert the records. The problem is when I try to let the travelagent bean to talk to the cabin bean. The error-message from the JBoss -console is:
[INFO,Default] Got context
[ERROR,TravelAgentEJB] TRANSACTION ROLLBACK EXCEPTION:
javax.transaction.TransactionRolledbackException: null; nested exception is:
javax.ejb.EJBException
javax.ejb.EJBException
at no.gnomeit.travelagent.TravelAgentBean.listCabins(TravelAgentBean.java:61)
at java.lang.reflect.Method.invoke(Native Method)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:542)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:82)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:286)
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:410)
at java.lang.reflect.Method.invoke(Native Method)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
at sun.rmi.transport.Transport$1.run(Transport.java:152)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
at java.lang.Thread.run(Thread.java:484)
The ejb-jar.xml is:
<ejb-jar>
<enterprise-beans>
TravelAgent Session Bean
<display-name>TravelAgent</display-name>
<ejb-name>TravelAgentEJB</ejb-name>
no.gnomeit.travelagent.TravelAgentHomeRemote
no.gnomeit.travelagent.TravelAgentRemote
<ejb-class>no.gnomeit.travelagent.TravelAgentBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/CabinEJB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
no.gnomeit.cabin.CabinHomeRemote
no.gnomeit.cabin.CabinRemote
</ejb-ref>
</enterprise-beans>
<assembly-descriptor>
...
</assembly-descriptor>
</ejb-jar>
The jboss-xml looks like:
<enterprise-beans>
<ejb-name>TravelAgentEJB</ejb-name>
<ejb-ref>
<ejb-ref-name>ejb/CabinEJB</ejb-ref-name>
<jndi-name>CabinBean</jndi-name>
</ejb-ref>
</enterprise-beans>
TravelAgentBean.java (parts of):
public String [] listCabins(int shipId, int bedCount) {
try {
// Get a naming context
InitialContext jndiContext = new InitialContext();
System.out.println("Got context");
// Get a reference to the CabinBean bean
Object obj = jndiContext.lookup("java:comp/env/ejb/CabinEJB");
System.out.println("Got reference");
CabinHomeRemote home = (CabinHomeRemote)
PortableRemoteObject.narrow(obj, CabinHomeRemote.class);
I have changed the com.titan with no.gnomeit, but this should only be cosmetic.
I have deployed the travelagent.jar file with the CabinHome.class and CabinHomeRemote.class as stated in the jboss-doc. The jar is (according to the jboss-console) correct.
Am I doing this right?
regards
Claus Guttesen