On May 29, 2006, at 10:31 PM, Nirav Mehta wrote: Hi all,
I am a newbie at JEE and ave just started trying out EJBs. I managed to create a stateful session bean and a client JSP program. This works perfect when I deploy them both in a single EAR. But when I deploy the bean jar and the client war separately, there are issues.
One of the problems is that you have an ejb-local-ref from the web app to the ejb. This can only be deployed if the web app and ejb app are in the same ear. If you only use the remote interface for the ejb you should be able to deploy them separately, although I don't think there is any reason to actually do so other than checking that it is possible.
thanks david jencks
These are my deployment descriptors:
The Bean - ejb-jar.xml :
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_1" xmlns=" http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
<description><![CDATA[EJBProj1 generated by eclipse wtp xdoclet extension.]]></description> <display-name>EJBProj1</display-name>
<enterprise-beans>
<!-- Session Beans --> <session id="Session_HelloWorld"> <description>A session bean returning HelloWorld></description> <display-name>HelloWorld</display-name>
<ejb-name>HelloWorld</ejb-name>
<home>helloWorld.HelloWorldHome</home> <remote>helloWorld.HelloWorld </remote> <local-home>helloWorld.HelloWorldLocalHome</local-home> <local>helloWorld.HelloWorldLocal</local> <ejb-class>helloWorld.HelloWorldSession</ejb-class> <session-type>Stateful</session-type> <transaction-type>Container</transaction-type>
</session>
</ejb-jar>
openejb-jar.xml :
<?xml version="1.0" encoding="UTF-8"?> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0 " xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0" xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0 " xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0 " configId="EJBProj1/EJBProj1"> <enterprise-beans> <entity> <ejb-name>ejb/HelloWorld</ejb-name> <jndi-name>HelloWorld</jndi-name> <local-jndi-name>HelloWorldLocal</local-jndi-name> </entity> </enterprise-beans> </openejb-jar>
Client prog - web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>EJBClientProj1</display-name> <welcome-file-list> <welcome-file>Hello.jsp</welcome-file> </welcome-file-list> <ejb-ref> <ejb-ref-name>ejb/HelloWorld</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <home>helloWorld.HelloWorldHome</home> <remote>helloWorld.HelloWorld</remote> </ejb-ref> <ejb-local-ref> <ejb-ref-name>ejb/HelloWorldLocal</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>helloWorld.HelloWorldLocalHome</local-home> <local>helloWorld.HelloWorldLocal</local> <ejb-link>HelloWorldLocal</ejb-link> </ejb-local-ref>
</web-app>
geronimo-web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns=" http://geronimo.apache.org/xml/ns/j2ee/web-1.0" xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.0" xmlns:sec=" http://geronimo.apache.org/xml/ns/security-1.1" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.0" configId="EJBClientProj1/EJBClientProj1"> <context-root>/EJBClientProj1</context-root> <context-priority-classloader>false</context-priority-classloader> <nam:ejb-ref> <nam:ref-name>ejb/HelloWorld</nam:ref-name> <nam:target-name>geronimo.server:J2EEModule=EJBProj1.jar,J2EEServer=geronimo,j2eeType=StatefulSessionBean,name=HelloWorld</nam:target-name> </nam:ejb-ref> </web-app>
Where am I going wrong? Can someone please explain conceptually so that I dont have to trouble you again?
Regards, Nirav Mehta
|
- Re: EJB trouble David Jencks
-