4 Replies Latest reply on Nov 20, 2006 12:18 AM by Vivek Pinto

    JBoss 3.2.5/MySQL 4.0 ejbCreate throws NullPointer exception

    Vivek Pinto Newbie

      I have created an EJB with CMP in JBoss 3.2.5. It deploys fine. When I try to create an EJB in the database table it gives me a NullPointerException error. Here is the trace

      14:52:53,757 INFO [UserProfile] Table 'UserProfile' already exists
      14:52:54,278 INFO [EJBDeployer] Deployed: file:/C:/devenv/jboss-3.2.5/server/default/tmp/deploy/tmp45702FiboApp.ear-contents/FiboEJB.jar
      14:52:54,558 INFO [TomcatDeployer] deploy, ctxPath=/fibo, warUrl=file:/C:/devenv/jboss-3.2.5/server/default/tmp/deploy/tmp45702FiboApp.ear-contents/FiboWeb.war/
      14:52:54,919 INFO [TomcatDeployer] ClusteredHTTPSessionService not found
      14:52:54,919 ERROR [TomcatDeployer] Failed to setup clustering, clustering disabled
      14:52:55,720 INFO [EARDeployer] Started J2EE application: file:/C:/devenv/jboss-3.2.5/server/default/deploy/FiboApp.ear
      14:52:56,230 INFO [Server] JBoss (MX MicroKernel) [3.2.5 (build: CVSTag=JBoss_3_2_5 date=200406251954)] Started in 1m:15s:809ms
      14:52:56,230 INFO [Tomcat5] Saw org.jboss.system.server.started notification, starting connectors
      14:52:56,571 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080
      14:52:58,153 INFO [ChannelSocket] JK2: ajp13 listening on /0.0.0.0:8009
      14:52:58,173 INFO [JkMain] Jk running ID=0 time=0/741 config=null
      14:54:19,230 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract wonomi.identityManagement.interfaces.UserProfileLocal wonomi.identityManagement.interfaces.UserProfileLocalHome.create(java.lang.String,java.lang.String) throws javax.ejb.CreateException, causedBy:
      java.lang.NullPointerException
      at com.mysql.jdbc.PreparedStatement.asSql(PreparedStatement.java:562)
      at com.mysql.jdbc.PreparedStatement.asSql(PreparedStatement.java:504)
      at com.mysql.jdbc.PreparedStatement.toString(PreparedStatement.java:3228)
      at java.lang.String.valueOf(String.java:2131)
      at java.lang.StringBuffer.append(StringBuffer.java:370)
      at com.mysql.jdbc.trace.Tracer.printParameters(Tracer.aj:240)
      at com.mysql.jdbc.trace.Tracer.printEntering(Tracer.aj:167)

      Here is the ejb Create method:
      /**
      * ejbCreate
      *
      * @ejb.create-method view-type="local"
      */
      public java.lang.Integer ejbCreate(java.lang.String name, String password)
      throws CreateException {
      setId(new Integer(1));
      setUserName(name);
      setPassword(password);
      return null;
      }

      Any help will be greatly appreciated.

        • 1. Re: JBoss 3.2.5/MySQL 4.0 ejbCreate throws NullPointer excep
          Vivek Pinto Newbie

          Here is my ejb-jar.xml file

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

          <ejb-jar >

          <![CDATA[No Description.]]>
          <display-name>Generated by XDoclet</display-name>

          <enterprise-beans>

          <!-- Session Beans -->

          <![CDATA[EJB that computes Fibonacci Suite]]>
          <display-name>Fibo EJB</display-name>

          <ejb-name>Fibo</ejb-name>

          wonomi.identityManagement.interfaces.FiboHome
          wonomi.identityManagement.interfaces.Fibo
          <ejb-class>wonomi.identityManagement.ejb.FiboBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>



          <!--
          To add session beans that you have deployment descriptor info for, add
          a file to your XDoclet merge directory called session-beans.xml that contains
          the markup for those beans.
          -->

          <!-- Entity Beans -->

          <![CDATA[]]>

          <ejb-name>UserProfile</ejb-name>

          <local-home>wonomi.identityManagement.interfaces.UserProfileLocalHome</local-home>
          wonomi.identityManagement.interfaces.UserProfileLocal

          <ejb-class>wonomi.identityManagement.ejb.UserProfileBean</ejb-class>
          <persistence-type>Container</persistence-type>
          <prim-key-class>java.lang.Integer</prim-key-class>
          true
          <cmp-version>2.x</cmp-version>
          <abstract-schema-name>UserProfile</abstract-schema-name>
          <cmp-field >
          <![CDATA[]]>
          <field-name>id</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[]]>
          <field-name>userName</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[]]>
          <field-name>password</field-name>
          </cmp-field>
          <primkey-field>id</primkey-field>


          <query-method>
          <method-name>findAll</method-name>
          <method-params>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[select object(o) from UserProfile o]]></ejb-ql>


          <query-method>
          <method-name>findByID</method-name>
          <method-params>
          <method-param>java.lang.Integer</method-param>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[select object(o) from UserProfile o where o.id = (?1)]]></ejb-ql>


          <query-method>
          <method-name>findByUserName</method-name>
          <method-params>
          <method-param>java.lang.String</method-param>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[select object(o) from UserProfile o where o.userName = (?1)]]></ejb-ql>


          <query-method>
          <method-name>findAll</method-name>
          <method-params>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[select object(o) from UserProfile o]]></ejb-ql>

          <!-- Write a file named ejb-finders-UserProfileBean.xml if you want to define extra finders. -->


          <!--
          To add entity beans that you have deployment descriptor info for, add
          a file to your XDoclet merge directory called entity-beans.xml that contains
          the markup for those beans.
          -->

          <!-- Message Driven Beans -->
          <!--
          To add message driven beans that you have deployment descriptor info for, add
          a file to your XDoclet merge directory called message-driven-beans.xml that contains
          the <message-driven></message-driven> markup for those beans.
          -->

          </enterprise-beans>

          <!-- Relationships -->

          <!-- Assembly Descriptor -->
          <assembly-descriptor >
          <!--
          To add additional assembly descriptor info here, add a file to your
          XDoclet merge directory called assembly-descriptor.xml that contains
          the <assembly-descriptor></assembly-descriptor> markup.
          -->

          <!-- finder permissions -->

          <!-- finder permissions -->

          <!-- transactions -->

          <!-- finder transactions -->
          </assembly-descriptor>

          </ejb-jar>

          • 2. Re: JBoss 3.2.5/MySQL 4.0 ejbCreate throws NullPointer excep
            Vivek Pinto Newbie

            I performed a "Select * from userprofile" from the MySQL query browser and it worked fine. The mysql check shows that the database is running fine. The JBoss log indicates that it is able to locate and connect to mySQL datasource.

            • 4. Re: JBoss 3.2.5/MySQL 4.0 ejbCreate throws NullPointer excep
              Vivek Pinto Newbie

              An update:
              So I figured I would try the new JBoss IDE and see if it would resolve my issues. Unfortunately I get the same error.

              Hss anyone got the JBoss CMP to work on MySQL? IF kindly provide any help you believe may be useful