-->
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.  [ 2 posts ] 
Author Message
 Post subject: using datasource configured in tomcat
PostPosted: Tue Oct 12, 2004 9:12 am 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
Hibernate version:2.1

Mapping documents:
Here is the configuration file for hibernate:

(hibernate.cfg.xml)
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/hibernate</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- Mapping files -->
<mapping resource="User.hbm.xml"/>
</session-factory>
</hibernate-configuration>




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

The datasource is configured succesfully in the tomcat context file (i used it without hibernate so i am sure it is ok).
The problem is that hiberante doens't see the datasource but it is strange becase in the log belove it says everything is ok unitll the last line where say:
15:06:49,679 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured.
What is happenening??


Full stack trace of any exception that occurs:
2004-10-12 15:06:48 NamingContextListener[/Catalina/localhost/hibernate]: Resource parameters for jdbc/hibernate = ResourceParams[name=jdbc/hibernate, parameters={factory=org.apache.commons.dbcp.BasicDataSourceFactory, maxWait=-1, maxActive=20, password=sagra, url=jdbc:mysql:///hibernate, driverClassName=com.mysql.jdbc.Driver, maxIdle=10, username=agori}]
2004-10-12 15:06:48 NamingContextListener[/Catalina/localhost/hibernate]: Adding resource ref jdbc/hibernate
2004-10-12 15:06:48 NamingContextListener[/Catalina/localhost/hibernate]: ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=maxWait,content=-1},{type=maxActive,content=20},{type=password,content=sagra},{type=url,content=jdbc:mysql:///hibernate},{type=driverClassName,content=com.mysql.jdbc.Driver},{type=maxIdle,content=10},{type=username,content=agori}]
2004-10-12 15:06:48 NamingContextListener[/Catalina/localhost/hibernate]: Resource parameters for UserTransaction = null
2004-10-12 15:06:50 StandardContext[/hibernate]StandardWrapper.Throwable
java.lang.ExceptionInInitializerError
at servlets.Init.init(Init.java:26)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3991)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer.java:903)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:252)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:256)
at org.apache.commons.digester.Rule.end(Rule.java:276)
at org.apache.commons.digester.Digester.endElement(Digester.java:1058)
at org.apache.catalina.util.CatalinaDigester.endElement(CatalinaDigester.java:76)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1567)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:488)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:482)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:964)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:476)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2298)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)
Caused by: java.lang.NoClassDefFoundError: javax/transaction/Synchronization
at net.sf.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:313)
at net.sf.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:326)
at net.sf.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:334)
at servlets.Init.init(Init.java:22)
... 46 more

2004-10-12 15:06:50 StandardContext[/hibernate]15:06:48,217 INFO Environment:469 - Hibernate 2.1.6
15:06:48,227 INFO Environment:503 - loaded properties from resource hibernate.properties: {hibernate.connection.username=agori, hibernate.connection.password=sagra, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql:///hibernate, hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N'}
15:06:48,227 INFO Environment:529 - using CGLIB reflection optimizer
15:06:48,237 INFO Configuration:895 - configuring from resource: /hibernate.cfg.xml
15:06:48,247 INFO Configuration:867 - Configuration resource: /hibernate.cfg.xml
15:06:48,377 INFO Configuration:331 - Mapping resource: User.hbm.xml
15:06:48,477 INFO Binder:229 - Mapping class: beans.User -> USER
15:06:48,657 INFO Configuration:1053 - Configured SessionFactory: null
15:06:48,667 INFO Configuration:627 - processing one-to-many association mappings
15:06:48,667 INFO Configuration:636 - processing one-to-one association property references
15:06:48,667 INFO Configuration:661 - processing foreign key constraints
15:06:48,747 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
15:06:48,747 INFO SettingsFactory:59 - Maximim outer join fetch depth: 2
15:06:48,747 INFO SettingsFactory:63 - Use outer join fetching: true
15:06:48,757 INFO NamingHelper:26 - JNDI InitialContext properties:{}
15:06:48,808 INFO DatasourceConnectionProvider:51 - Using datasource: java:comp/env/jdbc/hibernate
15:06:48,818 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
15:06:49,008 INFO SettingsFactory:103 - Use scrollable result sets: false
15:06:49,018 INFO SettingsFactory:106 - Use JDBC3 getGeneratedKeys(): false
15:06:49,018 INFO SettingsFactory:109 - Optimize cache for minimal puts: false
15:06:49,088 INFO SettingsFactory:115 - echoing all SQL to stdout
15:06:49,088 INFO SettingsFactory:118 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
15:06:49,088 INFO SettingsFactory:129 - cache provider: net.sf.hibernate.cache.EhCacheProvider
15:06:49,098 INFO Configuration:1116 - instantiating and configuring caches
15:06:49,238 INFO SessionFactoryImpl:118 - building session factory
15:06:49,679 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured

2004-10-12 15:06:50 StandardContext[/hibernate]Servlet /hibernate threw load() exception
javax.servlet.ServletException: Servlet.init() for servlet init threw exception
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1061)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3991)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer.java:903)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:252)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:256)
at org.apache.commons.digester.Rule.end(Rule.java:276)
at org.apache.commons.digester.Digester.endElement(Digester.java:1058)
at org.apache.catalina.util.CatalinaDigester.endElement(CatalinaDigester.java:76)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1567)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:488)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:482)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:964)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:476)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2298)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)
----- Root Cause -----
java.lang.ExceptionInInitializerError
at servlets.Init.init(Init.java:26)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3991)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer.java:903)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:252)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:256)
at org.apache.commons.digester.Rule.end(Rule.java:276)
at org.apache.commons.digester.Digester.endElement(Digester.java:1058)
at org.apache.catalina.util.CatalinaDigester.endElement(CatalinaDigester.java:76)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1567)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:488)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:482)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:964)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:476)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2298)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)
Caused by: java.lang.NoClassDefFoundError: javax/transaction/Synchronization
at net.sf.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:313)
at net.sf.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:326)
at net.sf.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:334)
at servlets.Init.init(Init.java:22)
... 46 more




Name and version of the database you are using:
Mysql


The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 12, 2004 3:12 pm 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
Simply i have to remove hibernate.properties from my classpath.


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