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.  [ 6 posts ] 
Author Message
 Post subject: Eclipse RCP problems using buddyloading
PostPosted: Tue Jan 03, 2006 5:43 pm 
Newbie

Joined: Tue Jan 03, 2006 5:09 pm
Posts: 4
Hibernate version: 3.1.0 (hibernate tools 3.1.0 beta2)

Full stack trace of any exception that occurs:
Code:
java.lang.ExceptionInInitializerError
   at metaInformationClient.Application.run(Application.java:20)
   at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
   at org.eclipse.core.launcher.Main.run(Main.java:973)
   at org.eclipse.core.launcher.Main.main(Main.java:948)
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
   at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
   at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1265)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1287)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1274)
   at conf.HibernateUtil.<clinit>(HibernateUtil.java:11)
   ... 12 more


It's not that I didn't look trough the available resources on this forum or on the wiki. My main guidelines have been: http://forum.hibernate.org/viewtopic.php?t=944666 and
http://www.hibernate.org/311.html

I first modified the MANIFEST.MF in C:\Program Files (x86)\eclipse\plugins\org.hibernate.eclipse_3.1.0.beta2\META-INF adding "Eclipse-BuddyPolicy: registered".

To my own MANIFEST.MF file I have added:
Code:
Eclipse-RegisterBuddy: org.hibernate.eclipse


But when trying to run I still get the above exception.
The hibernate.cfg.xml has been in /, /src, /bin, etc, always keep getting the same exception while it should just be in my /src dir according to the wikipage.

So far I've read topics all using a single plugin, does this also work for RCP applications? If so, what am I doing wrong here? Do I need to add the jar's to my own project?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 6:03 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
buddy loading work great with rcp application

you have to set

Eclipse-BuddyPolicy: registered

in manifest file - plugin with hibernate libraries (org.hibernate.eclipse)

and your

Eclipse-RegisterBuddy: org.hibernate.eclipse

in plugin where hibernate.cfg.xml (and other plugin with configuration or POJO classes)

regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 12:01 pm 
Newbie

Joined: Tue Jan 03, 2006 5:09 pm
Posts: 4
Thank you for the effort but apparently you did not read my opening post :)

