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.
Created attachment 136393 [details] Modified Sample project I have attached a modified version of the DVDStoreAdmin project to illustrate the issue.. To run the project, you will need MySQL default sample sakila database and you will need to enter the appropriate connection password into htbernate.cfg.xml and resolve any library references for the MySQl jdbc connector. Under NB 7.3.1 and earlier, the project should run fine and you should be able to open and run both the original sample DVDStoreAdmin GUI and BrokenFrame. Under NB 7.4 however, BrokenFrame will issue a Form Loaded with Errors warning with the exceptions: java.lang.ClassNotFoundException: sakila.ui.ActorComboBox at org.netbeans.modules.form.project.ProjectClassLoader.findClass(ProjectClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.netbeans.modules.form.project.FormClassLoader.findClass(FormClassLoader.java:83) db
Bumped this up to P2 - for me this would be a show stopper!
hibernate library was updated, it's likely related.
may be caused by loading of dom4j in org.netbeans.modules.form.project.ProjectClassLoader and org.netbeans.modules.hibernate.util.CustomClassLoader
I just wanted to mention that some update(? plug-in maybe?)) caused my JavaFX application to crash during the first accesses of Hibernate in 7.3 and 7.3.1 where previously in those versions the app had been working fine. My point is that, under 7.4 dev (with the upgraded Hibernate) the app now builds and runs fine. Let me know if you think I should work up a bug report for this - it seems moot if it stays fixed in 7.4
(In reply to comment #3) > hibernate library was updated, it's likely related. I have also tested with much later versions of hibernate (I currently use 4.1.8.Final) and see the same problem.
(In reply to comment #5) > I just wanted to mention that some update(? plug-in maybe?)) caused my JavaFX > application to crash during the first accesses of Hibernate in 7.3 and 7.3.1 > where previously in those versions the app had been working fine. My point is > that, under 7.4 dev (with the upgraded Hibernate) the app now builds and runs > fine. Let me know if you think I should work up a bug report for this - it > seems moot if it stays fixed in 7.4 I suspect this is a different problem - the specific issue i have is with the GUI builder failing to load components that depend on a hibernate connection.
(In reply to comment #4) > may be caused by loading of dom4j in > org.netbeans.modules.form.project.ProjectClassLoader > and > org.netbeans.modules.hibernate.util.CustomClassLoader Sergey, can you be more specific; is this something I can test/work around?
As far as I'm responsible for hibernate area, I've done some brief evaluation and it seems forms module do not use hibernate module here and hibernate custom classloader isn't invoked also. In this case it's likely should be addressed on forms side. If it's "two classloaders" issue, it should be somewhere else. Google show some similar problems in deployment of hibernate applications on some servers but hints may not work for forms module. I don't know any workaround so far on hibernate/application side, if project configuration may be updated manually to avoid this exception, I can update hibernate module to include some options by default(for example in hibernate.cfg or in generated hibernateutil etc).
(In reply to comment #9) > "In this case it's likely should be addressed on forms side. " Does this mean you'll be passing the issue on to guibuilder? department? > If it's "two classloaders" issue, it should be somewhere else. Who? I'm just concerned that this issue does not get dropped or kicked into the 'WONTFIX/CANTFIX' bucket.
It's already assined to guibuilder department, I just noted it in netcat thread and evaluate if it's directly dependent(or caused by) to hibernate module. I played a bit and if I use systemclassloader inside of org.netbeans.modules.form.project.ProjectClassLoader, I pass initial exception, but got some another. I hope someone from forms can look into the issue.
Tomasi, can you please evaluate this? Thanks a lot!
additional note: for me, I can't open the BrokenFrame in 7.3.1 also
(In reply to comment #13) > additional note: for me, I can't open the BrokenFrame in 7.3.1 also Can you run DVDStoreAdmin? If not then check hibernate.CFB.XML and database connection. BrokenFrame will only open without error in 7.3.1 if the hibernate database connection is correctly configured and the database is available.
Are you sure this worked before? Same as mentioned by Sergey I can't open the BrokenForm in 7.3(.1) either. I'm getting: java.lang.ExceptionInInitializerError at sakila.util.HibernateUtil.<clinit>(HibernateUtil.java:30) at sakila.ui.ActorComboBox.<clinit>(ActorComboBox.java:26) at java.lang.Class.forName0(Native Method) ... caused by a ClassCastException logged as: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory at org.dom4j.io.SAXReader.read(SAXReader.java:484) ... Note this is not related to whether I have the right database or not, here it fails to read the hibernate.cfg.xml file. I'm getting this same exception from NB 7.3 as well as from current dev 7.4. The (part of) ClassNotFoundException originally attached here looks more like if the sakila.ui.ActorComboBox was not compiled. The real problem is that the sakila.ui.ActorComboBox actually initializes whole Hibernate and tries to read from the database. This is fine when the app runs standalone (though not sure if reading database from class static block is generally a good idea), but in design time this code gets executed in the GUI builder, i.e. inside the NetBeans IDE when it tries to load and instantiate the component class. I'm afraid Hibernate is not designed to work this way. It relies on thread context class loader which should load both the hibernate classes and also the config files (hibernate.cfg.xml). It would be possible to make the classes be loaded by the NetBeans context class loader, which would eliminate the mentioned ClassCastException, but this classloader can't find the hibernate.cfg.xml, which is part of the user project (note there can be multiple user projects). We can't give hibernate the right context class loader it needs inside NetBeans - we might try to fiddle with that but it would be fragile and unreliable from principle. From my point of view Hibernate is simply not designed to run in custom components individually instantiated inside a GUI builder tool. I'd suggest to surround the code in ActorComboBox that initializes the Hibernate with if (!Beans.isDesignTime()) { ... }, so this code is not executed inside GUI builder, but otherwise the component should be usable. Would this be sufficient for you? (Note if on JDK 7 newer than u21 you'll probably need to wait for fix of bug 234032 to propagate so the Beans.isDesignTime() check actually works.)
Integrated into 'main-silver', will be available in build *201308090746* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/2e20c8a4ea34 User: Tomas Pavek <tpavek@netbeans.org> Log: allow to exclude packages/classes in class loading specifications (found useful when playing with #231916)
(In reply to comment #15) > Are you sure this worked before? Same as mentioned by Sergey I can't open the > BrokenForm in 7.3(.1) either. I'm getting: > > java.lang.ExceptionInInitializerError > at sakila.util.HibernateUtil.<clinit>(HibernateUtil.java:30) > at sakila.ui.ActorComboBox.<clinit>(ActorComboBox.java:26) > at java.lang.Class.forName0(Native Method) > ... > > caused by a ClassCastException logged as: > org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory > at org.dom4j.io.SAXReader.read(SAXReader.java:484) > ... > > Note this is not related to whether I have the right database or not, here it > fails to read the hibernate.cfg.xml file. > > I'm getting this same exception from NB 7.3 as well as from current dev 7.4. > > The (part of) ClassNotFoundException originally attached here looks more like > if the sakila.ui.ActorComboBox was not compiled. > > The real problem is that the sakila.ui.ActorComboBox actually initializes whole > Hibernate and tries to read from the database. This is fine when the app runs > standalone (though not sure if reading database from class static block is > generally a good idea), but in design time this code gets executed in the GUI > builder, i.e. inside the NetBeans IDE when it tries to load and instantiate the > component class. I'm afraid Hibernate is not designed to work this way. It > relies on thread context class loader which should load both the hibernate > classes and also the config files (hibernate.cfg.xml). It would be possible to > make the classes be loaded by the NetBeans context class loader, which would > eliminate the mentioned ClassCastException, but this classloader can't find the > hibernate.cfg.xml, which is part of the user project (note there can be > multiple user projects). We can't give hibernate the right context class loader > it needs inside NetBeans - we might try to fiddle with that but it would be > fragile and unreliable from principle. > > From my point of view Hibernate is simply not designed to run in custom > components individually instantiated inside a GUI builder tool. I'd suggest to > surround the code in ActorComboBox that initializes the Hibernate with if > (!Beans.isDesignTime()) { ... }, so this code is not executed inside GUI > builder, but otherwise the component should be usable. Would this be sufficient > for you? > > (Note if on JDK 7 newer than u21 you'll probably need to wait for fix of bug > 234032 to propagate so the Beans.isDesignTime() check actually works.) I agree with your comments about hibernate not being designed to run like this - and I have since refactored a number of classes to eliminate the problem.