-->
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.  [ 1 post ] 
Author Message
 Post subject: Problems Loading Datasource in JBoss/Tomcat Configuration
PostPosted: Fri Sep 17, 2004 1:51 am 
Newbie

Joined: Tue Mar 09, 2004 8:52 pm
Posts: 5
I am trying to migrate an existing Hibernate application from Tomcat to JBoss to take advantage of EJB support and possibly better Hot Deployment.

The context and datasource were previously defined in Tomcat's server.xml file (code snippet 1). The context path was being redirected to the c:\eclipse\workspace directory.

The datasource has now been moved to JBoss in a mysql-ds.xml file (code snippet 2). The context statement (minus the datasource) was moved to the server.xml file defined in the c:\jboss\server\default\deploy\jbossweb-tomcat50.sar directory.

The problem is that the context is being loaded from the server.xml file before the datasource has been created. This causes the following error:

00:28:15,918 INFO [Binder] Mapping collection: com.agworks.model.User.actionItems -> actionitem
00:28:15,918 INFO [Binder] Mapping collection: com.agworks.model.User.phones -> userphone
00:28:15,918 INFO [Binder] Mapping collection: com.agworks.model.User.addresses -> useraddress
00:28:15,918 INFO [Binder] Mapping collection: com.agworks.model.User.roleAssignments -> roleAssignment
0
00:28:15,934 INFO [Configuration] processing one-to-one association property references
00:28:15,934 INFO [Configuration] processing foreign key constraints
00:28:15,981 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialect
00:28:15,981 INFO [SettingsFactory] Use outer join fetching: true
00:28:16,027 INFO [NamingHelper] JNDI InitialContext properties:{}
00:28:16,043 FATAL [DatasourceConnectionProvider] Could not find datasource: java:comp/env/jdbc/agworks
javax.naming.NameNotFoundException: env not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
at org.jnp.server.NamingServer.lookup(NamingServer.java:253)


The datasource is later loaded as shown below:
00:28:17,652 INFO [jdbc/agworks] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=LocalTxCM,name=jdbc/agworks to JNDI name 'java:/jdbc/agworks'

How do I not load the context until after the datasource is loaded when using JBoss?

Any help would be greatly appreciated.

Rafe
___________________________________________________________

Code Snippet 1
<Context path="/agworks" docBase="c:\eclipse\workspace\agworks" workDir="C:\eclipse\workspace\agworks\work" debug="5" reloadable="true" crossContext="true">

<Resource name="jdbc/agworks" auth="Container" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/agworks">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/agworks?relaxAutoCommit=true&amp;autoReconnectForPools=true</value>
</parameter>

<parameter>
<name>driverClassName</name><value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>agworks</value>
</parameter>
<parameter>
<name>password</name>
<value>river2000</value>
</parameter>

<!-- DBCP connection pooling options -->
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->

<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- When available db connections run low DBCP will recover and recyle any abandoned dB connections it finds. -->
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>

<!-- Use the removeAbandonedTimeout parameter to set the number of seconds a dB connection has been idle before it is considered abandoned. -->
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>

<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->

<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->

<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
</ResourceParams>
</Context>

Code Snippet 2
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/agworks</jndi-name>
<connection-url>jdbc:mysql://localhost/agworks</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>agworks</user-name>
<password>river2000</password>
<min-pool-size>0</min-pool-size>

</local-tx-datasource>
</datasources>


a Hibernate/Tomcat installation to


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.