-
1. Re: 5.1.0.GA - Problems with Dependency Injection
wolfgangknauf Apr 12, 2011 8:05 AM (in response to pi4630)Hi,
I hope it helps to add a JBoss-specific "@Depends" annotation to "AnaUniEJB":
@Depends(value = "jboss.j2ee:jar=JAR2.jar,name=GvccBean,service=EJB3")
@Stateless
@WebService
public class AnaUniEJB implements AURemoteBusiness, AnaUniWebService {
I am not sure whether the @Depends value is correct. If not: when "GvccBean" is deployed sucessfully, you can find the correct name by looking at the jmx console.
It might also help to force JBoss to first deploy JAR2, then JAR1. Take a look e.g. at those articels:
http://community.jboss.org/wiki/PrefixDeploymentOrder
http://community.jboss.org/wiki/HowToOrderJBossASDeploymentsByDefiningCustomDependencies
Hope this helps
Wolfgang
-
2. Re: 5.1.0.GA - Problems with Dependency Injection
pi4630 Apr 12, 2011 8:32 AM (in response to wolfgangknauf)Hi Wolfgang,
unfortunately, it did not work. Here it was I tried:
From the JMX Console, I got the String for @Depends:
{quote}@Depends(value="jboss.j2ee:jar=GVCC.jar,name=GvccBean,service=EJB3"){quote}
I've put that in the SLSB (1) that tries to make a DI on the other SLSB (2).
I've stopped JBoss AS, deleted the respective jars and deployed first SLSB (2), i.e. the one without dependency. I then read the String on the JMX Console. When I deploy the jar containing SLSB(1), I get the following msg on the console:
{quote}ERROR [AbstractKernelController] Error installing to Start: name=jboss.j2ee:jar=AnagraficaUnificata.jar,name=AnaUniEJB,service=EJB3 state=Create
java.lang.NullPointerException{quote}
and, further
{quote}ERROR [AbstractKernelController] Error installing to Start: name=jboss.j2ee:jar=AnagraficaUnificata.jar,name=AnaUniEJB,service=EJB3 state=Create
java.lang.NullPointerException
...
Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: env not bound
{quote}
I use eclipse IDE, the build path is project independent. Instead, I've copied & pasted the packages from Project 2 (JAR2 = SLSB2) containing the interfaces of SLSB2 into Project 1 (JAR1 = SLSB1). It's just for a proof of concept, I guess one can use maven to manage such dependencies in production use.
Thanks for caring,
-
3. Re: 5.1.0.GA - Problems with Dependency Injection
jaikiran Apr 12, 2011 9:06 AM (in response to pi4630)Injection across independent applications isn't supported https://issues.jboss.org/browse/JBAS-6332. Try adding those 2 jars to a .ear to get it working.
-
4. Re: 5.1.0.GA - Problems with Dependency Injection
pi4630 Apr 12, 2011 9:12 AM (in response to jaikiran)Hi Jaikiran,
I've followed your posts about similar discussions around here and JavaRanch; I wasn't quite sure if my problem was due to the same reason. Now it is, thank you.
So, DI works only between EARs, not JARs. That is, am I able to use DI only inside one EAR or also between different EARs?
Thank you very much!
-
5. Re: 5.1.0.GA - Problems with Dependency Injection
jaikiran Apr 12, 2011 9:24 AM (in response to pi4630)Pasquale Imbemba wrote:
Hi Jaikiran,
I've followed your posts about similar discussions around here and JavaRanch; I wasn't quite sure if my problem was due to the same reason. Now it is, thank you.
You're welcome
So, DI works only between EARs, not JARs. That is, am I able to use DI only inside one EAR or also between different EARs?
@EJB Injection currently works within a single application. So it won't work between different EARs (or different independently deployed jars).