Hello,

my name is Alexander Dümont and i have some troubles configuring a JNDI datasource for Tomcat6. Im sorry, if i can't find the right words, English is not my first language and this is my first shot asking others.


I have two active configurations for the same java software project "carmanager". * The first (I) is working like a charm. Starting it by the Maven operation "jetty:run", i use this configuration for development and testing purposes. * Unfortunately the second (II) is not correctly working with my desired data source. Here i am deploying my maven generated software project WAR to a remote Tomcat6 server.


I tried to figure out the problem for ~8 hours now, used different tutorials, variations and examples, but somehow i did not succeed at all. My decent powers ended here. Now I really hope you guys can help me.

As you will see i am using a H2 database. For now it's a local database address. Below I describe what both configurations have in common and in which way they alter:


=> Both configuration have the following same conditions:

 * accessing data source by hibernate: "java:comp/env/jdbc/DSCarsAppDB"
 * $(webapp)/WEB-INF/web.xml [1]


        [1] $(webapp)/WEB-INF/web.xml

 <resource-ref>
  <res-ref-name>jdbc/DSCarsAppDB</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>


---


=> (I) My local jetty server configuration is the following:

 OS Name: Windows 7
 OS Architecture: amd64
 JVM Version: 1.7.0_02-b13
 Java(TM) SE Runtime Environment

 * $(webapp)/WEB-INF/jetty-env.xml [2]


        [2] $(webapp)/WEB-INF/jetty-env.xml

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
        <New id="DSTest" class="org.mortbay.jetty.plus.naming.Resource">
                <Arg></Arg>
                <Arg>jdbc/DSCarsAppDB</Arg>
                <Arg>
                        <New class="org.h2.jdbcx.JdbcDataSource">
                                <Set name="Description">DSCarsAppDB</Set>
                                <Set name="User">root</Set>
                                <Set name="Password">sa</Set>
                                <Set name="URL">jdbc:h2:carmanager01</Set>
                        </New>
                </Arg>
        </New>
</Configure>



---


=> (II) My remote server configuration is the following:

 Tomcat Version: Apache Tomcat/6.0.35
 JVM Version: 1.6.0_26-b03
 JVM Vendor: Sun Microsystems Inc.
 OS Name: Linux
 OS Version: 2.6.36.4-vs2.3.0.36.39-nc
 OS Architecture: amd64

 * untouched $(Tomcat)/conf/server.xml
 * untouched $(Tomcat)/conf/context.xml
* added h2-1.3.163.jar to $(Tomcat)/lib/ (next to the other shared libraries) * deployment automatically copies "context.xml"[3] to $(Tomcat)/conf/Catalina/localhost/carmanager.xml

 * $(webapp)/META-INF/context.xml [3]


        [3] $(webapp)/META-INF/context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Resource
        type="javax.sql.DataSource"
        name="jdbc/DSCarsAppDB"
        factory="org.h2.jdbcx.JdbcDataSourceFactory"
        driverClassName="org.h2.Driver"
        url="jdbc:h2:carmanager"
        username="root"
        password="sa"
        maxActive="100"
        maxIdle="20"
        minIdle="15"
        initialSize="15"
        maxWait="10000" />

</Context>


---

Exception occuring with remote server configuration (2):

org.hibernate.HibernateException: Could not find datasource: java:comp/env/jdbc/DSCarsAppDB

    
org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:82)
    
org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)
    
org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:84)
    
org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:459)
    org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:90)
    
org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
    org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
    org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
    [...]
    (hibernate factory initialization)



I got different exceptions when trying to use $(Tomcat)/conf/context.xml, by setting a Resource or a ResourceLink. The remote server configuration as described here, was only my "easiest" attempt. I thought, it's good for portraying my problem. In $(webapp)/WEB-INF/web.xml [1] i also tried <resource-env-ref> instead of <resource-ref>.


I don't know anymore what else i can do. That's why i would really appreciate any help - as a proper tutorial, ideas or the final solution.

Have a nice day!
Alexander Dümont

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to