aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes deployment descriptor (ejb-jar.xml) problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "deployment descriptor (ejb-jar.xml) problem" Watch "deployment descriptor (ejb-jar.xml) problem" New topic
Author

deployment descriptor (ejb-jar.xml) problem

Alexander V Fahrmann
Greenhorn

Joined: Jan 16, 2008
Posts: 22
Hi, Ranchers!

Does anyone know how to describe a Bean in the deployment descriptor in such a way as to get rid of annotations entirely/completely?

For now my ejb-jar.xml file looks like this:


The interface:


And the class:


client application:

the EJB Container - GlassFish (SJSAS 9.1)

The application does not work! I am getting the InjectionException.
Any ideas why?
Because the deployment descriptor is correct: the container "knows" what a Bean is described by the <session>-element (I tried to add some <env-entry> elements and corresponding @Resources in the class in order to test that).
[ August 19, 2008: Message edited by: Alexander V Fahrmann ]

SCJD, SCBCD, SCWCD
Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

Can you post a more detailed excerpt of the logged exception ?


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Also, tell us how you are running the client. Are you using a client-container? Injection does not work outside the container.


SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
Alexander V Fahrmann
Greenhorn

Joined: Jan 16, 2008
Posts: 22
Originally posted by Sergio Tridente:
Also, tell us how you are running the client. Are you using a client-container? Injection does not work outside the container.


Hi, Sergio.
Yes, I am using the client-container:
> appclient -client CLIENT-JAR

Actually, the problem is as follows:
if the class is annotated (that is, if the @Stateless and the @Remote annotations applied), the application works fine; but if I comment these
annotations (and make no other changes), then the client gets the
com.sun.enterprise.InjectionException at run-time (deployment is successfull in both cases).

Another symptom: in the first case (when the annotations are present) the bean gets bind to the JNDI-context (according to the JNDI browser); in the latter case (annotations are commented) does not (at least I could not see it via JNDI browser)!

It seems that the GlassFish (itself!) does not comply to the EJB 3 Specification (because it is the Container who does not process the deployment descriptor properly)?


Stack trace of the issue:

Buildfile: build.xml

init:
[delete] Deleting 4 files from D:\Programs\Eclipse\HelloEJB\build
[delete] Deleted 6 directories from D:\Programs\Eclipse\HelloEJB\build
[delete] Deleting 2 files from D:\Programs\Eclipse\HelloEJB\dist
[mkdir] Created dir: D:\Programs\Eclipse\HelloEJB\build\ejb
[mkdir] Created dir: D:\Programs\Eclipse\HelloEJB\build\client

compile:
[javac] Compiling 3 source files to D:\Programs\Eclipse\HelloEJB\build\ejb
[javac] Compiling 1 source file to D:\Programs\Eclipse\HelloEJB\build\client

pack:
[jar] Building jar: D:\Programs\Eclipse\HelloEJB\dist\ejb.jar
[jar] Building jar: D:\Programs\Eclipse\HelloEJB\dist\client.jar

deploy:
[echo] dist/ejb.jar
[exec] Command deploy executed successfully.

run:
[exec] 20.08.2008 15:52:32 com.sun.enterprise.appclient.MainWithModuleSupport <init>
[exec] WARNING: ACC003: Application threw an exception.
[exec] com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref helloEJB.client.Main/hello@jndi: hello.bean.Hello@null@hello.bean.Hello@Session@null into class helloEJB.client.Main
[exec] at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
[exec] at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
[exec] at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:144)
[exec] at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:136)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:420)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
[exec] at com.sun.enterprise.appclient.Main.main(Main.java:200)
[exec] Caused by: javax.naming.NameNotFoundException: hello.bean.Hello#hello.bean.Hello not found
[exec] at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
[exec] at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
[exec] at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
[exec] at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:129)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[exec] at java.lang.reflect.Method.invoke(Method.java:597)
[exec] at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
[exec] at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
[exec] at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
[exec] at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
[exec] at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
[exec] Exception in thread "main" java.lang.RuntimeException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref helloEJB.client.Main/hello@jndi: hello.bean.Hello@null@hello.bean.Hello@Session@null into class helloEJB.client.Main
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:487)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
[exec] at com.sun.enterprise.appclient.Main.main(Main.java:200)
[exec] Caused by: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref helloEJB.client.Main/hello@jndi: hello.bean.Hello@null@hello.bean.Hello@Session@null into class helloEJB.client.Main
[exec] at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
[exec] at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
[exec] at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:144)
[exec] at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:136)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:420)
[exec] ... 2 more
[exec] Caused by: javax.naming.NameNotFoundException: hello.bean.Hello#hello.bean.Hello not found
[exec] at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
[exec] at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
[exec] at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
[exec] at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:129)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[exec] at java.lang.reflect.Method.invoke(Method.java:597)
[exec] at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
[exec] at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
[exec] at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
[exec] at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
[exec] at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)

