-->
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.  [ 10 posts ] 
Author Message
 Post subject: Can not create SessionFactory---Help, please!!!!
PostPosted: Mon Dec 26, 2005 5:53 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 12:18 pm
Posts: 21
Location: Birmingham, Alabama
I am very new to Hibernate and trying to work through several examples.

Hibernate version:3.1

Mapping documents:
<hibernate-mapping>
<class name="com.hibernate.test.Honey" table="honey">

<meta attribute="session-method">
HibernateUtil.getSession();
</meta>
<id name="id" column="honeyId" type="java.lang.Integer">
<!-- postgre:
<generate class="sequence">
<param name="sequence">honey_id_seq</param>
</generate>
-->
<generator class="native"/>
</id>
<property name="name" column="honeyName" type="java.lang.String" />
<property name="taste" column="taste" type="java.lang.String" />
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
org.hibernate.MappingException: Resource: com.hibernate.test.honey.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:478)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1443)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1411)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1392)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1368)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1322)
at org.hibernate.console.ConsoleConfiguration.loadConfigurationXML(ConsoleConfiguration.java:208)
at org.hibernate.console.ConsoleConfiguration.access$0(ConsoleConfiguration.java:155)
at org.hibernate.console.ConsoleConfiguration$1.execute(ConsoleConfiguration.java:131)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:112)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:98)
at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:19)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:70)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:192)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)


Name and version of the database you are using:MQSQL

When I change to the Hibernate perspective in Eclipse 3.2, I can see the configuration file for the project. However, when I right click on the configuration file and select "generate Session Factory, I get the above stacktrace. For some reason, the mapping file can not be found. However, the mapping file is in the same directory as the hibernate.cgf.xml file.

What am I doing wrong? Can someone please point me in the right direction?

Thank you in advance for any possible suggestions.


Russ


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 6:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you need to put the build path into the classpath of the console configuration

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 7:15 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 12:18 pm
Posts: 21
Location: Birmingham, Alabama
Max:

Thank you for responding. I apologizenot understanding, but I don't understand the terms you are using. I understand the build path;this is part of project's properties in eclipse. The classpath is part of the buildpath under the windows preferences. What I don't understand is the console configuration. Can you explain more, please?

I apologize for not understanding. I am very next to Hibernate.

Russ


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 4:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you have already created a console configuration - otherwise you would not be able to get the above exception.

Double click the console configuration you are trying to create a session factory for and a dialog should popup where you can add paths to the console configuration classpath.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 8:30 am 
Beginner
Beginner

Joined: Thu Dec 08, 2005 12:18 pm
Posts: 21
Location: Birmingham, Alabama
Thanks Max! I found the console configuration. Thanks for explaining it so I could understand.

What I did was add the mapping file location to the mapping portion within the console. I also added to the classpath the project root and the location of the source files (src).

Now I am getting a NPE when I try to generate a Session Factory.


java.lang.NullPointerException
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationFile(ClassLoaderHelper.java:91)
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationURL(ClassLoaderHelper.java:83)
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationsURLForResources(ClassLoaderHelper.java:117)
at org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences.getCustomClassPathURLS(EclipseConsoleConfigurationPreferences.java:81)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:109)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:98)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:37)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:46)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:544)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:494)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:406)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:896)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3236)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2856)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1774)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1738)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:376)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106)
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:165)
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:338)
at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
)



When I try to expand the configuration tree, I also get a NPE:


java.lang.NullPointerException
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationFile(ClassLoaderHelper.java:91)
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationURL(ClassLoaderHelper.java:83)
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationsURLForResources(ClassLoaderHelper.java:117)
at org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences.getCustomClassPathURLS(EclipseConsoleConfigurationPreferences.java:81)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:109)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:98)
at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:19)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:70)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:192)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)


What am I doing wrong?

Thanks for reading my post........


Russ


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 3:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
either use a newer version of the tools where this bug should not be present anymore or separate your classes and src into different directories.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 30, 2005 8:20 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 12:18 pm
Posts: 21
Location: Birmingham, Alabama
Max:

Sorry I have not responded as I have been away.

I have the src and bin directories established for the project. When I click on create sessionfactory or expand the Hibernate configuration tree for the project, I get the below exceptions:


This happens when you attempt to create a sessionfactory:

!ENTRY org.eclipse.ui 4 4 2005-12-30 17:42:53.265
!MESSAGE Unhandled event loop exception

!ENTRY org.eclipse.ui 4 0 2005-12-30 17:42:53.265
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationFile(ClassLoaderHelper.java:91)
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationURL(ClassLoaderHelper.java:83)
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationsURLForResources(ClassLoaderHelper.java:117)
at org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences.getCustomClassPathURLS(EclipseConsoleConfigurationPreferences.java:81)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:109)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:98)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:37)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:46)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:544)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:494)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:406)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:896)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3236)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2856)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1774)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1738)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:376)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106)
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:165)
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:338)
at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)


This happens when you try to expand the tree


!ENTRY org.hibernate.eclipse.console 4 4 2005-12-30 17:42:57.296
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationFile(ClassLoaderHelper.java:91)
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationURL(ClassLoaderHelper.java:83)
at org.hibernate.eclipse.console.utils.ClassLoaderHelper.getRawLocationsURLForResources(ClassLoaderHelper.java:117)
at org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences.getCustomClassPathURLS(EclipseConsoleConfigurationPreferences.java:81)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:109)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:98)
at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:19)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:70)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:192)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)
!SUBENTRY 1 org.hibernate.eclipse.console 4 150 2005-12-30 17:42:57.296
!MESSAGE <No message>



As far as the current versions are concern, I've download the lastest tool plugin I am using the JBOSS version JBossIDE-1.5RC2-ALL. I am led to believe I have all the latest information and versions.

Can you be more specific on what I could check to validate the configuration?


As always, thanks for your time in reading my post.


Russ


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 31, 2005 4:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i'm quite sure this is fixed in the latest version which is in the nightly builds now and will be released soon.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 31, 2005 2:49 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 12:18 pm
Posts: 21
Location: Birmingham, Alabama
Max:

Thanks for responding.

Can you give me a timeframe on how long it will be before we have another release? I would hate to go through the pain of trying to build the nightly changes when the release is just around the corner.

Russ


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 01, 2006 8:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
within days/weeks.

But remember that if we didn't have helpfull users checking out the nightly builds they would not report issues in jira so we could fix them - so using nightly builds to see if your "favorite" bug is fixed/remains is the best way to ensure that the final one will be better..

_________________
Max
Don't forget to rate


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