-->
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: ERROR [DatasourceConnectionProvider] Could not find datasour
PostPosted: Wed Jul 21, 2010 2:20 am 
Newbie

Joined: Mon Jul 19, 2010 3:21 pm
Posts: 3
Hi all

Im a newbie I using JBoss-5.1.0.GA

with mysql and hibernate 3 and Im getting some error with configuring datasource. Below are my hibernate.cfg.xml and mysql-ds.xml Please let me know if im missing anything.

I have my mysql-ds.xml under this F:\jboss-5.1.0.GA

\server\default\deploy

hibernate.cfg.xml
<?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

">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory name="jdbc/ercDS">
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.url">jdbc:mysql://localhost:3306/</property>
<property name="connection.username">root</property>
<property name="connection.password">sandeep123</property>
<property name="connection.pool_size">2</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.default_schema">erc</property>
<property name="hibernate.generate_statistics">true</property>
<property name="hibernate.order_inserts">true</property>
<property name="hibernate.order_updates">true</property>
<property name="hibernate.use_identifier_rollback">true</property>
<property name="hibernate.bytecode.use_reflection_optimizer">true</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.query.startup_check">true</property>
<property name="hibernate.current_session_context_class">jta</property>
<property name="hibernate.query.startup_check">true</property>

<!-- JTA transaction properties (begin) -->
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<!-- JTA transaction properties (end) -->

<!-- DataSource properties (begin) -->
<property name="hibernate.connection.datasource">jdbc/ercDS</property>
<!-- DataSource properties (end) -->

<!-- JBoss transaction manager lookup (begin) -->
<property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<!-- JBoss transaction manager lookup (end) -->

<!-- Mapping files -->
</session-factory>
</hibernate-configuration>

Im using annotation so i donot have any mapping files how ever i hand configure my class

private static Configuration configuration = new AnnotationConfiguration().addAnnotatedClass(Organisation.class);
--------------------------------------------------------------------------------------------------------------------------------------------------------------
mysql-ds.xml

<?xml version="1.0" encoding="UTF-8"?>

<!-- See http://www.jboss.org/community/wiki/Multiple1PC

for information about local-tx-datasource -->
<!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
<!-- Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html

-->

<datasources>
<local-tx-datasource>
<!-- The jndi name of the DataSource, it is prefixed with java:/ -->
<!-- Datasources are not available outside the virtual machine -->
<jndi-name>jdbc/ercDS</jndi-name>
<!-- For server mode db, allowing other processes to use mysql db over tcp.-->
<connection-url>jdbc:mysql://localhost:3306/</connection-url>
<!-- The driver class -->
<driver-class>com.mysql.jdbc.Driver</driver-class>
<!-- The login and password -->
<user-name>root</user-name>
<password>sandeep123</password>
<!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
<min-pool-size>1></min-pool-size>
<!-- The maximum connections in a pool/sub-pool -->
<max-pool-size>20></max-pool-size>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional)
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata> -->
</local-tx-datasource>
</datasources>


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Thanks
Sandeep


Top
 Profile  
 
 Post subject: Re: ERROR [DatasourceConnectionProvider] Could not find datasour
PostPosted: Thu Jul 22, 2010 2:19 am 
Newbie

Joined: Mon Jul 19, 2010 3:21 pm
Posts: 3
some more info reg the issue

10:50:52,312 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
10:50:52,843 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
10:50:52,875 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=jdbc/ercDS' to JNDI name 'java:jdbc/ercDS'

I see JNDI is configured

----------------------------------------------------------------------------------------------------------------

Im getting the below exception

[color=#4000FF]before getSessionFactory
11:08:36,625 INFO [STDOUT] HibernateSessionFactory.initiate Enter
11:08:36,625 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
11:08:36,625 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
11:08:36,625 INFO [Configuration] Configured SessionFactory: jdbc/ercDS
11:08:36,625 INFO [HibernateSearchEventListenerRegister] Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
11:08:36,640 INFO [NamingHelper] JNDI InitialContext properties:{}
11:08:36,640 ERROR [DatasourceConnectionProvider] Could not find datasource: jdbc/ercDS
javax.naming.NameNotFoundException: jdbc not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
at org.jnp.server.NamingServer.getObject(NamingServer.java:785)

------------------------------------------------------------------------------------------------------------

this is my code to create session

SessionFactory sessionFactory = HibernateSessionFactory.getSessionFactory();
CommonUtil.debugLog(_log, METHOD, "SessionFactory :: "+sessFact);
session= sessFact.getCurrentSession();

------------------------------------------------------------------------------------------------------------

I had also tried changing

<session-factory name="java:jdbc/ercDS">
<property name="hibernate.connection.datasource">java:jdbc/ercDS</property>

im getting the below exception

before getSessionFactory
11:32:40,921 INFO [STDOUT] HibernateSessionFactory.initiate Enter
11:32:40,921 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
11:32:40,921 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
11:32:40,921 INFO [Configuration] Configured SessionFactory: java:jdbc/ercDS
11:32:40,921 INFO [HibernateSearchEventListenerRegister] Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
11:32:40,937 INFO [NamingHelper] JNDI InitialContext properties:{}
11:32:40,937 ERROR [DatasourceConnectionProvider] Could not find datasource: java:jdbc/ercDS
java.lang.ClassCastException: org.hibernate.impl.SessionFactoryImpl cannot be cast to javax.sql.DataSource

it says Could not find datasource: java:jdbc/ercDS and it throws java.lang.ClassCastException not sure why it is comming

----------------------------------------------------------------------------------------------------------------

any help to fix this issue is great

Thanks

Sandeep


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.