5 Replies Latest reply on Apr 8, 2006 3:20 PM by holeinone

    Error deploying entity 3.0

    n00noors

      Hello,
      I have an error when I'm deploying an Entity bean
      It's a simple entity wtih one classe : ClientBean who must represent one table : Client on my database mysql

      here my entity bean code:

      @Table(name="Client")
      public @Entity class ClientBean implements Serializable{
       private int id;
       private String nom;
       private String prenom;
       private String codePostal;
       private String adresse;
       private String fixe;
       private String portable;
      
       public ClientBean() {
      
       }
       public String getAdresse() {
       return adresse;
       }
      
       public void setAdresse(String adresse) {
       this.adresse = adresse;
       }
       @Id(generate=GeneratorType.AUTO)
       public int getInt() {
       return id;
       }
       public void setId(int id) {
       this.id = id;
       }
       public String getCodePostal() {
       return codePostal;
       }
       public void setCodePostal(String codePostal) {
       this.codePostal = codePostal;
       }
       public String getFixe() {
       return fixe;
       }
       public void setFixe(String fixe) {
       this.fixe = fixe;
       }
       public String getNom() {
       return nom;
       }
       public void setNom(String nom) {
       this.nom = nom;
       }
       public String getPortable() {
       return portable;
       }
       public void setPortable(String portable) {
       this.portable = portable;
       }
       public String getPrenom() {
       return prenom;
       }
       public void setPrenom(String prenom) {
       this.prenom = prenom;
       }
      }


      here my persistence.xml :
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence>
       <persistence-unit name="mysql_unit">
       <jta-data-source>java:/mysql_clients</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       </properties>
       <class>cmp.ClientBean</class>
       </persistence-unit>
      </persistence>


      My Datasource is correctly deploy on jndi : java:/mysql_clients: it's a Mysql database named crm.

      here my datasource descriptor:
      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>mysql_clients</jndi-name>
       <connection-url>jdbc:mysql://localhost/crm</connection-url>
       <driver-class>org.gjt.mm.mysql.Driver</driver-class>
       <user-name></user-name>
       <password></password>
       </local-tx-datasource>
      </datasources>
      

      When I'm deploying my entity bean, following error appear on jboss console:
      11:36:14,234 WARN [ServiceController] Problem starting service persistence.unit
      s:unitName=mysql_unit
      java.lang.reflect.InvocationTargetException
       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:585)
       at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWra
      pper.java:97)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
      upport.java:274)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:230)
       at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.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(ServiceControl
      ler.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(DelegatingMethodAcces
      sorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.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 $Proxy88.start(Unknown Source)
       at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java
      :76)
       at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.ja
      va: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(ServiceMBeanS
      upport.java:274)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:230)
       at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.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(ServiceControl
      ler.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(DelegatingMethodAcces
      sorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.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(DelegatingMethodAcces
      sorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
      or.java:118)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
      BeanOperationInterceptor.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(URLDeploymen
      tScanner.java:319)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
      canner.java:507)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      doScan(AbstractDeploymentScanner.java:192)
       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.PropertyNotFoundException: Could not find a setter for
      property int in class cmp.ClientBean
       at org.hibernate.property.BasicPropertyAccessor.createSetter(BasicProper
      tyAccessor.java:216)
       at org.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyA
      ccessor.java:209)
       at org.hibernate.mapping.Property.getSetter(Property.java:256)
       at org.hibernate.tuple.PojoEntityTuplizer.buildPropertySetter(PojoEntity
      Tuplizer.java:259)
       at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTupli
      zer.java:103)
       at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java
      :55)
       at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
       at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
       at org.hibernate.persister.entity.AbstractEntityPersister.<init>(Abstrac
      tEntityPersister.java:412)
       at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(Sing
      leTableEntityPersister.java:108)
       at org.hibernate.persister.PersisterFactory.createClassPersister(Persist
      erFactory.java:55)
       at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
      215)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
      a:1176)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
      figuration.java:414)
       at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Co
      nfiguration.java:575)
       at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFacto
      ry(Ejb3Configuration.java:245)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFa
      ctory(HibernatePersistence.java:108)
       at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnit
      Deployment.java:260)
       ... 77 more
      11:36:14,234 INFO [EJB3Deployer] Deployed: file:/D:/jboss-4.0.3SP1/server/all/d
      eploy/Entity3_0.jar
      11:36:14,234 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
      
      --- MBeans waiting for other MBeans ---
      ObjectName: persistence.units:unitName=mysql_unit
       State: FAILED
       Reason: java.lang.reflect.InvocationTargetException
       I Depend On:
       jboss.jca:service=ManagedConnectionFactory,name=mysql_clients
      
      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: persistence.units:unitName=mysql_unit
       State: FAILED
       Reason: java.lang.reflect.InvocationTargetException
       I Depend On:
       jboss.jca:service=ManagedConnectionFactory,name=mysql_clients


      I use jboss-4.0.3SP1 version with jboss-EJB-3.0_RC5-PFD.

      thank you in advance for your help

        • 1. found cause of the error
          n00noors

          Hello,
          I found cause of the error
          I resolve precedent cause of java.lang.reflect.InvocationTargetException but when I deploy my entity, another cause appear( which always create an java.lang.reflect.InvocationTargetException) :

          Caused by: org.hibernate.AnnotationException: No identifier specified for entity
           : cmp.Client
           at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:55
           0)


          However I modified my class :
          @IdClass(cmp.Client.class)
          @Table(name="Client",schema="mysql_unit")
          public @Entity class Client implements Serializable{


          but it doesn't solve the problem

          • 2. Re: Error deploying entity 3.0
            epbernard

            Check the Hibernate annotations refernece documentation

            @Id is required on fields matching the @IdClass

            • 3. Re: Error deploying entity 3.0
              n00noors

              thanks for your answer : indeed @Id must be specify
              - before the attribute id
              - or before getId() and setId()

              it's work perfectly now!

              • 4. Re: Error deploying entity 3.0
                epbernard

                setters are ignored when reading annotations

                • 5. Re: Error deploying entity 3.0
                  holeinone

                  This page Just saved me a lot of puzzling, Thank you Emmanuel Bernard for answering and thank you n00noors for the question!