尝试保留JPA实体时出错

时间:2011-08-22 15:07:22

标签: java hibernate jpa jsf-2 jboss-weld

当我尝试从类中持久保存实体时,我收到错误。我创建了类UserController,当我尝试执行Register方法时,em.pertist(usr)行出现错误,当我在UserRegBean中直接运行此代码时,它可以工作......有人可以帮我...

以下是代码:

UserController.java

public Boolean Register(String _userName,String _passwd) throws NoSuchAlgorithmException, UnsupportedEncodingException

    {

         User usr = new User();

         usr.setEmail(_userName);

         MessageDigest digest = MessageDigest.getInstance("SHA-1");

         digest.reset();

         digest.update(pwdSalt);

         byte[] input = digest.digest(_passwd.getBytes("UTF-8"));    

         BASE64Encoder encoder = new BASE64Encoder();

         usr.setPassword(encoder.encode(input));

         em.persist(usr);



        return true;

    }

UserRegBean.java

public void register() throws Exception {

      UserController uControl = new UserController();

          Boolean registered = uControl.Register(this.email,this.passwd);  



/*             User usr = new User();

             usr.setEmail(this.email);

             MessageDigest digest = MessageDigest.getInstance("SHA-1");

             digest.reset();

             digest.update(pwdSalt);

             byte[] input = digest.digest(this.passwd. getBytes("UTF-8"));    

             BASE64Encoder encoder = new BASE64Encoder();

             usr.setPassword(encoder.encode(input));

             em.persist(usr);*/

       }

错误:

10:27:01,524 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-6) java.lang.NullPointerException: javax.faces.el.EvaluationException: java.lang.NullPointerException

    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118) [prettyfaces-jsf2-3.3.0.jar:]

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:734) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:541) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:479) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:407) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110) [prettyfaces-jsf2-3.3.0.jar:]

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]

    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

Caused by: java.lang.NullPointerException

    at net.newideas.scart.controllers.UserController.Register(UserController.java:34) [classes:]

    at net.newideas.scart.model.UserRegBean.register(UserRegBean.java:85) [classes:]

    at net.newideas.scart.model.UserRegBean$Proxy$_$$_WeldClientProxy.register(UserRegBean$Proxy$_$$_WeldClientProxy.java) [classes:]

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_26]

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_26]

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_26]

    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

    at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]

    at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]

    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    ... 32 more



10:27:01,527 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-6) #{userRegBean.register}: java.lang.NullPointerException: javax.faces.FacesException:
#{userRegBean.register}: java.lang.NullPointerException

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118) [prettyfaces-jsf2-3.3.0.jar:]

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:734) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:541) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:479) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:407) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110) [prettyfaces-jsf2-3.3.0.jar:]

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]

    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException

    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    ... 31 more

Caused by: java.lang.NullPointerException

    at net.newideas.scart.controllers.UserController.Register(UserController.java:34) [classes:]

    at net.newideas.scart.model.UserRegBean.register(UserRegBean.java:85) [classes:]

    at net.newideas.scart.model.UserRegBean$Proxy$_$$_WeldClientProxy.register(UserRegBean$Proxy$_$$_WeldClientProxy.java) [classes:]

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_26]

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_26]

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_26]

    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

    at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

    at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]

    at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]

    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]

    ... 32 more



10:27:01,531 ERROR [stderr] (http--127.0.0.1-8080-6) javax.faces.FacesException: #{userRegBean.register}: java.lang.NullPointerException

10:27:01,531 ERROR [stderr] (http--127.0.0.1-8080-6)     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:89)

10:27:01,531 ERROR [stderr] (http--127.0.0.1-8080-6)     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

10:27:01,531 ERROR [stderr] (http--127.0.0.1-8080-6)     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

10:27:01,532 ERROR [stderr] (http--127.0.0.1-8080-6)     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)

10:27:01,532 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

10:27:01,532 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

10:27:01,532 ERROR [stderr] (http--127.0.0.1-8080-6)     at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)

10:27:01,532 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

10:27:01,532 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

10:27:01,532 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:734)

