-
1. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
sfcoy Nov 28, 2011 7:38 PM (in response to kristjan273)Each EAR needs it's own copy of the remote interface classes used to access EJBs in the other EAR. Is that the case now?
-
2. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
kristjan273 Nov 29, 2011 5:20 AM (in response to sfcoy)Well, no.
Have tried that, but if I put same @Remote annotated interface to both EARs following occurs:
11:13:40,609 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.subunit."ejbremote-ear.ear"."ejbremote-ejb-0.0.1-SNAPSHO T.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."ejbremote-ear.ear"."ejbremote-ejb-0.0.1-SNAPSHOT.jar".INSTALL: Failed to process phase INS TALL of subdeployment "ejbremote-ejb-0.0.1-SNAPSHOT.jar" of deployment "ejbremote-ear.ear" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.1.0.Beta1.jar:] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_29] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_29] at java.lang.Thread.run(Thread.java:662) [:1.6.0_29] Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011058: Failed to install component HelloWorldServiceBean at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deploy(ComponentInstallProcessor.java:95) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.1.0.Beta1.jar:] ... 5 more Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: No component found for type 'com.acme.test.ejbremote_core.services.HelloService' with name null for binding com.acme.test.ejbremote.services.HelloWorldServiceBean/hs at org.jboss.as.ejb3.deployment.processors.EjbInjectionSource.getResourceValue(EjbInjectionSource.java:77) at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.processBindings(ComponentInstallProcessor.java:240) at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.access$000(ComponentInstallProcessor.java:74) at org.jboss.as.ee.component.deployers.ComponentInstallProcessor$1.handle(ComponentInstallProcessor.java:194) at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54) at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deployComponent(ComponentInstallProcessor.java:190) at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deploy(ComponentInstallProcessor.java:93) ... 6 more
Any other idea?
-
3. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
prasad.deshpande Nov 29, 2011 6:11 AM (in response to kristjan273)How have you packaged your remote interfaces jar? does that contain just interfaces or other classes (Bean/POJO) too? As Steve said earlier, you'll need remote interface(s) copy in the EAR where you are accessing this bean. It might be that you'll have to rebundle you remote interfaces jar for the use in other EAR(s).
If you say the you have included
ejbremote-ejb-0.0.1-SNAPSHOT.jar
in other ear, looking at above error, it seems that above jar contains bean class as well, which is what it's trying to deploy. You just need interfaces jar.How is your packaging btw?
-
4. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
kristjan273 Nov 29, 2011 9:00 AM (in response to prasad.deshpande)I would be glad if one of you please check the attached eclipse projects:
- 'ejbremote_core' has HelloService @Remote interface and bean impl
- 'ejbremote' tries to use the HelloService as @EJB with above errors
(while I am not yet maven expert, I did maually put HelloService interface to various places inside ejbremote ear with no success)
Thank you in advance for looking into this.
-
ejbremoteProjects.tar.zip 8.5 KB
-
-
5. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
alesj Nov 29, 2011 9:48 AM (in response to kristjan273)As a side note, you could extract interfaces jar into separate deployment, and have both .ears depened on that module.
(AS7 has strict modular classloading, while AS4 (actually any pre-v7) had global view (unless specified diff) of deployment's classes / resources)
-
6. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
kristjan273 Nov 29, 2011 10:39 AM (in response to alesj)Tnx for joining in Ales.
Ok, tried what you proposed:
- created separate jar 'ejbremote-core-ejbapi-0.0.1-SNAPSHOT.jar' with both ear's remote interfaces
- altered both ears ejbs MANIFEST.MF with 'Dependencies: org.apache.log4j,deployment.ejbremote-core-ejbapi-0.0.1-SNAPSHOT.jar'
- removed interfaces from both ejbs
Result:
- ear 'ejbremote_core' deployed with success
- ear 'ejbremote' failed again with
16:34:39,466 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) Starting deployment of "ejbremote-ear.ear" 16:34:39,566 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) Starting deployment of "ejbremote-ejb-0.0.1-SNAPSHOT.jar" 16:34:39,587 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class com.acme.ejbremote.services.AlohaServiceBean in Module "deployment.ejbremote-ear.ear.ejbremot e-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader: java.lang.LinkageError: Failed to link com/acme/ejbremote/services/AlohaServiceBean (Module "deployment.ejbremote-ear.ear .ejbremote-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader) at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:416) [jboss-modules.jar:1.1.0.CR4] at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:260) [jboss-modules.jar:1.1.0.CR4] at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73) [jboss-modules.jar:1.1.0.CR4] at org.jboss.modules.Module.loadModuleClass(Module.java:500) [jboss-modules.jar:1.1.0.CR4] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182) [jboss-modules.jar:1.1.0.CR4] at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:485) [jboss-modules.jar:1.1.0.CR4] at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:421) [jboss-modules.jar:1.1.0.CR4] at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:143) [jboss-modules.jar:1.1.0.CR4] at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:111) at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:54) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.1.0.Beta1.jar:] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_29] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_29] at java.lang.Thread.run(Thread.java:662) [:1.6.0_29] Caused by: java.lang.NoClassDefFoundError: com/acme/ejbremote/services/AlohaService at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_29] at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) [:1.6.0_29] at java.lang.ClassLoader.defineClass(ClassLoader.java:615) [:1.6.0_29] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [:1.6.0_29] at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:330) [jboss-modules.jar:1.1.0.CR4] at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:411) [jboss-modules.jar:1.1.0.CR4] ... 15 more
any idea?
-
7. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
prasad.deshpande Nov 29, 2011 10:40 AM (in response to kristjan273)could you please attach both your ear's from above projects? I'm having trouble at the moment with my eclipse workspace to build it myself...
-
8. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
kristjan273 Nov 29, 2011 5:35 PM (in response to prasad.deshpande)Sure, attached right now.
Have played a little more (by trial/failure) to get some clue, but whatever combination of files, i got 'NoClassDefFoundError' or 'DeploymentUnitProcessingException: No component found for type....'
thank you for looking into this.
-
ejbremote-ear.ear 7.0 KB
-
ejbremote-core-ear.ear 6.9 KB
-
-
9. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
alesj Nov 29, 2011 5:53 PM (in response to kristjan273)Ok, tried what you proposed:
- created separate jar 'ejbremote-core-ejbapi-0.0.1-SNAPSHOT.jar' with both ear's remote interfaces
- altered both ears ejbs MANIFEST.MF with 'Dependencies: org.apache.log4j,deployment.ejbremote-core-ejbapi-0.0.1-SNAPSHOT.jar'
- removed interfaces from both ejbs
Result:
- ear 'ejbremote_core' deployed with success
- ear 'ejbremote' failed again with
any idea?
Hmmm, this should work.
Are you sure the MANIFEST.MF still has that dependency?
As I've sometimes seen this being overridden by build tools, IDE, ...
-
10. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
sfcoy Nov 29, 2011 5:57 PM (in response to kristjan273)- Technically I think these EAR files should fail to deploy as you have specified J2EE 1.4 deployment descriptors for them, and they contain EJB 3.0 ejb jars. (This was a JBoss 4.x extension)
- As I mentioned above, your ejb-remote ear needs an additional jar file containing the HelloService interface class. Classes in the ejb-remote ear cannot access the classes in the ejb-remote-core ear. This again could be considered to be a JBoss 4.x extension
You (and probably a lot of other migrators from earlier JBoss implementations) will find it helpful to become familiar with the "Class Loading Requirements" section (8.3) of the JEE 6 Platform Specification.
-
11. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
sfcoy Nov 29, 2011 9:35 PM (in response to sfcoy)The attached version of your project deloys and runs on JBoss 7.1.0.Beta1
-
ejbremote.tar.gz 8.2 KB
-
ejbremote-core.tar.gz 8.0 KB
-
-
12. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
kristjan273 Nov 30, 2011 7:43 AM (in response to sfcoy)@Stephen
Thank you very much for the time on that, that does actually work and I will go for it in my migration task.
@Ales
But still I would like to see the 'Dependency' in the MANIFEST.MF to properly propagate the value from common jar deployment. I have double checked and packaging tool didn't drop the line from manifest.mf as I have manually added it afterwards.
And I would be very glad if you have time to check the test case to confirm the issue on that (as you state that this should work).
Thanks again to all for the helpful replies.
-
13. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
kristjan273 Nov 30, 2011 8:39 AM (in response to kristjan273)And another simplification if possible. Currently, there is a need to have an explicit defined lookup
@EJB(lookup="java:global/ejbremote-core-ear/ejbremote-core-ejb/HelloServiceBean") HelloService hs;
Do you see any possibility to go for plain @EJB (or @Inject) if possible, without explicit lookup defined (as it is more clean code IMO, but can live with it for now)
-
14. Re: Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
prasad.deshpande Nov 30, 2011 9:01 AM (in response to kristjan273)kristjan slomsek wrote:
Do you see any possibility to go for plain @EJB (or @Inject) if possible, without explicit lookup defined (as it is more clean code IMO, but can live with it for now)
If you want to inject inside a servlet/EJB within same app (ear),
@EJB
HelloService hs;
would still work (unless your EJB implements more than 1 interface). Otherwise, you'll need to provide JNDI name if lookup is from another app within same JVM. However, if this is done from a managed bean, I'm sure I read somewhere that it was a bug in AS 7.0.2 where it was not injecting EJB just with @EJB annotation.