BUILD SUCCESSFUL
Total time: 8 seconds


(I have been using Ant to automate the process - but that does not matter)
Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

Your client runs inside the Glassfish container ?
If not, the injection cannot happen.
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Alexander,

If I understand it correctly you are deploying a file named ejb.jar (which contains your bean class, remote interface and META-INF/ejb-jar.xml) into Glassfish and you have another jar (client.jar) which contains your client and the remote interfaces of your bean. Is this right?

Please:
1) Explain how both JARs are packed and how (which one/s) you are deploying.
2) Try packaging the ejb-jar.xml file inside your client.jar (I don't know how this works).
3) Try doing a JNDI lookup intead of injecting the bean in your client. Does this work? (I suppose it does not.)

Post the answers back, please.
Alexander V Fahrmann
Greenhorn

Joined: Jan 16, 2008
Posts: 22
Originally posted by Sergio Tridente:
Alexander,

If I understand it correctly you are deploying a file named ejb.jar (which contains your bean class, remote interface and META-INF/ejb-jar.xml) into Glassfish and you have another jar (client.jar) which contains your client and the remote interfaces of your bean. Is this right?

Please:
1) Explain how both JARs are packed and how (which one/s) you are deploying.
2) Try packaging the ejb-jar.xml file inside your client.jar (I don't know how this works).
3) Try doing a JNDI lookup intead of injecting the bean in your client. Does this work? (I suppose it does not.)

Post the answers back, please.


Hi, Sergio.

1. Yes, you understood me correctly: I have 2 (two) jar-files: ejb.jar (which gets deployed), and client.jar (which gets launched within the appclient-container). Yes, ejb-jar.xml is present inside the ejb.jar file:
the result of: >jar -tf ejb.jar:

META-INF/
META-INF/MANIFEST.MF
hello/
hello/bean/
hello/bean/Hello.class
hello/bean/HelloBean.class
META-INF/ejb-jar.xml

2. I tried to add the ejb-jar.xml file into the client.jar:
> jar -tf client.jar

META-INF/
META-INF/MANIFEST.MF
helloEJB/
helloEJB/client/
helloEJB/client/Main.class
META-INF/ejb-jar.xml

and got the following:

Buildfile: build.xml

init:
[delete] Deleting 3 files from D:\Programs\Eclipse\HelloEJB\build
[delete] Deleted 6 directories from D:\Programs\Eclipse\HelloEJB\build
[delete] Deleting 2 files from D:\Programs\Eclipse\HelloEJB\dist
[mkdir] Created dir: D:\Programs\Eclipse\HelloEJB\build\ejb
[mkdir] Created dir: D:\Programs\Eclipse\HelloEJB\build\client

compile:
[javac] Compiling 2 source files to D:\Programs\Eclipse\HelloEJB\build\ejb
[javac] Compiling 1 source file to D:\Programs\Eclipse\HelloEJB\build\client

pack:
[jar] Building jar: D:\Programs\Eclipse\HelloEJB\dist\ejb.jar
[jar] Building jar: D:\Programs\Eclipse\HelloEJB\dist\client.jar

deploy:
[echo] dist/ejb.jar
[exec] Command deploy executed successfully.

run:
[exec] com.sun.enterprise.appclient.UserError: The archive D:\Programs\Eclipse\HelloEJB\dist\client.jar seems to be valid but an app client or an enterprise app was expected

BUILD SUCCESSFUL
Total time: 8 seconds

it seems, that it is illegal to put ejb-jar.xml file into a client application.
3. I tried JNDI-lookup asa follows:

and it does not work either (of course, when the anntotations are absent (@Stateless and @Remote annotations in the HelloBean); when annotations are present - the code works as expected).
[ August 21, 2008: Message edited by: Alexander V Fahrmann ]
Alexander V Fahrmann
Greenhorn

Joined: Jan 16, 2008
Posts: 22
Hold the charge, guys!
Do not beat me too badly, please!

Having read a lot of docs/forum-posts/XSD-documents I found the root of the issue: compatability of EJB 3.0 with the EJB 2.1 is the culprit.

The ejb-jar.xml file should look like this:


That is, a <business-remote> element should be used instead of the <remote> (a bloody heritage of the EJB 2.1).

P.S.: The application works now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: deployment descriptor (ejb-jar.xml) problem