Hi,
I'm trying to set up Hibernate tools to work in Eclipse.
I'm running Eclipse 3.4.1 and HibernateTools-3.2.4.Beta1. The stable version of the Hibernate tools seems to crash my Eclipse.
In the Hibernate tools configuration screen I have selected the JPA option and filled out the project name and the persistant unit. The database connection is [Hibernate configured connection].
Here's the persistence.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<persistence 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"
version="1.0">
<persistence-unit name="ritz">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/ritzDatasource</jta-data-source>
<properties>
<property name="hibernate.archive.autodetection" value="class, hbm" />
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/ritzEntityManagerFactory"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect" />
<property name="hibernate.default_schema" value="RITZ"/>
<property name="hibernate.jdbc.batch_size" value="0"/>
</properties>
</persistence-unit>
</persistence>
the ritz-ds.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<local-tx-datasource>
<jndi-name>ritzDatasource</jndi-name>
<connection-url>jdbc:oracle:thin:@123.ete.test.net:1539:ritzd1</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>user</user-name>
<password>password</password>
<min-pool-size>1</min-pool-size>
<max-pool-size>20</max-pool-size>
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<new-connection-sql>select * from dual</new-connection-sql>
<check-valid-connection-sql>select * from dual</check-valid-connection-sql>
<metadata>
<type-mapping>Oracle10g</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
When I try to connect, this is the error message I get.
Here's the stacktrace:
Code:
Error
Thu Nov 20 10:51:26 PST 2008
org.hibernate.HibernateException: Could not find datasource
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:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:395)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:93)
at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:390)
at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:43)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:99)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:105)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:234)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
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(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
... 15 more
The configuration part loads my entities without problems, but the Session factory and Database don't seem to work.
It seems that the tool can't find the ritz-ds.xml file. Is there a way to link to that?
I've also tried to set up the database connection manually, instead of using the [Hibernate configured connection], but that doesn't seem to work either. I'm then able to connect to the database and get my tables to show up under the Database section in the tree, but the session factory still failing.
Any help that can point me in the right direction would be greatly appreciated. I've read most of the posts on the board remotely relevant to this, but couldn't get it to work.
Thanks.
Peter