4 Replies Latest reply on Jul 9, 2004 5:22 AM by Alexey Loubyansky

    Procedure for Database Structure Changes with CMP 2.0?

    Hugh Allen Newbie

      I have an EJB/CMP 2.0 application that has been running fine for weeks. Environment is JBoss 3.2.2 and MySQL 4.0.16.

      Now, I simply want to add some new fields to one of the database tables. Despite repeated attempts trying multiple variations, nothing has worked successfully. I can't change the database structure without getting strange JBoss errors.

      My conclusion is that I am missing a procedural step in the update process. There is nothing conceptually difficult with adding a few new DB fields to one table:

      I updated the code for the entity beans with the new getters and setters, updated my stateless session beans with all the new fields, modified the JSPs as required, updated the deployment descriptors, and built a new EAR.

      Then, I shut down JBoss, dropped the old database, created the new database, and rebooted the whole server. When the server came back up, I deployed the new EAR file. It deployed with no errors in the log, as usual. The part of the application that does not reference the table with structure changes works fine.

      NOTE: JBoss is NOT creating the table - I am doing this through a MySQL script and using default of:
      <create-table>false</create-table>

      However, now I am getting some very strange errors:

      Entity not found: primaryKey=ABC$9991112222; CausedByException is: Entity not found: primaryKey=ABC$9991112222; nested exception is: javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=ABC$9991112222; - nested throwable: (javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=ABC$9991112222)

      The bean being updated has a compound primary key and I have inserted a "$" in the toString() method of the primary key class to separate the two key fields for visibility. That's not the problem it worked fine previously.

      ***The message above clearly shows the problem because ABC is the correct first field of the PK, but 9991112222 is from the phone number field, which is NOT part of the PK. I made no changes to the PK class, since the DB changes did NOT involved the key fields.

      It appears that JBoss is getting confused by the database structure change. JBoss appears to have a mangled view of the database structure.

      Is there something I need to do to make JBoss recognize the new database structure? Are there somehow OLD JBoss entity instances being saved across shutdowns? I have had the same problem using both commit option A and B. In any case, I don't think any entity beans should be cached or saved across shutdowns.

      Stack Trace follows:

      2004-07-07 10:05:54,120 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException in method: public abstract java.util.ArrayList com.xyz.abc.ejb.cableorder.CableOrderController.getAllLocations() throws java.rmi.RemoteException,com.xyz.abc.ejb.exception.C1Exception, causedBy:
      javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=ABC$9999991112222
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:158)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:490)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:375)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy59.getLocation_customer_id(Unknown Source)
      at com.xyz.abc.ejb.cableorder.CableOrderControllerBean.copyLocationsToDetails(Unknown Source)
      at com.xyz.abc.ejb.cableorder.CableOrderControllerBean.getAllLocations(Unknown Source)
      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:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
      at $Proxy67.getAllLocations(Unknown Source)
      at org.apache.jsp.regions_jsp._jspService(regions_jsp.java:121)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
      at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:220)
      at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:125)
      at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:822)
      at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:398)
      at com.xyz.abc.web.taglib.InsertTag.doEndTag(Unknown Source)
      at org.apache.jsp.template_jsp._jspx_meth_tt_insert_1(template_jsp.java:3300)
      at org.apache.jsp.template_jsp._jspService(template_jsp.java:461)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
      at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:220)
      at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:133)
      at com.xyz.abc.web.Dispatcher.doGet(Unknown Source)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1803)
      at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:523)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1753)
      at org.mortbay.http.HttpServer.service(HttpServer.java:879)
      at org.jboss.jetty.Jetty.service(Jetty.java:456)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
      at org.mortbay.http.ajp.AJP13Connection.handleNext(AJP13Connection.java:273)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
      at org.mortbay.http.ajp.AJP13Listener.handleConnection(AJP13Listener.java:199)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
      at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:494)

      Thanks for any help.