2 Replies Latest reply on Feb 3, 2006 9:54 AM by Bill Burke

    primary key class does not work with RC5

    Quande Ren Newbie

      Hi, there,

      when I deploy ejb with single field as PK, it get through. but if I have a combined PK, then the deployment failed. this failure happens both on RC4 and RC5.

      The problem will show up when you use a class as primary key.

      here is my PK class:

      package org.jboss.tutorial.entity.bean;
      
      public class LocaleMessagePK
       implements java.io.Serializable
      {
      
       public java.lang.Integer tableType;
       public java.lang.Integer referenceId;
       public java.lang.Integer catergory;
       public java.lang.String theLanguage;
      
       public LocaleMessagePK()
       {
       }
      
       public java.lang.Integer getTableType()
       {
       return tableType;
       }
       public java.lang.Integer getReferenceId()
       {
       return referenceId;
       }
       public java.lang.Integer getCatergory()
       {
       return catergory;
       }
       public java.lang.String getTheLanguage()
       {
       return theLanguage;
       }
      
       public void setTableType(java.lang.Integer tableType)
       {
       this.tableType = tableType;
       }
       public void setReferenceId(java.lang.Integer referenceId)
       {
       this.referenceId = referenceId;
       }
       public void setCatergory(java.lang.Integer catergory)
       {
       this.catergory = catergory;
       }
       public void setTheLanguage(java.lang.String language)
       {
       this.theLanguage = language;
       }
      
      
       public boolean equals(Object obj)
       {
       if( !(obj instanceof LocaleMessagePK) )
       return false;
      
       LocaleMessagePK pk = (LocaleMessagePK)obj;
       boolean eq = true;
      
       if( obj == null )
       {
       eq = false;
       }
       else
       {
       if( this.tableType != null )
       {
       eq = eq && this.tableType.equals( pk.getTableType() );
       }
       else // this.tableType == null
       {
       eq = eq && ( pk.getTableType() == null );
       }
       if( this.referenceId != null )
       {
       eq = eq && this.referenceId.equals( pk.getReferenceId() );
       }
       else // this.referenceId == null
       {
       eq = eq && ( pk.getReferenceId() == null );
       }
       if( this.catergory != null )
       {
       eq = eq && this.catergory.equals( pk.getCatergory() );
       }
       else // this.catergory == null
       {
       eq = eq && ( pk.getCatergory() == null );
       }
       if( this.theLanguage != null )
       {
       eq = eq && this.theLanguage.equals( pk.getTheLanguage() );
       }
       else // this.language == null
       {
       eq = eq && ( pk.getTheLanguage() == null );
       }
       }
      
       return eq;
       }
      
       public String toString()
       {
       StringBuffer toStringValue = new StringBuffer("[.");
       toStringValue.append(this.tableType).append('.');
       toStringValue.append(this.referenceId).append('.');
       toStringValue.append(this.catergory).append('.');
       toStringValue.append(this.theLanguage).append('.');
       toStringValue.append(']');
       return toStringValue.toString();
       }
      
      }
      


      Here is the Bean:

      package org.jboss.tutorial.entity.bean;
      
      import java.util.Collection;
      import javax.persistence.Entity;
      import javax.persistence.IdClass;
      import javax.persistence.Table;
      import javax.persistence.Transient;
      
      @IdClass(LocaleMessagePK.class)
      @Entity
      @Table(name = "LocaleMessage")
      public class LocaleMessage
       implements java.io.Serializable{
      
       private Integer tableType;
       private Integer referenceId;
       private Integer catergory;
       private String theLanguage;
       private String message;
      
       public LocaleMessage() {
       }
      
       @Transient
       public LocaleMessagePK getPK(){
       return new LocaleMessagePK(tableType, referenceId,catergory,theLanguage);
       }
       public Integer getTableType() {
       return this.tableType;
       }
      
       public void setTableType(Integer tableType) {
       this.tableType = tableType;
       }
      
       public Integer getReferenceId() {
       return this.referenceId;
       }
      
       public void setReferenceId(Integer referenceId) {
       this.referenceId = referenceId;
       }
      
       public Integer getCatergory() {
       return this.catergory;
       }
      
       public void setCatergory(Integer catergory) {
       this.catergory = catergory;
       }
      
       public String getTheLanguage() {
       return this.theLanguage;
       }
      
       public void setTheLanguage(String aTheLanguage) {
       this.theLanguage = aTheLanguage;
       }
      
      
       public String getMessage() {
       return this.message;
       }
      
       public void setMessage(String message) {
       this.message = message;
       }
      
      }
      


      before I put the code into C:\JavaApp\jboss-EJB-3.0_RC5-PFD\docs\tutorial\entity\src\org\jboss\tutorial\entity\bean, the tutorial bean can be deployed without any problem, but if I add my two classes into this directory, then error happens:

      Here is all the console information:

      23:22:32,843 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=ShoppingCartBean, class=org.jboss.tutorial.entity.bean.Sh
      oppingCartBean, type=STATEFUL
      23:22:32,859 FATAL [PersistenceXmlLoader] tempdb JTA
      23:22:32,859 INFO [Ejb3Deployment] EJB3 deployment time took: 31
      23:22:32,859 INFO [JmxKernelAbstraction] installing MBean: persistence.units:jar=tutorial.jar.jar,unitName=tempdb with
      dependencies:
      23:22:32,859 INFO [JmxKernelAbstraction] jboss.jca:name=DefaultDS,service=ManagedConnectionFactory
      23:22:32,859 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jboss.tutorial.entity.bean.LineItem
      23:22:32,859 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jboss.tutorial.entity.bean.LocaleMessage
      23:22:32,875 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jboss.tutorial.entity.bean.Order
      23:22:32,875 INFO [AnnotationBinder] Binding entity from annotated class: org.jboss.tutorial.entity.bean.LineItem
      23:22:32,875 INFO [EntityBinder] Bind entity org.jboss.tutorial.entity.bean.LineItem on table LineItem
      23:22:32,875 INFO [AnnotationBinder] Binding entity from annotated class: org.jboss.tutorial.entity.bean.LocaleMessage
      23:22:32,875 INFO [EntityBinder] Bind entity org.jboss.tutorial.entity.bean.LocaleMessage on table LocaleMessage
      23:22:32,890 WARN [ServiceController] Problem starting service persistence.units:jar=tutorial.jar.jar,unitName=tempdb
      java.lang.reflect.InvocationTargetException
       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 org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:97)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:274)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:230)
       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 org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:943)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:428)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy93.start(Unknown Source)
       at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java:76)
       at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:599)
       at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:452)
       at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:139)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:274)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:230)
       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 org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:943)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:428)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy27.start(Unknown Source)
       at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:365)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:989)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:790)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)
       at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy9.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:319)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:507)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:19
      2)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:203)
      
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:182)
      Caused by: org.hibernate.AnnotationException: No identifier specified for entity: org.jboss.tutorial.entity.bean.LocaleM
      essage
       at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:550)
       at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:276)
       at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:210)
       at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:997)
       at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:722)
       at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:161)
       at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:567)
       at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:245)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:108)
       at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:260)
       ... 79 more
      23:22:32,890 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,jar=tutorial.jar,name=ShoppingCartBe
      an with dependencies:
      23:22:32,890 INFO [JmxKernelAbstraction] persistence.units:jar=tutorial.jar.jar,unitName=tempdb
      23:22:32,890 INFO [EJB3Deployer] Deployed: file:/C:/JavaApp/jboss-4.0.3SP1/server/all/deploy/tutorial.jar
      23:22:32,890 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
      
      --- MBeans waiting for other MBeans ---
      ObjectName: persistence.units:jar=tutorial.jar.jar,unitName=tempdb
       State: FAILED
       Reason: java.lang.reflect.InvocationTargetException
       I Depend On:
       jboss.jca:service=ManagedConnectionFactory,name=DefaultDS
       Depends On Me:
       jboss.j2ee:service=EJB3,jar=tutorial.jar,name=ShoppingCartBean
      
      ObjectName: jboss.j2ee:service=EJB3,jar=tutorial.jar,name=ShoppingCartBean
       State: NOTYETINSTALLED
       I Depend On:
       persistence.units:jar=tutorial.jar.jar,unitName=tempdb
      
      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: persistence.units:jar=tutorial.jar.jar,unitName=tempdb
       State: FAILED
       Reason: java.lang.reflect.InvocationTargetException
       I Depend On:
       jboss.jca:service=ManagedConnectionFactory,name=DefaultDS
       Depends On Me:
       jboss.j2ee:service=EJB3,jar=tutorial.jar,name=ShoppingCartBean