9 Replies Latest reply on Jan 25, 2002 8:39 PM by glm

    Still Unabe to Create Entity Bean

    glm Newbie

      Hi,
      I previously posted that I was unable to Create an Entity Bean using JBoss 2.4.3 and the MS JDBC Driver. I installed another JDBC Driver, "JSQLConnect" with the same resulting Error.

      I have modified the Bean to use a Long as its primary key instead of wrapping it in a PK class. I modified the ejb-jar.xml as follows :


      Client Entity Bean
      <ejb-name>Client</ejb-name>
      com.paye.payroll.ClientHome
      com.paye.payroll.ClientRemote
      <ejb-class>com.paye.payroll.ClientBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <!-- prim-key-class>com.paye.payroll.ClientPK</prim-key-class -->
      <prim-key-class>java.lang.Long</prim-key-class>
      <cmp-field><field-name>clientId</field-name></cmp-field>
      <cmp-field><field-name>name</field-name></cmp-field>
      <cmp-field><field-name>address</field-name></cmp-field>
      <cmp-field><field-name>city</field-name></cmp-field>
      <cmp-field><field-name>state</field-name></cmp-field>
      <cmp-field><field-name>zip</field-name></cmp-field>
      <cmp-field><field-name>taxId</field-name></cmp-field>
      <primkey-field>clientId</primkey-field>
      False
      .
      .
      .


      I have modified my ejbCreate() to return null as was suggested by Sven.

      public Long ejbCreate( String name, String address, String city,
      String zip, String taxId) throws CreateException,
      RemoteException
      {
      Long number = null;

      try
      {
      InitialContext ictx = new InitialContext();
      String propFileName = (String)ictx.lookup("java:comp/env/PayeProperties");

      if( this.seqGen == null )
      this.seqGen = new SeqGenerator2(propFileName);

      if( this.seqGen == null )
      log.debug("unable to instanciate a SeqGenerator object");
      else
      log.debug("We have a SeqGenerator object");

      number = new Long(seqGen.generate("Client"));
      if( number != null )
      log.debug("Got an Autogenerated number");
      }
      catch(javax.naming.NamingException ne)
      {
      ne.printStackTrace();
      }
      catch( Exception e )
      {
      System.out.println(e.getMessage());
      }
      this.clientId = number;
      this.name = name;
      this.address = address;
      this.city = city;
      this.zip = zip;
      this.taxId = taxId;

      log.debug("ClientId ="+clientId+
      "\n name ="+name+"\n address="+address+
      "\n city="+city+"\n zip="+zip+"\ntaxid="+taxId);

      return null;
      }

      ======================


      The code that I call from my Bean Tester is :

      public static void main(String args[]) throws Exception
      {
      InitialContext iniCtx = null;
      ClientHome home = null;
      ClientRemote bean = null;
      ClientRemote bean2 = null;
      Long pk= null;
      Object ref = null;
      try
      {
      if( (iniCtx = new InitialContext()) == null)
      log.debug("Initial context is null");
      else
      log.debug("Got initial context");
      ref = iniCtx.lookup("payroll/Client");
      if( ref == null)
      log.debug("Reference object is null");
      else
      log.debug("Got reference object");
      }
      catch( Exception e )
      {
      log.debug("Initializing error :"+e.getMessage());
      System.exit(1);
      }
      try
      {
      home = (ClientHome) ref;
      bean = home.create("Acme Tools","222 Cabot Rd", "Laguna Niguel", "92677", "TXID-123");
      //System.out.println("bean = "+bean.getBeanState());
      }
      catch(...){....}

      ==================================

      and this is the output from the log file.

      [PropertyReader] in readInStream() : propFileName = Paye.properties
      [PropertyReader] URL for propFile is jar:file:/D:/JBoss-2.4.3_Tomcat-3.2.3/jboss/tmp/deploy/Default/Paye_Payroll.jar/ejb1002.jar!/Paye.properties
      [PropertyReader] Properties file was loaded into p
      [PropertyReader] p was set to SystemProperties
      [ClientBean] We have a SeqGenerator object
      [JDBCGenerator] in generate(String seq) : seq =Client
      [JDBCGenerator] in generate(String seq) : conn =com.microsoft.jdbc.sqlserver.SQLServerConnection@762fc7
      [SeqGenerator2] jdbcGen.generate() made new clientId = 38
      [ClientBean] Got an Autogenerated number
      [ClientBean] ClientId =38
      name =Acme Tools
      address=222 Cabot Rd
      city=Laguna Niguel
      zip=92677
      taxid=TXID-123
      [Client] TRANSACTION ROLLBACK EXCEPTION:null
      Embedded Exception
      null; nested exception is:
      javax.ejb.EJBException: null
      Embedded Exception
      null

      ================
      The database is MS SQLServer 2000 and the database table look like this:

      clientId BIGINT IDENTITY NO NULLS,
      name VARCHAR(50),
      address VARCHAR(30),
      city VARCHAR(30),
      state CHAR(2),
      zip CHAR(5),
      taxId CHAR(9) ;

      Can anyone tell me why I am unable to create this CMP Entity Bean?

      Thanks,

      Gary

        • 1. Re: Still Unabe to Create Entity Bean
          Mark Desrosier Newbie

          Gary,
          You did not post your jaws.xml, which would be helpful.

          However, you can get more information by editting standardjaws.xml to turn on debugging. About the 5th line of this file set this: true

          This will result in all the SQL stmts that will be executed to be logged to server.log. If the SQL is not what you expected, then you can address the cause of that.

          • 2. Re: Still Unabe to Create Entity Bean
            glm Newbie

            I have install JBoss2.4.4 and have now gotten more information. It looks like there is a chick&egg thing going on with the database and JBoss.

            I was getting back an error telling me that I needed to turn on the INSERT_IDENTITY flag for the table. Our DB admin suggested that I not make the clientId a primary key and to turn off the identity flag on the clientId field. I did so and got a different set of errors. No it looks as though JBoss is failing on trying to find the entity (clientId) that I just tried to create with ejbCreate(). Here is the error message:

            [10:23:31,726,PropertyReader] in readInStream() : propFileName = Paye.properties
            [10:23:31,726,PropertyReader] URL for propFile is jar:file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/Paye_Payroll.jar/ejb1003.jar!/Paye.properties
            [10:23:31,736,PropertyReader] Properties file was loaded into p
            [10:23:31,736,PropertyReader] p was set to SystemProperties
            [10:23:31,736,ClientBean] We have a SeqGenerator object
            [10:23:31,746,JDBCGenerator] in generate(String seq) : seq =Client
            [10:23:31,766,JDBCGenerator] in generate(String seq) : conn =com.microsoft.jdbc.sqlserver.SQLServerConnection@34151f
            [10:23:31,816,SeqGenerator2] jdbcGen.generate() made new clientId = 65
            [10:23:31,816,ClientBean] Got an Autogenerated number
            [10:23:32,056,Client] TRANSACTION ROLLBACK EXCEPTION:
            javax.transaction.TransactionRolledbackException: Load failed; nested exception is:
            java.rmi.NoSuchObjectException: Entity 65 not found; nested exception is:
            java.rmi.ServerException: Load failed; nested exception is:
            java.rmi.NoSuchObjectException: Entity 65 not found
            java.rmi.ServerException: Load failed; nested exception is:
            java.rmi.NoSuchObjectException: Entity 65 not found
            java.rmi.NoSuchObjectException: Entity 65 not found
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.handleResult(JDBCLoadEntityCommand.java:172)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCQueryCommand.executeStatementAndHandleResult(JDBCQueryCommand.java:59)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:156)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:147)
            at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.loadEntity(JAWSPersistenceManager.java:156)
            at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:362)
            at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:287)
            at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:197)
            at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:125)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
            at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:428)
            at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:410)
            at java.lang.reflect.Method.invoke(Native Method)
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
            at sun.rmi.transport.Transport$1.run(Transport.java:152)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
            at java.lang.Thread.run(Thread.java:484)

            ===============

            here are the jaws.xml entries of interest:


            java:/SQLServerPool
            <type-mapping>MS SQLSERVER2000</type-mapping>

            <default-entity>
            <create-table>true</create-table>
            <tuned-updates>false</tuned-updates>
            <read-only>false</read-only>
            <time-out>300</time-out>
            <select-for-update>false</select-for-update>
            <remove-table>false</remove-table>
            true
            </default-entity>
            .
            .
            .
            <enterprise-beans>

            <ejb-name>Client</ejb-name>
            <table-name>CLIENT</table-name>
            <remove-table>false</remove-table>
            <cmp-field>
            <field-name>clientId</field-name>
            <column-name>clientid</column-name>
            <jdbc-type>INTEGER</jdbc-type>
            <sql-type>int</sql-type>
            </cmp-field>
            <cmp-field>
            <field-name>name</field-name>
            <column-name>NAME</column-name>
            <jdbc-type>VARCHAR</jdbc-type>
            <sql-type>VARCHAR(50)</sql-type>
            </cmp-field>
            <cmp-field>
            <field-name>address</field-name>
            <column-name>ADDRESS</column-name>
            <jdbc-type>VARCHAR</jdbc-type>
            <sql-type>VARCHAR(30)</sql-type>
            </cmp-field>
            <cmp-field>
            <field-name>city</field-name>
            <column-name>CITY</column-name>
            <jdbc-type>VARCHAR</jdbc-type>
            <sql-type>VARCHAR(30)</sql-type>
            </cmp-field>
            <cmp-field>
            <field-name>state</field-name>
            <column-name>STATE</column-name>
            <jdbc-type>CHAR</jdbc-type>
            <sql-type>char(2)</sql-type>
            </cmp-field>
            <cmp-field>
            <field-name>zip</field-name>
            <column-name>ZIP</column-name>
            <jdbc-type>CHAR</jdbc-type>
            <sql-type>char(5)</sql-type>
            </cmp-field>
            <cmp-field>
            <field-name>taxId</field-name>
            <column-name>TAXID</column-name>
            <jdbc-type>CHAR</jdbc-type>
            <sql-type>char(9)</sql-type>
            </cmp-field>

            <!--

            findByEmployeeIdAndClientId
            employeeId = {0} AND clientId = {1}
            employeeId DESC
            <read-ahead>true</read-ahead>

            -->

            ========================

            I have tried this was several JDBC Drivers and even the JDBC-ODBC bridge from Sun and I get the same error.

            Any Suggestions???

            Gary


            • 3. Re: Still Unabe to Create Entity Bean
              David Jencks Master

              I don't know what IDENTITY columns are -- is it possible that the db is still supplying its own value instead of using the one you supply? This would certainly cause what you are seeing.

              In general jboss cmp cannot at the moment deal with pk values generated by the db on insert.

              • 4. Re: Still Unabe to Create Entity Bean
                glm Newbie

                DavidJencks;

                I have tried a combination of things like setting clientId as the primary key and turning off the identity flag. This results in the following error :

                [INFO,Default] JBoss-2.4.4 Started in 0m:11s.387
                [ERROR,Client] TRANSACTION ROLLBACK EXCEPTION:
                javax.transaction.TransactionRolledbackException: Load failed; nested exception is:
                java.rmi.NoSuchObjectException: Entity 68 not found; nested exception is:
                java.rmi.ServerException: Load failed; nested exception is:
                java.rmi.NoSuchObjectException: Entity 68 not found
                java.rmi.ServerException: Load failed; nested exception is:
                java.rmi.NoSuchObjectException: Entity 68 not found
                java.rmi.NoSuchObjectException: Entity 68 not found
                at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.handleResult(JDBCLoadEntityCommand.java:172)
                at org.jboss.ejb.plugins.jaws.jdbc.JDBCQueryCommand.executeStatementAndHandleResult(JDBCQueryCommand.java:59)
                at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:156)
                at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:147)
                at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.loadEntity(JAWSPersistenceManager.java:156)
                at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:362)
                at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:287)
                at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:197)
                at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:125)
                at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
                at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
                at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
                at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
                at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
                at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:428)
                at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:410)
                at java.lang.reflect.Method.invoke(Native Method)
                at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
                at sun.rmi.transport.Transport$1.run(Transport.java:152)
                at java.security.AccessController.doPrivileged(Native Method)
                at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
                at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
                at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
                at java.lang.Thread.run(Thread.java:484)
                =======================

                when I unset clientId as the primary key and go without a designated primary key in the database, I get the same error.

                So whether the field is designated as a primary key or not it still acts as though it is trying to do a select on the table using the value(68) I have just assigned to the clientId field then after failing to find the record JBoss is throwing an error instead of creating a new record. Am I miss reading the error messages or is this really what is happening? If so then doesn't this seem like JBoss is reacting incorrectly? If during the execution of ejbCreate() you check to see whether the record exists and if it doesn't you created it, you don't throw and exception and exit.

                So this begs the question, why doesn't JBoss create the record if it can't find it?

                Gary

                • 5. Re: Still Unabe to Create Entity Bean
                  David Jencks Master

                  I think (but am not 100% sure) after jboss creates the db row it reads it back in case triggers changed it. So your exception is indicating that the inserted row can't be found with the expected pk.

                  I would start over with a bean that you supply the pk for, let jaws create the table for you, make sure it works, and then start modifying things one at a time to get to the exact structure you want.

                  • 6. Re: Still Unabe to Create Entity Bean
                    glm Newbie

                    David;

                    I deleted the Client table from my PayeArchitecture
                    database. I have the create-tabe attribute set to
                    true in jaws.xml for the Client table and after
                    starting jboss I find this in the log:

                    [21:26:58,192,ConnectionManagerFactoryLoader] ConnectionManagerLoader.getObjectInstance, name = 'MinervaSharedLocalCMFactory'
                    [21:26:58,213,MinervaDS] Binding object 'org.jboss.pool.connector.jdbc.JDBCDataSource@2a0877' into JNDI at 'java:/MinervaDS'
                    [21:26:58,213,MinervaDS] Bound connection factory for resource adapter 'Minerva JDBC LocalTransaction ResourceAdapter' to JNDI name 'java:/MinervaDS'
                    [21:26:58,213,JmsXA] Evaluating notification type='org.jboss.resource.deployment.deploy', message='Minerva JDBC LocalTransaction ResourceAdapter'
                    [21:26:58,223,AutoDeployer] Auto deploy of file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/deploy/Paye_Payroll.jar
                    [21:26:58,223,J2eeDeployer] Deploy J2EE application: file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/deploy/Paye_Payroll.jar
                    [21:26:58,243,J2eeDeployer] Create application Paye_Payroll.jar
                    [21:26:58,253,J2eeDeployer] install EJB module Paye_Payroll.jar
                    [21:26:58,293,ContainerFactory] Deploying:file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/Paye_Payroll.jar
                    [21:26:58,403,ContainerFactory] Verifying file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/Paye_Payroll.jar/ejb1003.jar
                    [21:26:58,443,ContainerFactory] Client: Verified.
                    [21:26:58,473,ContainerFactory] Employee: Verified.
                    [21:26:58,483,ContainerFactory] Deploying Client
                    [21:26:58,513,JRMPContainerInvoker] Container Invoker RMI Port='4444'
                    [21:26:58,513,JRMPContainerInvoker] Container Invoker Client SocketFactory='Default'
                    [21:26:58,523,JRMPContainerInvoker] Container Invoker Server SocketFactory='Default'
                    [21:26:58,523,JRMPContainerInvoker] Container Invoker Server SocketAddr='Default'
                    [21:26:58,523,JRMPContainerInvoker] Container Invoker Server sslDomain='Default'
                    [21:26:58,523,JRMPContainerInvoker] Container Invoker Optimize='true'
                    [21:26:58,593,EntityInstancePool] config - MaximumSize=100, strictMaximumSize=false, feederPolicy=null
                    [21:26:58,613,ContainerFactory] Deploying Employee
                    [21:26:58,623,JRMPContainerInvoker] Container Invoker RMI Port='4444'
                    [21:26:58,623,JRMPContainerInvoker] Container Invoker Client SocketFactory='Default'
                    [21:26:58,623,JRMPContainerInvoker] Container Invoker Server SocketFactory='Default'
                    [21:26:58,623,JRMPContainerInvoker] Container Invoker Server SocketAddr='Default'
                    [21:26:58,623,JRMPContainerInvoker] Container Invoker Server sslDomain='Default'
                    [21:26:58,623,JRMPContainerInvoker] Container Invoker Optimize='true'
                    [21:26:58,623,EntityInstancePool] config - MaximumSize=100, strictMaximumSize=false, feederPolicy=null
                    [21:26:58,623,EntityContainer] Begin java:comp/env for EJB: Employee
                    [21:26:58,623,EntityContainer] TCL: java.net.URLClassLoader@15fb38
                    [21:26:58,633,EntityContainer] Binding env-entry: PayeProperties of type: java.lang.String to value:Paye.properties
                    [21:26:58,633,EntityContainer] Binding an EJBReference ClientEJB
                    [21:26:58,633,EntityContainer] Binding ClientEJB to internal JNDI source: Client
                    [21:26:58,633,EntityContainer] End java:comp/env for EJB: Employee
                    [21:26:58,653,JRMPContainerInvoker] JRMP 1.3 CI initialized
                    [21:26:58,663,JAWSPersistenceManager] Initializing JAWS plugin for Employee
                    [21:26:58,743,JAWSPersistenceManager] Loading standardjaws.xml : file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/conf/catalina/standardjaws.xml
                    [21:26:58,823,JAWSPersistenceManager] jar:file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/Paye_Payroll.jar/ejb1003.jar!/META-INF/jaws.xml found. Overriding defaults
                    [21:26:58,883,JAWSPersistenceManager] AutoGenerated finders - Home=interface com.paye.payroll.EmployeeHome -- LocalHome=null
                    [21:26:59,004,JAWSPersistenceManager] Table 'Employee' already exists
                    [21:26:59,014,EntityContainer] Begin java:comp/env for EJB: Client
                    [21:26:59,014,EntityContainer] TCL: java.net.URLClassLoader@71c84
                    [21:26:59,014,EntityContainer] Binding env-entry: PayeProperties of type: java.lang.String to value:Paye.properties
                    [21:26:59,014,EntityContainer] Binding an EJBReference EmployeeEJB
                    [21:26:59,014,EntityContainer] Binding EmployeeEJB to internal JNDI source: Employee
                    [21:26:59,014,EntityContainer] End java:comp/env for EJB: Client
                    [21:26:59,034,JRMPContainerInvoker] JRMP 1.3 CI initialized
                    [21:26:59,034,JAWSPersistenceManager] Initializing JAWS plugin for Client
                    [21:26:59,044,JAWSPersistenceManager] AutoGenerated finders - Home=interface com.paye.payroll.ClientHome -- LocalHome=null
                    [21:26:59,044,JAWSPersistenceManager] Save AutoGenerated findAll public abstract java.util.Collection com.paye.payroll.ClientHome.findAll() throws java.rmi.RemoteException,javax.ejb.FinderException
                    [21:26:59,044,JAWSPersistenceManager] Save AutoGenerated findByName public abstract com.paye.payroll.ClientRemote com.paye.payroll.ClientHome.findByName(java.lang.String) throws java.rmi.RemoteException,javax.ejb.FinderException
                    [21:26:59,054,JAWSPersistenceManager] Finder:name
                    [21:26:59,054,JAWSPersistenceManager] Table 'CLIENT' already exists
                    [21:26:59,204,JRMPContainerInvoker] Bound Employee to payroll/Employee
                    [21:26:59,214,EnterpriseContextCachePolicy$Scheduler] Cache policy scheduler started
                    [21:26:59,254,JRMPContainerInvoker] Bound Client to payroll/Client
                    [21:26:59,264,Employee] Initializing
                    [21:26:59,264,Employee] Initialized
                    [21:26:59,274,Employee] Starting
                    [21:26:59,284,Employee] Started
                    [21:26:59,284,Client] Initializing
                    [21:26:59,294,Client] Initialized
                    [21:26:59,304,Client] Starting
                    [21:26:59,314,Client] Started
                    [21:26:59,314,ContainerFactory] Deployed application: file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/Paye_Payroll.jar
                    [21:26:59,324,J2eeDeployer] J2EE application: file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/deploy/Paye_Payroll.jar is deployed.
                    [21:26:59,324,AutoDeployer] Started

                    =============

                    I find this line very interesting :


                    21:26:59,054,JAWSPersistenceManager] Table 'CLIENT' already exists

                    especially since I have deleted the table.

                    then of course there is the error later in the log:


                    [21:27:07,205,JAWSPersistenceManager] java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert explicit value for identity column in table 'CLIENT' when IDENTITY_INSERT is set to OFF.
                    [21:27:07,215,JAWSPersistenceManager] Could not create entity:
                    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert explicit value for identity column in table 'CLIENT' when IDENTITY_INSERT is set to OFF.
                    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
                    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
                    at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:2533)

                    ============

                    here is the top few lines of my jaws.xml


                    java:/SQLServerPool
                    <type-mapping>MS SQLSERVER2000</type-mapping>

                    <default-entity>
                    <create-table>true</create-table>
                    <tuned-updates>false</tuned-updates>
                    <read-only>false</read-only>
                    <time-out>300</time-out>
                    <select-for-update>false</select-for-update>
                    <remove-table>false</remove-table>
                    true
                    </default-entity>

                    <enterprise-beans>

                    <ejb-name>Client</ejb-name>
                    <table-name>CLIENT</table-name>
                    <remove-table>false</remove-table>
                    <cmp-field>
                    <field-name>clientId</field-name>
                    <column-name>clientid</column-name>
                    <jdbc-type>INTEGER</jdbc-type>
                    <sql-type>int</sql-type>
                    </cmp-field>
                    <cmp-field>
                    <field-name>name</field-name>
                    <column-name>NAME</column-name>
                    <jdbc-type>VARCHAR</jdbc-type>
                    <sql-type>VARCHAR(50)</sql-type>
                    </cmp-field>
                    <cmp-field>
                    <field-name>address</field-name>
                    <column-name>ADDRESS</column-name>
                    <jdbc-type>VARCHAR</jdbc-type>
                    <sql-type>VARCHAR(30)</sql-type>
                    </cmp-field>
                    <cmp-field>
                    <field-name>city</field-name>
                    <column-name>CITY</column-name>
                    <jdbc-type>VARCHAR</jdbc-type>
                    <sql-type>VARCHAR(30)</sql-type>
                    </cmp-field>
                    <cmp-field>
                    <field-name>state</field-name>
                    <column-name>STATE</column-name>
                    <jdbc-type>CHAR</jdbc-type>
                    <sql-type>char(2)</sql-type>
                    </cmp-field>
                    <cmp-field>
                    <field-name>zip</field-name>
                    <column-name>ZIP</column-name>
                    <jdbc-type>CHAR</jdbc-type>
                    <sql-type>char(5)</sql-type>
                    </cmp-field>
                    <cmp-field>
                    <field-name>taxId</field-name>
                    <column-name>TAXID</column-name>
                    <jdbc-type>CHAR</jdbc-type>
                    <sql-type>char(9)</sql-type>
                    </cmp-field>




                    ===============
                    I check the database and the client table is still deleted. It was never created.

                    So David where is JBoss looking for and finding the
                    client table???

                    Gary

                    • 7. Re: Still Unabe to Create Entity Bean
                      glm Newbie

                      David;

                      My mistake!! Even though I deleted the Client table
                      in the database through SQL Server Enterprise Manager,
                      it apparently doesn't take effect until after you
                      close the Enterprise Manager window.

                      So now I delete the table and it is created again
                      by Jaws. Here is the output from starting Jboss and
                      performing the Bean test.

                      [INFO,ContainerFactory] Deploying:file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/Paye_Payroll.jar
                      [INFO,ContainerFactory] Deploying Client
                      [INFO,ContainerFactory] Deploying Employee
                      [INFO,JAWSPersistenceManager] Table 'Employee' already exists
                      [INFO,JAWSPersistenceManager] Created table 'CLIENT' successfully.
                      [INFO,EnterpriseContextCachePolicy$Scheduler] Cache policy scheduler started
                      [INFO,Employee] Initializing
                      [INFO,Employee] Initialized
                      [INFO,Employee] Starting
                      [INFO,Employee] Started
                      [INFO,Client] Initializing
                      [INFO,Client] Initialized
                      [INFO,Client] Starting
                      [INFO,Client] Started
                      [INFO,ContainerFactory] Deployed application: file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/tmp/deploy/Default/Paye_Payroll.jar
                      [INFO,J2eeDeployer] J2EE application: file:/D:/JBoss-2.4.4_Tomcat-4.0.1/jboss/deploy/Paye_Payroll.jar is deployed.
                      [INFO,AutoDeployer] Started
                      [INFO,JMXAdaptorService] Starting
                      [INFO,JMXAdaptorService] Started
                      [INFO,RMIConnectorService] Starting
                      [INFO,RMIConnectorService] Started
                      [INFO,MailService] Starting
                      [INFO,MailService] Mail Service 'Mail' bound to java:/Mail
                      [INFO,MailService] Started
                      [INFO,ServiceControl] Started 49 services
                      [INFO,Default] JBoss-2.4.4 Started in 0m:11s.327
                      [ERROR,Client] TRANSACTION ROLLBACK EXCEPTION:
                      javax.transaction.TransactionRolledbackException: Load failed; nested exception is:
                      java.rmi.NoSuchObjectException: Entity 78 not found; nested exception is:
                      java.rmi.ServerException: Load failed; nested exception is:
                      java.rmi.NoSuchObjectException: Entity 78 not found
                      java.rmi.ServerException: Load failed; nested exception is:
                      java.rmi.NoSuchObjectException: Entity 78 not found
                      java.rmi.NoSuchObjectException: Entity 78 not found
                      at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.handleResult(JDBCLoadEntityCommand.java:172)
                      at org.jboss.ejb.plugins.jaws.jdbc.JDBCQueryCommand.executeStatementAndHandleResult(JDBCQueryCommand.java:59)
                      at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:156)
                      at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:147)
                      at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.loadEntity(JAWSPersistenceManager.java:156)

                      ==========

                      It is still acting the same way.

                      Gary

                      • 8. Re: Still Unabe to Create Entity Bean
                        David Jencks Master

                        Did you try removing the code using the sequence generator or at least adding another ejbCreate that includes the clientID? (and using it in your test code) Why don't we see the debug output from your bean? is it in server.log? How far does it get?

                        • 9. Re: Still Unabe to Create Entity Bean
                          glm Newbie

                          David;

                          Thanks for your help. Your suggestions made me take a fresh look at the problem and think a little more out of the box. The problem was in the test program which was creating two entity beans through the remote interface on the same table. Then removing one and then the other. The second remove was generating the error message. The other problems seem to be involving the JDBC driver. I changed drivers to the JSQLConnect driver and the problems seemed to go away.

                          Thanks again,

                          Gary