-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Alexander,
On 2/20/13 10:31 AM, Alexander Dümont wrote: > 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. Welcome to the community. Your English is very good! No need to apologize. > => 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> Since you are configuring your DataSource in context.xml, you don't really need <resource-ref>, but it's probably best to configure it, anyway. It does not harm anything and helps document your webapp's configuration a bit. > <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> [snip] > <?xml version="1.0" encoding="UTF-8"?> <Context> <Resource > type="javax.sql.DataSource" name="jdbc/DSCarsAppDB" > factory="org.h2.jdbcx.JdbcDataSourceFactory" You probably don't need to specify this factory. If you don't specify this, you'll get Tomcat's built-in DBCP. > driverClassName="org.h2.Driver" url="jdbc:h2:carmanager" Above, you've for "jdbc:h2:carmanager01". Is that intentionally different? > 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 know it seems excessive, but you can post your entire catalina.out (after you shut down Tomcat, remove catalina.out, and re-start)? Sometimes all that extra "junk" in the stack trace can help. > I got different exceptions when trying to use > $(Tomcat)/conf/context.xml, by setting a Resource or a > ResourceLink. <ResourceLink> is only used if you have configured your DataSource in Tomcat's global conf/server.xml -- you shouldn't need that. Another simple question: did you restart Tomcat completely after putting the H2 JAR into $CATALINA_BASE/lib? - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEAREIAAYFAlEmzGgACgkQ9CaO5/Lv0PCJpQCbB0M21GcHe0FMJ+zMsrvkjV65 G14AoMJcoLNPtZKWq5DzAph1xPuVqngA =neOL -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org