1 Reply Latest reply on Feb 9, 2003 2:57 PM by ABAZIOU

    Runtime Error with User/UserManagement beans

    ABAZIOU Newbie

      I try to develop my first entity bean using CMP on
      User/UserManagement beans.

      The sample consist of an entity bean (User)
      a session bean UserManagement
      and a client.
      The UserBean only consist of 2 fields (email and password)

      deploy is OK but i have a runtime error :

      trace:
      19:30:40,779 ERROR [LogInterceptor] RuntimeException:
      java.lang.NullPointerException
      at fr.free.banks.UserManagementBean.addUser(UserManagementBean.java:53)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(S
      tatelessSessionContainer.java:660)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invo
      ke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(Stat
      elessSessionInstanceInterceptor.java:77)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
      rceptor.java:107)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
      torCMT.java:178)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:6
      0)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.
      java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContai
      ner.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:712)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
      382)
      at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
      60)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
      .java:701)
      at java.lang.Thread.run(Thread.java:536)
      19:30:48,639 ERROR [LogInterceptor] RuntimeException:
      java.lang.NullPointerException
      at fr.free.banks.UserManagementBean.addUser(UserManagementBean.java:53)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(S
      tatelessSessionContainer.java:660)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invo
      ke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(Stat
      elessSessionInstanceInterceptor.java:77)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
      rceptor.java:107)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
      torCMT.java:178)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:6
      0)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.
      java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContai
      ner.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:712)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
      382)
      at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
      60)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
      .java:701)
      at java.lang.Thread.run(Thread.java:536)

        • 1. Re: Runtime Error with User/UserManagement beans
          ABAZIOU Newbie

          I'va solved the problem,
          missing some code in ejbCreate of UserManagementBean
          (silly error)

          Still having a problem with

          I think i missed an EJB QL in my files : for method
          findByPrimaryKey

          How should i declare it?
          If i had an * @ejb:finder tag i have
          duplicated method

          What's the solution

          Here is th beginning of my Bean code :


          import javax.ejb.CreateException;
          import javax.ejb.EntityBean;

          /**
          * @ejb:bean name="User"
          * jndi-name="jndi/UserBean"
          * type="CMP"
          * cmp-version="2.x"
          *
          * @ejb:pk class = "java.lang.String"
          *
          * @ejb:env-entry name = "DataSourceName" value = "MySqlDS"
          *
          * @ejb:finder
          * signature="Collection findAll()"
          * query="select Object(o) from UserBean as o"
          * result-type-mapping="Local"
          *
          * @ejb:finder
          * signature="User findByEmail(java.lang.String email)"
          * query="select Object(o) from UserBean as o where o.email = ?1"
          * result-type-mapping="Local"
          *
          * @jboss:table-name table-name = "user"
          *
          * @jboss:create-table create = "${jboss.create.table}"
          *
          * @jboss:datasource "MySqlDS"
          *
          *
          **/
          public abstract class UserBean implements EntityBean {

          /**
          * Context set by container
          */
          private javax.ejb.EntityContext _entityContext;

          /**
          * @ejb:persistent-field
          * @ejb:interface-method
          * @ejb:pk-field
          * @jboss:column-name name = "email"
          *
          **/
          public abstract String getEmail();

          /**
          * @ejb:interface-method
          */
          public abstract void setEmail(String email);



          Trace:

          21:04:19,092 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.0.4_tomcat-
          4.1.12/server/default/deploy/myEJB.jar
          21:04:24,482 ERROR [User] Error checking if entity exists
          java.sql.SQLException: Syntax error or access violation: You have an error in yo
          ur SQL syntax near '' at line 1
          at com.mysql.jdbc.MysqlIO.sendCommand(Unknown Source)
          at com.mysql.jdbc.MysqlIO.sqlQueryDirect(Unknown Source)
          at com.mysql.jdbc.Connection.execSQL(Unknown Source)
          at com.mysql.jdbc.PreparedStatement.executeQuery(Unknown Source)
          at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.executeQ
          uery(LocalPreparedStatement.java:289)
          at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.entityExists(J
          DBCCreateEntityCommand.java:154)
          at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCr
          eateEntityCommand.java:127)
          at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStor