Forums Register Login

Problem in integrating EJB3.0 with Struts

+Pie Number of slices to send: Send
Hello Experts,
I am facing some problem in integration of struts 1.2.9 with EJB 3.0.I am using Netbeans 6.0.I have Deployed & undeployed the EJB module.I have also added the EJB module project as a jar file in my client project.I have already googled this error but didn't find anything useful.Please help.Many Thanks in advance.


This is my stateless bean




This is my local interface





This is my client(Struts's Action class)



This is the error I am getting
Deploying application in domain failed; Error loading deployment descriptors for module [IMS_1] -- Cannot resolve reference Unresolved Ejb-Ref com.myapp.struts.LoginAction/loginSessionLocal@jndi: @null@IMS_EJB.LoginSessionLocal@Session@null
Deployment error:
The module has not been deployed.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:163)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor335.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: The module has not been deployed.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:157)
... 16 more
+Pie Number of slices to send: Send
hi..I am also having the same kind of a problem. I have added the EJB3 module to a web project and trying to call methods in a stateless session bean through remote interface.

Here is the error:
Deploying application in domain failed; Error loading deployment descriptors for module [Merchants] -- Cannot resolve reference Unresolved Ejb-Ref com.mjoy.cp.interfaces.ReservationCPInterfaceBean/ticketReservationBean@jndi: @null@com.mjoy.cp.reservation.TicketReservationLocal@Session@null
Deployment error:
The module has not been deployed.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:166)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: The module has not been deployed.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:160)
... 16 more
BUILD FAILED





If somebody know the answer pleas help.

Thank you.
+Pie Number of slices to send: Send
Hi Neha,

I think you have to look up EJB from JNDI if you want to use it in Struts Action class. The Dependency Injection only works if the class is managed by the container. For instance , it is possible to use annotated dependency injection in Servlet, Listener, Tag Handler or any EJB. Therefore the struts Action instance is not managed by container so you can not directly use Annotated dependency.

And for the best practice you should use ServiceLocator design pattern for the JNDI lookup.

Thanks
+Pie Number of slices to send: Send
Although.It is a pretty old thread,but lots people googled this page for a solution
I find one,and attach here for future people reference.
this is referenced from glassfish2 Q/A

I have an EJB component with a Local interface. Can I access it from a web component in a different application?

No. The EJB specification only requires access to an EJB component's local EJB interface from within the same application in the same JVM. One option is to package the ejb-jar in the same .ear as the .war. A second option, if using GlassFish v3, is to package the EJB component directly within the .war.

+Pie Number of slices to send: Send
Just a note to above, you can only package the EJB inside the WAR in JEE6, not JEE5 - and I heard using something like Guice might be able to do the injection you're looking for.
I found some pretty shells, some sea glass and this lovely tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 5210 times.
Similar Threads
Help : Servlet can not find EJB using DI in glassfish2
Help in connecting to oracle10 database using struts
Error while deploying a web service
How to define Generic Collection types in JPA Entity table column
Problem while deploying Web Service on Tomcat (in netbeans)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:08:56.