My stateless session bean(FooBean) has only @Stateless annotation. My JSP (di_foo_test.jsp) simply has @EJB annotation for injecting the remote biz interface(FooRemote) annotated with @Remote.
I have index.htm as:
I have di_foo_test.jsp defined as:
My web.xml contains
I tried deploying the ejb-jar(foo.jar) first and foowebapp.war next in glassfish. Then when I hit index.htm and submit some message, I got org.apache.jasper.JasperException: java.lang.NullPointerException. I checked logs and found following:
[#|2009-07-25T08:48:42.343+0530|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=16;_ThreadName=httpSSLWorkerThread-8080-1;_RequestID=c70c606b-697b-4da0-a9cd-074c932a7a0f;|StandardWrapperValve[EJBTestJsp]: PWC1406: Servlet.service() for servlet EJBTestJsp threw exception
java.lang.NullPointerException at org.apache.jsp.di_005ffoo_005ftest_jsp._jspService(di_005ffoo_005ftest_jsp.java:58)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
...
...
...
Then I undeployed both the ejb-jar and webapp. Created fooapp.ear containing foo.jar and foowebapp.war. Deployed it in glassfish. Tried to access my EJB client via http://localhost:8080/foowebapp . Tried to send some message via index.htm, but still getting the same error.
1. Can some one explain me what's going wrong? The DI works fine if I create a servlet EJb client(FooServlet ).
3. In the posting Raf Szczypiorski, stated "one has to specify the jsp explicitly in web.xml for injection to work". Is it true ? Doesn't seem to work for me.
FYI, I am using Sun Java System Application Server 9.1_02 (build b04-fcs) installed via(glassfish-installer-v2ur2-b04-windows.jar) and JDK1.5.0.11 .
May I request the mdoerator to please move this posting to SCBCD forum where it might attract attention and get some response. I don't want to craete a duplicate Posting for the same.
This message was edited 1 time. Last update was at by lalit upadheyay
What happens when you try to access the di_foo_test.jsp directly instead of going through index.html? Also which exact version of Glassfish do you use? Are you sure that, that version supports injection in JSP? The other post shows that mapping a JSP in the web.xml does indeed help with the injection.
How do I check the exact version of glassfish ? I looked at the console after bringing up the server and clicking the version tab in glassfish admin console. From that I concluded that I am using Sun Java System Application Server 9.1_02 (build b04-fcs). I installed glassfish via glassfish-installer-v2ur2-b04-windows.jar. I am using JDK1.5.0.11 .
Are you sure that, that version supports injection in JSP?
Not sure. But DI does work in a Servlet. I have verified that myself. The post url which I mentioned does not mention the version of glassfish used .
EJB 3 in Action, page 440. - there is a table on top of page, which lists JSPs and helper classes as non-managed, and therefore injection doesn't work for them.
I'll try to find this in ejb core spec. to confirm it.
A JSP container that is not part of a Java EE technology-compliant
implementation is encouraged, but not required, to support resource injection.
Resource injection is not supported for JSP pages or tag files.
Note, that tag handler and event listeners are supported.
I think, that you have no other choice but to use JNDI in JSPs.
In this posting the author(Raf Szczypiorski) was finally succesful in injecting EJB in a JSP using GlassFish server. I am unable to find out the missing link in my repeated efforts to see it working. Also sent a private message to the author but didn't hear back anything.
Once again thanks for replying and sharing the information.
This message was edited 1 time. Last update was at by lalit upadheyay