4 Replies Latest reply on Feb 17, 2008 2:10 PM by Pete Muir

    NPE with migration to Seam 2.0.1- JBoss 4.2.2

    Guillaume Jeudy Master

      I'm getting NPE when trying to use EntityConverter with Seam 2.0.1 - JBoss 4.2.2.
      I use

      <s:convertEntity />
      in a facelets page. Below is the stack I get:

      2008-02-05 14:43:09,862 DEBUG [org.jboss.seam.Component] seam component not found: entityManager
      2008-02-05 14:43:09,862 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      2008-02-05 14:43:09,862 ERROR [STDERR] 5-Feb-2008 2:43:09 PM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/showpackages.xhtml]
      java.lang.NullPointerException
       at org.jboss.seam.ui.converter.entityConverter.EntityLoader.getPersistenceContext(EntityLoader.java:30)
       at org.jboss.seam.ui.converter.entityConverter.EntityLoader.getPersistenceContext(EntityLoader.java:24)
       at org.jboss.seam.ui.converter.entityConverter.AbstractEntityLoader.put(AbstractEntityLoader.java:46)
       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 org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
       at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
       at org.jboss.seam.util.Work.workInTransaction(Work.java:40)
       at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
       at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
       at org.jboss.seam.ui.converter.entityConverter.EntityLoader_$$_javassist_2.put(EntityLoader_$$_javassist_2.java)
       at org.jboss.seam.ui.converter.EntityConverter.getAsString(EntityConverter.java:77)
       at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getFormattedValue(HtmlBasicRenderer.java:469)
       at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:502)
       at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:757)
       at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:811)
       at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)


      My guess is that for some reasons the persistence context is not wired properly with seam. In the components.xml I have:

      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
       xmlns:core="http://jboss.com/products/seam/core"
       xmlns:security="http://jboss.com/products/seam/security"
       xmlns:transaction="http://jboss.com/products/seam/transaction"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
       http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
      
       <component name="org.jboss.seam.core.init">
       <property name="myFacesLifecycleBug">true</property>
       <property name="jndiPattern">
       rdm-0.1-SNAPSHOT/#{ejbName}/local
       </property>
       <property name="debug">false</property>
       </component>
      
       <component name="org.jboss.seam.remoting.remoting">
       <property name="debug">false</property>
       </component>
      
       <core:managed-persistence-context name="entityManager"
       persistence-unit-jndi-name="java:/rdmEntityManagerFactory" />
      
       <core:manager conversation-timeout="120000"
       concurrent-request-timeout="500" conversation-id-parameter="cid" />
      
       <transaction:ejb-transaction/>
      </components>


      I noticed managed-persistence-context is no longer part of core XSD, could that be related to the issue i'm having ?

      Thanks,
      -Guillaume