1 Reply Latest reply on Sep 12, 2006 5:44 AM by Eric Chow

    Hibernate: failed if the models package in different JAR

    Eric Chow Apprentice

      Hello,

      I create some models in Hibernate (with Annotation and EntityManager).

      If I packed them into one JAR, everything is fine.
      If faield if I packed them into two JARs.

      For example,

      model1.User <<<< mode1.jar

      model2.Phone <<<< model2.jar

      class Phone {
      private String no;

      private User user;
      }





      Both JARs(mode1.jar and model2.jar) will be in the same class loader, but when I run a client, it just throws the following exception:



      [java] javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: model1.User, for columns: [org.hibernate.mapping.Column(user)]
      [java] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
      [java] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
      [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
      [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
      [java] at test.Test.main(Test.java:30)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [java] at java.lang.reflect.Method.invoke(Method.java:585)
      [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:202)
      [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:134)
      [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
      [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
      [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
      [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      [java] at org.apache.tools.ant.Task.perform(Task.java:364)
      [java] at org.apache.tools.ant.Target.execute(Target.java:341)
      [java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
      [java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
      [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
      [java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
      [java] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
      [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
      [java] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
      [java] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
      [java] Caused by: org.hibernate.MappingException: Could not determine type for: model1.User, for columns: [org.hibernate.mapping.Column(user)]
      [java] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
      [java] at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
      [java] at org.hibernate.mapping.Property.isValid(Property.java:185)
      [java] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:395)
      [java] at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
      [java] at org.hibernate.cfg.Configuration.validate(Configuration.java:1021)
      [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1206)
      [java] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
      [java] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
      [java] at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
      [java] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
      [java] ... 24 more