我有一个带有EJB和ServicePOJO的Web应用程序。当我尝试访问其中一个POJOS时,我收到以下错误:
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)
我的系统:Jboss 5.0.1 EJB 3.0 MyFaces 1.1
有人可以提供一些信息吗?
更新:这里是代码:这是我注入POJO对象的方式
@EJB(mappedName = "service/ServPOJOBean")
@IgnoreDependency
private ServPOJOBean mb;
这是导致nullpointerexception的行:
mb.getValue("servername");
奇怪的是:当我像这样查看ServicePOJO时它会起作用:
MBeanServer server = MBeanServerLocator.locate();
ServPOJOBean mb = (ServPOJOBean) MBeanProxyExt.
create(ServPOJOBean.class, "jboss:service=ServPOJOBean");
更新
这就是我定义ServicePoJO类的方法:
@Service(objectName = "jboss:service=ServPOJOBean")
@Management(ServPOJOBean.class)
@Local(ServPOJOBean.class)
@LocalBinding(jndiBinding = "service/ServPOJOBean")
public class ServPOJOBeanImpl implements ServPOJOBean
{
...
}
答案 0 :(得分:0)
问题是,使用@EJB
注释注入Service POJOS目前失败,因此NullPointerException
。说实话,我甚至都不知道这是可能的 - 根据下面的链接,它似乎是一个“扩展”的EJB 3,所以应该是 - 但如果是,请仔细检查远程接口的JNDI名称。并且可能会显示您的服务POJO的代码。