Im trying to link an
EJB to an EJB deployed in another application within JBoss. JBoss Administration
and Developement (2nd Ed) says under "EJB References with jboss.xml and
jboss-web.xml" (pg 110 of Naming on JBoss...)
"The ejb-link
element cannot be used to refer to EJB's in another enterprise application. If
your ejb-ref needs to access an external EJB, you can specify the jndi name of
the deployed EJB home using the jboss.xml ejb-ref/jndi-name
element"
So l have used the
following in jboss.xml
<entity>
<ejb-name>HistoryEntity</ejb-name>
<jndi-name>HistoryEntityRemoteHome</jndi-name>
<local-jndi-name>HistoryEntityLocalHome</local-jndi-name>
<ejb-local-ref>
<ejb-local-ref-name>ejb/SequenceSession</ejb-local-ref-name>
<jndi-name>SequenceSessionLocalHome</jndi-name>
</ejb-local-ref>
<ejb-name>HistoryEntity</ejb-name>
<jndi-name>HistoryEntityRemoteHome</jndi-name>
<local-jndi-name>HistoryEntityLocalHome</local-jndi-name>
<ejb-local-ref>
<ejb-local-ref-name>ejb/SequenceSession</ejb-local-ref-name>
<jndi-name>SequenceSessionLocalHome</jndi-name>
</ejb-local-ref>
</entity>
In my ejb-jar.xml l
have
<entity
>
<ejb-name>HistoryEntity</ejb-name>
<ejb-name>HistoryEntity</ejb-name>
...
<ejb-local-ref >
<ejb-ref-name>ejb/SequenceSession</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.newellandbudge.commons.ejb.common.SequenceSessionLocalHome</local-home>
<local>com.newellandbudge.commons.ejb.common.SequenceSessionLocal</local>
</ejb-local-ref>
<ejb-ref-name>ejb/SequenceSession</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.newellandbudge.commons.ejb.common.SequenceSessionLocalHome</local-home>
<local>com.newellandbudge.commons.ejb.common.SequenceSessionLocal</local>
</ejb-local-ref>
</entity>
The SequenceSession
EJB is defined in the jboss.xml and ejb-jar.xml of another EAR
as
[jboss.xml]
<session>
<ejb-name>SequenceSession</ejb-name>
<jndi-name>SequenceSessionRemoteHome</jndi-name>
<local-jndi-name>SequenceSessionLocalHome</local-jndi-name>
<ejb-name>SequenceSession</ejb-name>
<jndi-name>SequenceSessionRemoteHome</jndi-name>
<local-jndi-name>SequenceSessionLocalHome</local-jndi-name>
</session>
[ejb-jar.xml]
<session
>
<ejb-name>SequenceSession</ejb-name>
<ejb-name>SequenceSession</ejb-name>
<home>com.newellandbudge.commons.ejb.common.SequenceSessionRemoteHome</home>
<remote>com.newellandbudge.commons.ejb.common.SequenceSessionRemote</remote>
<local-home>com.newellandbudge.commons.ejb.common.SequenceSessionLocalHome</local-home>
<local>com.newellandbudge.commons.ejb.common.SequenceSessionLocal</local>
<ejb-class>com.newellandbudge.commons.ejb.SequenceSessionBean</ejb-class>
<session-type>Stateless</session-type>
<remote>com.newellandbudge.commons.ejb.common.SequenceSessionRemote</remote>
<local-home>com.newellandbudge.commons.ejb.common.SequenceSessionLocalHome</local-home>
<local>com.newellandbudge.commons.ejb.common.SequenceSessionLocal</local>
<ejb-class>com.newellandbudge.commons.ejb.SequenceSessionBean</ejb-class>
<session-type>Stateless</session-type>
...
</session>
</session>
When the EAR with
HistoryEntity is deployed l get following
DeploymentException
16:48:23,812
WARN [ServiceController] Problem starting service
jboss.j2ee:jndiName=HistoryEntityRemoteHome,service=EJB
org.jboss..deployment.DeploymentException: Local references currently require ejb-link
at org.jboss.ejb.Container.setupEnvironment(Container.java:876)
at org.jboss.ejb.Container.startService(Container.java:568)
at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:325)
at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController..java:966)
at $Proxy11.start(Unknown Source)
org.jboss..deployment.DeploymentException: Local references currently require ejb-link
at org.jboss.ejb.Container.setupEnvironment(Container.java:876)
at org.jboss.ejb.Container.startService(Container.java:568)
at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:325)
at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController..java:966)
at $Proxy11.start(Unknown Source)
Firstly, the message
in this exception seems to contradict the statement about the ejb-link
element.
Secondly, the EJB
spec says that the ejb-link element can only be used to link to another EJB in
the same ejb-jar or another jar in the same application. If l follow the advise
of the DeploymentException my deployment fails because the SequenceSession EJB
is not in the same ejb-jar or application as my HistoryEntity
EJB.
I cant see a way
forward with this situation. I dont want to have to deploy the
SequenceSession EJB in every application that uses it. What is the solution
to this problem? Or could someone shed some more light on the use of
ejb-ref/jndi-name in jboss.xml?
(Im using JBoss
3.2.1)
Thanks
******************************************************************************** This electronic mail system is used for information purposes and is not intended to form any legal contract or binding agreement. The content is confidential and may be legally privileged. Access by anyone other than the addressee(s) is unauthorised and any disclosure, copying, distribution or any other action taken in reliance on it is prohibited and maybe unlawful All incoming and outgoing e-mail communications and attachments are scanned automatically by software designed to detect and remove any material containing viruses or other unauthorised content. While we undertake best endeavours to ensure that this content checking software is up to date, recipients should take steps to assure themselves that e-mails received are secure. ***************************************************************************************