views:

28

answers:

1

I have a Webapplication with EJBs and ServicePOJOs. When i try to access one of those POJOS, i get the following error:

java.lang.NullPointerException
 at com.sonydadc.MyAPP.pa.server.PA_Bean.getServername(PA_Bean.java:539)
 at org.apache.jsp.templates.start_jsp._jspService(start_jsp.java:104)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
 at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:543)
 at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:480)
 at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
 at org.apache.jsp.login.login_jsp._jspService(login_jsp.java:101)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
 at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444)
 at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
 at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
 at org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormAuthenticator.java:316)
 at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:244)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
 at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
 at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Thread.java:619)

My System: Jboss 5.0.1 EJB 3.0 MyFaces 1.1

Can anybody provide some information?

Update: here comes the code: This is how i inject the POJO Object

@EJB(mappedName = "service/ServPOJOBean") 
@IgnoreDependency 
private ServPOJOBean mb; 

And this is the line which causes the nullpointerexception:

mb.getValue("servername");

Strange thing is: it works when i look up the ServicePOJO like this:

MBeanServer server = MBeanServerLocator.locate(); 
ServPOJOBean mb = (ServPOJOBean) MBeanProxyExt.
                             create(ServPOJOBean.class, "jboss:service=ServPOJOBean");

Update

This is how i definedthe ServicePoJO class:

@Service(objectName = "jboss:service=ServPOJOBean")
@Management(ServPOJOBean.class)
@Local(ServPOJOBean.class)
@LocalBinding(jndiBinding = "service/ServPOJOBean")
public class ServPOJOBeanImpl implements ServPOJOBean
{
    ...
}
A: 

The problem is that the injection of your Service POJOS using the @EJB annotation is currently failing, hence the NullPointerException. To be honest, I wasn't even aware this was possible - according to the links below it seems to be an "extented" EJB 3 so it should be - but if it is, double check the JNDI name of the remote interface. And maybe show the code of your Service POJO.

References

Pascal Thivent
HI,this way of injecting a ServicePOJO is described in the book "Jboss 5 AS Developement" page 241.The JNDI name should be right, because i am able to inject a object of that service in another EJB without any problems.Thanks for the links btw.I posted some code of the ServiePOJO in my first Posting (see update).
blnzn
@binzn Ok, thanks for the ref too, I'll look at this. But still, injection isn't occurring here or you wouldn't get a NPE. What are the differences between both EJBs then (the one that work and the other)? Does it work in the current one if you remove the other?
Pascal Thivent
hmmm actually, i wrote something wrong. Where the injection is working, is a servlet, not a EJB. Sorry for that.And is is not working in a backing bean placed a JSF Project.(Sorry for my english btw. I do not speak english that often)
blnzn