-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: ClassNotFoundException when class with no package used
PostPosted: Thu Aug 24, 2006 8:11 am 
Newbie

Joined: Wed Mar 29, 2006 3:47 pm
Posts: 17
Hibernate version: Hibernate EntityManager 3.2.0.CR1
Mapping documents:
Code:
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0">
  <embeddable class="Incident$IncidentId" access="FIELD" metadata-complete="true">
  </embeddable>
</entity-mappings>

Full stack trace of any exception that occurs:
Caused by: org.hibernate.AnnotationException: Unable to load class defined in XML: .Incident$IncidentId
at org.hibernate.cfg.AnnotationConfiguration.add(AnnotationConfiguration.java:493)
at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:573)
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:818)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:653)
at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:148)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:202)
... 4 more
Caused by: java.lang.ClassNotFoundException: /Incident$IncidentId
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:112) at org.hibernate.reflection.java.JavaXFactory.classForName(JavaXFactory.java:101)
at org.hibernate.cfg.AnnotationConfiguration.add(AnnotationConfiguration.java:490)
... 9 more

I think this is caused by the following code in XMLContext.java http://fisheye.labs.jboss.com/browse/~raw,r=10187/Hibernate/trunk/HibernateExt/metadata/src/java/org/hibernate/reflection/java/xml/XMLContext.java
Code:
   public static String buildSafeClassName(String className, String defaultPackageName) {
      if ( className.indexOf( '.' ) < 0 && defaultPackageName != null ) {
         className = StringHelper.qualify( defaultPackageName, className );
      }
      return className;
   }

It checks against null, where as in the following code, packagename defaults to "".
Code:
      //entity mapping default
      Default entityMappingDefault = new Default();
      Element unitElement = root.element( "package" );
      String packageName = unitElement != null ? unitElement.getTextTrim() : "";


Thanks,
Sahoo


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 7:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
http://opensource.atlassian.com/projects/hibernate/browse/ANN-421

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.