aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate packageesToScan fails, but annotatedClasses works Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate packageesToScan fails, but annotatedClasses works" Watch "Hibernate packageesToScan fails, but annotatedClasses works" New topic
Author

Hibernate packageesToScan fails, but annotatedClasses works

Brian Mulholland
Ranch Hand

Joined: Mar 12, 2009
Posts: 61
We have a new webapp that we are prepping for deployment. We changed how we include our jars, from just manually dumping them into the web-inf/lib to using eclipse's deployment assembly to move them from a common location into the web-inf/lib dynamically, creating one repository for our libs. This tactic works fine with everything but one jar...the one our hibernate entities are in.

The jar is there, we can see it. It's in the classpath, we can instantiate it. But when we run, we get an exception for unknown entity as if the annotations from the target entity were never run. When we replace our "packagesToScan" declaration with a "annotatedClasses" list, it works fine. Yet our packagesToScan looks right. I'd much rather use the flexible packagesToScan than has developers required to do the easy-to-forget step of declaring their classes each time.

Anyone have any idea why this might be?

spring config (the below shows all three at the same time, in reality we comment one in at a time):



Exception:

Brian Mulholland
Ranch Hand

Joined: Mar 12, 2009
Posts: 61
So I recently rediscovered this post and thought I'd post the solution for posterity. When exporting the jars in RAD, the jar wizard has a checkbox called "Add Directory Entries" on the first page of the wizard. Check that. Without it, my packagesToScan reference, which was to a root of the package with the entities in it (since there is more than one package of entities), would not be found. It acted like there were no entitites. Checking this adds stuff to the manifest and causes the classes to be found by the annotation scanner.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9317
    
109

Thank you for posting the solution.

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate packageesToScan fails, but annotatedClasses works
 
Similar Threads
QuerySyntaxException (table is not mapped)
Hibernate/Spring/Jboss Annotations + Entity Mapping problems
Basic Hibernate many-to-many mapping / query not right
org.hibernate.hql.ast.QuerySyntaxException: INFORMATION_SCHEMA.SYSTEM_ALIASES is not mapped.
Running application on web start