10:27:01,532 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:541)

10:27:01,533 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:479)

10:27:01,533 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:407)

10:27:01,533 ERROR [stderr] (http--127.0.0.1-8080-6)     at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110)

10:27:01,533 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

10:27:01,533 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

10:27:01,533 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

10:27:01,533 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

10:27:01,533 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)

10:27:01,533 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49)

10:27:01,534 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)

10:27:01,534 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

10:27:01,534 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

10:27:01,534 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)

10:27:01,534 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

10:27:01,534 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)

10:27:01,534 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)

10:27:01,534 ERROR [stderr] (http--127.0.0.1-8080-6)     at java.lang.Thread.run(Thread.java:662)

10:27:01,535 ERROR [stderr] (http--127.0.0.1-8080-6) Caused by: javax.faces.FacesException: #{userRegBean.register}: java.lang.NullPointerException

10:27:01,535 ERROR [stderr] (http--127.0.0.1-8080-6)     at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)

10:27:01,535 ERROR [stderr] (http--127.0.0.1-8080-6)     at javax.faces.component.UICommand.broadcast(UICommand.java:315)

10:27:01,535 ERROR [stderr] (http--127.0.0.1-8080-6)     at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)

10:27:01,535 ERROR [stderr] (http--127.0.0.1-8080-6)     at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)

10:27:01,535 ERROR [stderr] (http--127.0.0.1-8080-6)     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

10:27:01,535 ERROR [stderr] (http--127.0.0.1-8080-6)     ... 27 more

10:27:01,535 ERROR [stderr] (http--127.0.0.1-8080-6) Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException

10:27:01,536 ERROR [stderr] (http--127.0.0.1-8080-6)     at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)

10:27:01,536 ERROR [stderr] (http--127.0.0.1-8080-6)     at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)

10:27:01,536 ERROR [stderr] (http--127.0.0.1-8080-6)     ... 31 more

10:27:01,536 ERROR [stderr] (http--127.0.0.1-8080-6) Caused by: java.lang.NullPointerException

10:27:01,536 ERROR [stderr] (http--127.0.0.1-8080-6)     at net.newideas.scart.controllers.UserController.Register(UserController.java:34)

10:27:01,536 ERROR [stderr] (http--127.0.0.1-8080-6)     at net.newideas.scart.model.UserRegBean.register(UserRegBean.java:85)

10:27:01,536 ERROR [stderr] (http--127.0.0.1-8080-6)     at net.newideas.scart.model.UserRegBean$Proxy$_$$_WeldClientProxy.register(UserRegBean$Proxy$_$$_WeldClientProxy.java)

10:27:01,536 ERROR [stderr] (http--127.0.0.1-8080-6)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

10:27:01,537 ERROR [stderr] (http--127.0.0.1-8080-6)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

10:27:01,537 ERROR [stderr] (http--127.0.0.1-8080-6)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

10:27:01,537 ERROR [stderr] (http--127.0.0.1-8080-6)     at java.lang.reflect.Method.invoke(Method.java:597)

10:27:01,537 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.el.parser.AstValue.invoke(AstValue.java:196)

10:27:01,537 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)

10:27:01,537 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)

10:27:01,537 ERROR [stderr] (http--127.0.0.1-8080-6)     at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)

10:27:01,537 ERROR [stderr] (http--127.0.0.1-8080-6)     at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)

10:27:01,538 ERROR [stderr] (http--127.0.0.1-8080-6)     at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)

10:27:01,538 ERROR [stderr] (http--127.0.0.1-8080-6)     ... 32 more

3 个答案:

答案 0 :(得分:0)

你能查看'name =“ SCarteiro ”'的拼写,看看你的名字是否与persistence.xml中的名字一致

答案 1 :(得分:0)

Plz检查UsrController Bean是否在bean定义列表中注册。

似乎容器无法访问bean。

最好的运气!

答案 2 :(得分:0)

我认为@EJB适用于非JEE6(Tomcat或Jetty)&在JEE6 CDI(JBoss或Glassfish)中,您需要使用@Inject