This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 159004 - Hibernate plugin fail on "New Hibernate Mapping files and POJOs from Database"
Summary: Hibernate plugin fail on "New Hibernate Mapping files and POJOs from Database"
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Hibernate (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: Sergey Petrov
URL:
Keywords:
: 168147 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-23 17:52 UTC by micrenda
Modified: 2016-07-07 08:53 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description micrenda 2009-02-23 17:52:06 UTC
Hello

Using Hibernate Support plugin (token from plugin center), when importing some tables I get this:

java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.JDBCMetaDataConfiguration
	at org.netbeans.modules.hibernate.wizards.HibernateRevengWizard.generateClasses(HibernateRevengWizard.java:315)
	at org.netbeans.modules.hibernate.wizards.HibernateRevengWizard.instantiate(HibernateRevengWizard.java:459)
	at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1016)
	at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:588)
	at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:409)
	at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:253)
	at org.openide.loaders.TemplateWizardIteratorWrapper.instantiate(TemplateWizardIteratorWrapper.java:165)
	at org.openide.WizardDescriptor.callInstantiateOpen(Unknown Source)
	at org.openide.WizardDescriptor.callInstantiate(Unknown Source)
	at org.openide.WizardDescriptor.access$1700(Unknown Source)
	at org.openide.WizardDescriptor$Listener$2$1.run(Unknown Source)
	at org.openide.util.RequestProcessor$Task.run(Unknown Source)
[catch] at org.openide.util.RequestProcessor$Processor.run(Unknown Source)


It seem to be that the hibernate-tools.jar don't contain the class org.hibernate.cfg.JDBCMetaDataConfiguration (and it
is so).

I think the hibernate-tools.jar but be downgraded to a previous version that has this class.

Best regards
Michele Renda
Comment 1 micrenda 2009-02-23 22:04:41 UTC
I can add that this problem seem to happen when using a firebird database, with jaybird 2.1.6
Comment 2 Petr Cyhelsky 2009-10-07 16:47:24 UTC
*** Issue 168147 has been marked as a duplicate of this issue. ***
Comment 3 Sergey Petrov 2011-01-12 12:45:54 UTC
as I got it it's comparability with new hibernate jars issue. we really need to update our module to support newer one at some point, but unfortunately not this time.
Comment 4 micrenda 2011-01-12 21:33:02 UTC
Thank you :)
Comment 5 mrotteveel 2013-11-02 12:37:53 UTC
After digging into the code of Netbeans and adding extra logging to Jaybird, I found that the problem is that Netbeans loads the driver with a custom classloader that doesn't return resources in /META-INF/services. 

Jaybird (the Firebird JDBC driver) uses plugins for its protocol implementation (eg the Type 4 implementation, Type 2 native, Type 2 embedded). These are listed in a file in /META-INF/services/ (specifically /META-INF/services/org.firebirdsql.gds.impl.GDSFactoryPlugin), and are loaded with a mechanism similar to java.util.ServiceLoader. This also allows third-parties to add protocol implementations. For example as a workaround, or for special needs; I know a company used this mechanism to provide a driver that could translate Oracle syntax to Firebird.

The change were a Netbeans classloader ignores the existence of all files in /META-INF/services was added in:
http://hg.netbeans.org/main-silver?cmd=changeset;node=c8413dd446c2
in response to bug:
https://netbeans.org/bugzilla/show_bug.cgi?id=194915

I have added a workaround in Jaybird, but I think it is a bug in Netbeans that it purposefully refuses to load files that may be required by a Java library.

See also:
http://tracker.firebirdsql.org/browse/JDBC-325
http://stackoverflow.com/a/18920383/466862
http://stackoverflow.com/questions/18921352/using-meta-inf-services-for-internal-plumbing-of-driver
Comment 6 mrotteveel 2013-11-02 12:51:13 UTC
When investigating this, I noticed that when going through the wizard, *two* database connections are made: 
one by org.netbeans.modules.hibernate.util.HibernateUtil that succeeds but isn't used, 
and another by org.netbeans.modules.hibernate.util.CustomJDBCConnectionProvider which fails because of the classloading issue described in my previous comment.
Comment 7 Sergey Petrov 2013-11-03 15:59:14 UTC
I see initial report is from 2009, whn mentioned fix was pushed in 2011, and latest comments may be completly new also, why it's added to this issue?

regarding 2011 fix, may be I need just to catch cnf in case of "services" folder instead of return null without "try"
Comment 8 mrotteveel 2013-11-03 16:02:28 UTC
Sergey, you are right. I had misread this issue. I will create a new issue.
Comment 9 mrotteveel 2013-11-03 16:33:54 UTC
I created issue: https://netbeans.org/bugzilla/show_bug.cgi?id=237922
Comment 10 Martin Balin 2016-07-07 08:53:24 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss