Hi.

Please help:
I have written a SSB that uses the @PersistenceContext annotation:

anonymous wrote : @Stateless
  | public class TopicEditAction implements TopicEdit {
  | 
  |     private Topic topic;
  |     @PersistenceContext(unitName = "pfe")
  |     EntityManager em;
  |     ...
  |     public String add() {
  |             System.out.println("try adding a topic...");
  |             if(em==null)System.out.println("em is null");
  |             em.persist(topic);
  |             System.out.println("added topic...");
  |             this.topic=new Topic();
  |             return "editTopic";
  |     }

When the "add" method is executed the output on the console is:

anonymous wrote : 21:50:19,174 INFO  [STDOUT] try adding a topic...
  | 21:50:19,174 INFO  [STDOUT] em is null
  | 21:50:19,174 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces 
Servlet threw exception
  | javax.faces.FacesException: Error calling action method of component with 
id _tagId2:_tagId5
  |     at 
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
  |     at javax.faces.component.UICommand.broadcast(UICommand.java:106)
  |     at 
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
  |     at 
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
  |     at 
org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
  |     at 
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
  |     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |     at 
org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |     at 
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |     at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  |     at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
  |     at 
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
  |     at 
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
  |     at 
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
  |     at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  |     at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  |     at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
  |     at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  |     at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
  |     at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
  |     at 
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  |     at 
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  |     at java.lang.Thread.run(Thread.java:595)
  | Caused by: javax.faces.el.EvaluationException: /addTopic.xhtml @21,69 
action="#{topiceditaction.add}": java.lang.NullPointerException
  |     at 
com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
  |     at 
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
  |     ... 28 more
  | Caused by: java.lang.NullPointerException
  |     at 
org.jboss.projects.performance.actions.TopicEditAction.add(TopicEditAction.java:44)
  |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |     at java.lang.reflect.Method.invoke(Method.java:585)
  |     at com.sun.el.parser.AstValue.invoke(AstValue.java:130)
  |     at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
  |     at 
com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
  |     at 
com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
  |     ... 29 more

My persistence.xml:

anonymous wrote : <entity-manager>
  |    pfe
  |    org.hibernate.ejb.HibernatePersistence
  |    <jta-data-source>java:/projectDS</jta-data-source>
  |    
  |       
  |       
  |    
  | </entity-manager>

I'm using jboss4.0.3SP1 and EJB3.0_RC3. The EAR deploys fine, I think.
No errors and the schema creates as expected.

Any suggestion are very appreciated.

Regards
Dirk 




View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3910550#3910550

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3910550


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to