-->
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: wrong path for mapped classes in netbeans
PostPosted: Sat May 23, 2009 9:20 am 
Newbie

Joined: Fri May 08, 2009 11:15 am
Posts: 5
Hi there,

i am currently very confused by the netbeans ide. I am developing a java se desktop app with hibernate as a db abstraction layer. Hibernate works great and didn't give me any problems but a week ago i switched development environments from eclipse to netbeans (to use the gui editor).

My problem is a class not mapped exception that is thrown when i run the app in netbeans, by klicking the run button in netbeans. What it comes down to is that the path where hibernate searches any entity classes is wrong:

Code:
14:58:04,306 DEBUG AbstractJarVisitor:116 - Searching mapped entities in jar/par: file:path/netbeans-project/src


where "path/netbeans-project" is the path to my netbeans project. The weird thing is that JUnit test run in netbeans do work because the right path is specified and the jar file that netbeans builds also works when run manually.

After debugging Hibernate to find out how the path is generated i found out that the path can be specified in the persistence.xml

EJB3Configuration.java line 272:
Code:
URL jarURL = JarVisitorFactory.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" );


But i don't know the directive to specify the jar-url and i would like to find a cleaner solution like a switch in netbeans.

Does anybody develop in netbeans?
I would be very thankful for a hint.


Top
 Profile  
 
 Post subject: Re: wrong path for mapped classes in netbeans
PostPosted: Sun May 24, 2009 11:49 am 
Newbie

Joined: Fri May 08, 2009 11:15 am
Posts: 5
Solved the problem. "Class not mapped Exception" accrued when running app in Netbeans

Because: Netbeans was running the project with a faulty build configuration. The persistence.xml from the src folder was returned to the app when hibernate called getResource(persistence.xml). Consequently hibernate assumed that the folder with all the classes with annotations is src. This is not the case because netbeans puts the compiled classes in the build/classes/ folder.

Solution: In the projects properties under "Compiling" uncheck "Compile on Save" because:

Quote:
By default, only the Clean and Build commands use this build script.
Commands such as Run, Debug, and Test only use this build script if
the Compile on Save feature is turned off for the project.
You can turn off the Compile on Save (or Deploy on Save) setting
in the project's Project Properties dialog box.


Found this in the comments of the "build.xml" file in the projects root folder.

hope this helps someone


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.