You see, I added the buddy loading stuff, correctly! (no typo's, not messing up the policy/register options. That part is ok.

Yet I still get the top stacktrace.

I have a feeling it might be because of my HibernateUtil class?

I've tried loading it with
Class.forName("metaInformationClient.HibernateUtil");
combined with the HibernateUtil found here

Code:
   // Create the initial SessionFactory from the default configuration files
   static {
      ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
      try {
         Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
         
         configuration = new Configuration();
         sessionFactory = configuration.configure().buildSessionFactory();
         // We could also let Hibernate bind it to JNDI:
         // configuration.configure().buildSessionFactory()
      } catch (Throwable ex) {
         // We have to catch Throwable, otherwise we will miss
         // NoClassDefFoundError and other subclasses of Error
         log.error("Building SessionFactory failed.", ex);
         throw new ExceptionInInitializerError(ex);
      } finally {
         Thread.currentThread().setContextClassLoader(originalClassLoader);
      }
   }


The this was off course a problem so I changed it to:
Code:
   static {

      Configuration configuration = new Configuration();
      sessionFactory = configuration.configure().buildSessionFactory();

   }

and tried loading it by: Class.forname("metaInformationClient.HibernateUtil", true, this.getClass().getClassLoader()); for using it with the same classloader as my Application.java.

I'm doing the calls from my public Object run() routine because my application does not have a start routine, only a run.

So how can I now initialize hibernate in a way that it uses (finds) my hibernate.cfg.xml?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 1:45 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Bl4ckh4wk,
do you have dependenices to org.hibernate.eclipse in your plugins ?

send us manifest.mf for both plugins

I have rcp application with hibernate core (hibernate libraries like org.hibernate.eclipse from hibernate tools;i don't use plugin from tools because i want control version hibernate) in one plugin and HibernateUtil in another (mapping plugin).It work perfect - i use spring , too and spring and buddy loader work

do you use eclipse >=3.1 ?

regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 2:27 pm 
Newbie

Joined: Tue Jan 03, 2006 5:09 pm
Posts: 4
Hi,

Yes, I'm using Eclipse 3.1.1, I should have pointed that out, sorry :)

Here is the manifest.mf file from my application:
Code:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MetaInformationClient Plug-in
Bundle-SymbolicName: MetaInformationClient; singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: metaInformationClient.MetaInformationClientPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.hibernate.eclipse
Eclipse-AutoStart: true
Eclipse-RegisterBuddy: org.hibernate.eclipse


and here is the manifest.mf file from org.hibernate.eclipse wich I modified:
Code:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)
Bundle-ManifestVersion: 2
Bundle-Name: Hibernate Core Plugin
Bundle-SymbolicName: org.hibernate.eclipse
Bundle-Version: 3.1.0.beta2
Bundle-ClassPath: org.hibernate.eclipse.jar,lib/tools/hibernateconsole
.jar,lib/hibernate/asm.jar,lib/hibernate/asm-attrs.jar,lib/hibernate/
c3p0-0.9.0.jar,lib/hibernate/commons-collections-2.1.1.jar,lib/hibern
ate/commons-logging-1.0.4.jar,lib/hibernate/concurrent-1.3.2.jar,lib/
hibernate/connector.jar,lib/hibernate/dom4j-1.6.1.jar,lib/hibernate/e
hcache-1.1.jar,lib/hibernate/hibernate3.jar,lib/hibernate/jboss-cache
.jar,lib/hibernate/jboss-common.jar,lib/hibernate/jboss-jmx.jar,lib/h
ibernate/jboss-system.jar,lib/hibernate/jdbc2_0-stdext.jar,lib/hibern
ate/jgroups-2.2.7.jar,lib/hibernate/jta.jar,lib/hibernate/jaas.jar,li
b/hibernate/log4j-1.2.11.jar,lib/hibernate/oscache-2.1.jar,lib/hibern
ate/proxool-0.8.3.jar,lib/hibernate/swarmcache-1.0rc2.jar,lib/tools/h
ibernate-tools.jar,lib/tools/jtidy-r8-21122004.jar,lib/tools/l2fprod-
common.jar,lib/tools/velocity-1.4.jar,lib/tools/velocity-tools-generi
c-1.1.jar,lib/tools/bsh-2.0b1.jar,lib/bsh-core-2.0b4.jar,lib/annotati
ons/ejb3-persistence.jar,lib/annotations/hibernate-annotations.jar,li
b/annotations/lucene-1.4.3.jar,lib/hibernate/antlr-2.7.6rc1.jar,lib/h
ibernate/cglib-2.1.3.jar
Bundle-Activator: org.hibernate.eclipse.HibernatePlugin
Bundle-Vendor: Hibernate Team
Bundle-Localization: plugin
Export-Package: EDU.oswego.cs.dl.util.concurrent,antlr,antlr.actions.c
pp,antlr.actions.csharp,antlr.actions.java,antlr.actions.python,antlr
.build,antlr.collections,antlr.collections.impl,antlr.debug,antlr.deb
...!lot's of packages go here!... org.w3c.tidy.ant
Require-Bundle: org.eclipse.core.runtime
Eclipse-AutoStart: true
Eclipse-BuddyPolicy: registered


I have zipped up the entire code, so you can grab that from here if you want to take a look at HibernateUtil.

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 3:02 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
i can't try this plugin because i haven't mysql and mysql jdbc driver, but i think that your
problem is call HibernateUtil before creating workspace and buddy policy doesn't exists yet

remove this construction
Class.forName("metaInformationClient.HibernateUtil", true, this.getClass().getClassLoader());
from Application.java
and try build/open session with static methods in
MetaInformationClientPlugin.java

i do it like this :
Code:
public static Session getSession() {
      if (sessionFactory == null)
         buildHibernate();
      Session s = (Session) threadSession.get();
      if (s == null) {
         s = getSessionFactory().openSession();
         threadSession.set(s);
      }
      return s;
   }

this si code in plugin class - buildHibernate is similar static from HibernateUtil, but i build hibernate lazy (when i need session)
complete source for my MappingPlugin is
http://www.snpe.co.yu/MappingPlugin.java


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.