9 Replies Latest reply on Feb 25, 2008 4:46 PM by jguglielmin

    NullPointerException at com.sun.enterprise.util.EntityManagerWrapper

    piotrjanik
      I'm trying to run my SEAM ICEFACES app on GLASSFISH.
      But I'm getting this error, when I want to use hibernate(searching db).

      Code:

      `

      javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: java
      .lang.NullPointerException
      java.lang.NullPointerException
              at com.sun.enterprise.util.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:349)
              at org.jboss.seam.persistence.EntityManagerProxy.createQuery(EntityManagerProxy.java:79)
              at nautilia.sklepy.ejb.web.customers.Cu||stomerSearch.Find(CustomerSearch.java:76)
              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.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.j
      ava:1067)
              at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
              at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4005)
              at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.j
      ava:483)
              at com.sun.ejb.Invocation.proceed(Invocation.java:498)
              at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
              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.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:4
      2)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyI
      nterceptor.java:26)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSession
      ProxyInterceptor.java:27)
      `
           



      persistence.xml
      `

      <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
          <persistence-unit name="sklepyPU" transaction-type="JTA">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <jta-data-source>jdbc/mysql</jta-data-source>
              <properties>
                 
                  <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/>
                  <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
                  <property name="hibernate.case.user_query_cache" value="true"/>
                  <property name="hibernate.show_sql" value="true"/>
              </properties>
             
             
             
          </persistence-unit>
      </persistence>
           
      `


      components.xml
      `
      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:transaction="http://jboss.com/products/seam/transaction"
                  xmlns:security="http://jboss.com/products/seam/security"
                  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/persistence http://jboss.com/products/seam/persistence-2.
      0.xsd
                  http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.
      0.xsd
                  http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
      http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
         
          <core:init jndi-pattern="java:comp/env/sklepy/#{ejbName}/local" debug="true"/>
         
          <core:manager conversation-timeout="120000"
                        concurrent-request-timeout="500"
                        conversation-id-parameter="cid"/>
         
          <persistence:entity-manager-factory name="sklepyPU" persistence-unit-name="sklepyPU"/>
         
          <persistence:managed-persistence-context name="em"
                                                   auto-create="true"
                                                   entity-manager-factory="#{sklepyPU}"/>
        
          <transaction:ejb-transaction />
         
         
      </components>
      `

      THX
        • 1. Re: NullPointerException at com.sun.enterprise.util.EntityManagerWrapper
          piotrjanik

          Sorry, cannot paste content of persistence.xml because of this new forum.

          • 2. Re: NullPointerException at com.sun.enterprise.util.EntityManagerWrapper
            christian.bauer

            And why can't you paste it? We need to know what is wrong.

            • 3. Re: NullPointerException at com.sun.enterprise.util.EntityManagerWrapper
              piotrjanik

              Invalid markup: expecting ALPHANUMERICWORD, found '?' at ' (and)lt (question)xml ...


              You can't post tags and special characters.
              Try to paste into textarea heading of persistence.xml

              • 4. Re: NullPointerException at com.sun.enterprise.util.EntityManagerWrapper
                christian.bauer

                It works fine if you put it in code blocks. Read the formatting Help (the green button).


                • 5. Re: NullPointerException at com.sun.enterprise.util.EntityManagerWrapper
                  piotrjanik

                  Here are my persistence.xml and components.xml



                  <?xml version="1.0" encoding="UTF-8"?>
                  <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                      <persistence-unit name="sklepyPU" transaction-type="JTA">
                          <provider>org.hibernate.ejb.HibernatePersistence</provider>
                          <jta-data-source>jdbc/mysql</jta-data-source>
                          <properties>
                              
                              <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/>
                              <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                              <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
                              <property name="hibernate.case.user_query_cache" value="true"/>
                              <property name="hibernate.show_sql" value="true"/>
                          </properties>
                          
                          
                          
                      </persistence-unit>
                  </persistence>
                  



                  <?xml version="1.0" encoding="UTF-8"?>
                  <components xmlns="http://jboss.com/products/seam/components"
                              xmlns:core="http://jboss.com/products/seam/core"
                              xmlns:persistence="http://jboss.com/products/seam/persistence"
                              xmlns:transaction="http://jboss.com/products/seam/transaction"
                              xmlns:security="http://jboss.com/products/seam/security"
                              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/persistence http://jboss.com/products/seam/persistence-2.0.xsd
                              http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
                              http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                  http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
                      
                      <core:init jndi-pattern="java:comp/env/sklepy/#{ejbName}/local" debug="true"/>
                      
                      <core:manager conversation-timeout="120000"
                                    concurrent-request-timeout="500"
                                    conversation-id-parameter="cid"/>
                      
                      <persistence:entity-manager-factory name="sklepyPU" persistence-unit-name="sklepyPU"/>
                      
                      <persistence:managed-persistence-context name="em"
                                                               auto-create="true"
                                                               entity-manager-factory="#{sklepyPU}"/>
                     
                      <transaction:ejb-transaction />
                      
                      
                  </components>
                  


                  • 6. Re: NullPointerException at com.sun.enterprise.util.EntityManagerWrapper
                    pmuir

                    We need to see CustomerSearch.Find()

                    • 7. Re: NullPointerException at com.sun.enterprise.util.EntityManagerWrapper
                      piotrjanik

                      Hi,


                      I have already resolved the problem.


                      THX for help


                      Regards,
                      Peter

                      • 8. Re: NullPointerException at com.sun.enterprise.util.EntityManagerWrapper
                        jguglielmin

                        Cheers Peter....care to share how you resolved this with the rest of us (for future reference)?

                        • 9. Re: NullPointerException at com.sun.enterprise.util.EntityManagerWrapper
                          jguglielmin

                          For anyone else out there using Glassfish, Seam and ICEfaces, I managed to get everything working with v2.0 except had some problems with transactions when using ajax-server-push.  Once I download and tried Glassfish v2.1 though, everything worked as it should.