-->
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.  [ 3 posts ] 
Author Message
 Post subject: JPA Console Configuration
PostPosted: Tue Oct 16, 2007 7:22 pm 
Newbie

Joined: Tue Oct 16, 2007 6:52 pm
Posts: 2
hi,

I use Hibernate Tools 3.2.0beta11 with Eclipse 3.3 & WTP2.0 and i would like to prototype my hql queries with the HQL Editor.

I've created a new JPA project and added my META-INF/persistence.xml this way

Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
   <persistence-unit name="testJPA">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:/test-DS</jta-data-source>
      <class>com.test.Person</class>
                <class>com.test.Departement</class>
   </persistence-unit>
</persistence>


I've also added my hibernate.cfg.xml file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory name="testJPAFactory">
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.password">secret</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
        <property name="hibernate.connection.username">myUser</property>
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
    </session-factory>
</hibernate-configuration>


I've created my console configuration by filling the name, project, type(JPA) and the persistence unit name and i got my console configuration that lists correctly my entities Person and Departement in the Configuration child but no session, it says <Sessionfactory error: Could not find datasource>

Code:
org.hibernate.HibernateException: Could not find datasource
   at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
   at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
   at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
   at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:317)
   at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
   at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:89)
   at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:312)
   at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:55)
   at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:63)
   at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
   at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545)
   at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
   at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
   at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
   at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   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.equinox.launcher.Main.invokeFramework(Main.java:504)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
   at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
   at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
   at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
   at javax.naming.InitialContext.lookup(Unknown Source)
   at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
   ... 39 more
!SUBENTRY 2 org.hibernate.eclipse.console 4 150 2007-10-17 01:14:10.796
!MESSAGE javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
!STACK 0
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
   at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
   at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
   at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
   at javax.naming.InitialContext.lookup(Unknown Source)
   at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
   at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
   at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
   at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:317)
   at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
   at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:89)
   at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:312)
   at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:55)
   at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:63)
   at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
   at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545)
   at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
   at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
   at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
   at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   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.equinox.launcher.Main.invokeFramework(Main.java:504)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1169)


What am i doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 1:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
your persistence.xml states i wants to use a jta-datasource.

you can override that by putting the connection properties in a xyz.properties file and make the console configuration point to that.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 8:20 am 
Newbie

Joined: Tue Oct 16, 2007 6:52 pm
Posts: 2
max wrote:
your persistence.xml states i wants to use a jta-datasource.

you can override that by putting the connection properties in a xyz.properties file and make the console configuration point to that.


Thank you max for your reply, it did not solve my problem when i added and pointed my console configuration to it
Code:
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.password=secret
hibernate.connection.url=jdbc:oracle:thin:@localhost:1521:xe
hibernate.connection.username=myUser
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect


here is the stack trace
Code:
org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect.Oracle9Dialect
   at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:81)
   at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
   at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
   at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:357)
   at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
   at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:88)
   at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:352)
   at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:41)
   at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:89)
   at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:95)
   at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:196)
   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


I must do something wrong. :(

But, it works fine when i comment my <jta-data-source> and i was able to start prototyping my queries. thank you again


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