The error hasn't actually changed from the one I posted originally. Is there any way of changing Tomcat's logging to display more information? I know there is a reference to a Ejb3Configuration.buildEntityManagerFactory but i am not actually using EJB3's. I am just using the EntityManagers/EntityManagerFactory that uses config from persistence.xml, a file in which you can tell it what datasource to make your persistence unit to use. I tell it to use "jdbc/workout_logger".
I guess I can try writing a simple Servlet that tries to get the context using the example in Tomcat's docs. I just thought that in the end, all ways call the same InitialContext.lookup method. Arturo - I have copied the same stacktrace that I am getting. It's almost as if the config changes haven't done anything. Just to make sure that it's loading the files, I tried to start tomcat with a "broken" xml and it fails to start, so I know that it's loading the right config files. 1 17:32:17 ERROR ceConnectionProvider: Could not find datasource: jdbc/workout_logger javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137) at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52) .... Filip Hanik - Dev Lists wrote: > > post the actual error you see with the new config > > arturoguedez wrote: >> Thanks for the help. I just tried it and it still does work. >> >> Here is the exact content of my current server.xml and my context.xml >> >> Server.xml: >> >> <?xml version='1.0' encoding='utf-8'?> >> <Server port="8005" shutdown="SHUTDOWN"> >> >> <Listener className="org.apache.catalina.core.AprLifecycleListener" >> SSLEngine="on" /> >> <Listener className="org.apache.catalina.core.JasperListener" /> >> <Listener >> className="org.apache.catalina.mbeans.ServerLifecycleListener" >> /> >> <Listener >> className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" >> /> >> >> <GlobalNamingResources> >> <Resource name="UserDatabase" auth="Container" >> type="org.apache.catalina.UserDatabase" >> description="User database that can be updated and saved" >> >> factory="org.apache.catalina.users.MemoryUserDatabaseFactory" >> pathname="conf/tomcat-users.xml" /> >> >> <Resource name="jdbc/workout_logger" auth="Container" >> type="javax.sql.DataSource" >> maxActive="100" maxIdle="30" maxWait="10000" >> username="user" password="password" >> driverClassName="com.mysql.jdbc.Driver" >> >> url="jdbc:mysql://localhost:3306/workout_logging?autoReconnect=true"/> >> >> </GlobalNamingResources> >> >> <Service name="Catalina"> >> <Connector port="8080" protocol="HTTP/1.1" >> connectionTimeout="20000" >> redirectPort="8443" /> >> >> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> >> >> <Engine name="Catalina" defaultHost="localhost"> >> >> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" >> resourceName="UserDatabase"/> >> >> <Host name="localhost" appBase="webapps" >> unpackWARs="true" autoDeploy="true" >> xmlValidation="false" xmlNamespaceAware="false"> >> </Host> >> >> </Engine> >> </Service> >> </Server> >> >> >> >> Context.xml >> >> <?xml version='1.0' encoding='utf-8'?> >> <Context> >> >> <WatchedResource>WEB-INF/web.xml</WatchedResource> >> <ResourceLink name="jdbc/workout_logger" >> global="jdbc/workout_logger"/> >> >> </Context> >> >> >> >> I check and my db user "user" has full access to the DB it's trying to >> use. >> Is it possible that I am missing a library or something in the classpath >> of >> tomcat? I already have the mysql connector library ( I had my DB >> connections >> working fine without datasources before, but I am trying to switch to >> using >> datasources). >> >> Thanks again >> >> Arturo >> >> >> >> >> Filip Hanik - Dev Lists wrote: >> >>> put this >>> >>> <Resource name="jdbc/workout_logger >>> " auth="Container" >>> type="javax.sql.DataSource" >>> maxActive="100" maxIdle="30" maxWait="10000" >>> username="user" password="password" >>> driverClassName="com.mysql.jdbc.Driver" >>> url="jdbc:mysql://localhost:3306/database_name?autoReconnect=true"/> >>> >>> inside the <GlobalNamingResources> in server.xml >>> >>> Put this >>> >>> <ResourceLink name="jdbc/workout_logger" global="jdbc/workout_logger"/> >>> >>> inside the <Context> elemement in conf/context.xml >>> >>> >>> and try again >>> >>> Filip >>> >>> arturoguedez wrote: >>> >>>> hey, sorry about that. The actual string I have in my app is >>>> "workout_logger" >>>> I just tried to replace my strings for "my_jdbc_name" for the posting. >>>> I >>>> guess I forgot to rename the in the error. >>>> >>>> other than that, do you see anything else wrong? >>>> >>>> >>>> >>>> Filip Hanik - Dev Lists wrote: >>>> >>>> >>>>> here is the name you specify >>>>> >>>>> <res-ref-name>jdbc/my_jdbc_name</res-ref-name> >>>>> >>>>> and here is your error >>>>> Could not find datasource:jdbc/workout_logger >>>>> >>>>> as you can see, somewhere you have configured the string >>>>> workout_logger, >>>>> and that one doesn't exist >>>>> >>>>> Filip >>>>> >>>>> arturoguedez wrote: >>>>> >>>>> >>>>>> Hi! >>>>>> >>>>>> I have been reading how to setup datasources for Tomcat 6.0.18 in >>>>>> http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html >>>>>> and nothing I have done has allowed my web application to view the >>>>>> datasource i have created. >>>>>> >>>>>> Here are some snippets of my web.xml, and my server.xml >>>>>> >>>>>> In the web.xml >>>>>> >>>>>> <resource-ref> >>>>>> <description>DB Connection</description> >>>>>> <res-ref-name>jdbc/my_jdbc_name</res-ref-name> >>>>>> <res-type>javax.sql.DataSource</res-type> >>>>>> <res-auth>Container</res-auth> >>>>>> </resource-ref> >>>>>> >>>>>> In server.xml >>>>>> I have tried to place the following snip it anywhere I saw in the >>>>>> docs >>>>>> it >>>>>> could belong to (ei, in the GlobalNamingResources, inside the Host >>>>>> tag, >>>>>> or >>>>>> inside the Context tag in all possible locations (under >>>>>> META-INF/context.xml, under >>>>>> $CATALINA_BASE/conf/[engine]/[host]/[path].xml) >>>>>> and I haven't been successful. >>>>>> >>>>>> <Resource name="jdbc/my_jdbc_name" auth="Container" >>>>>> type="javax.sql.DataSource" >>>>>> maxActive="100" maxIdle="30" maxWait="10000" >>>>>> username="user" password="password" >>>>>> driverClassName="com.mysql.jdbc.Driver" >>>>>> >>>>>> url="jdbc:mysql://localhost:3306/database_name?autoReconnect=true"/> >>>>>> >>>>>> >>>>>> I am using Entity Managers to get my connections opened, here is the >>>>>> snip >>>>>> it >>>>>> of my persistence.xml >>>>>> >>>>>> <persistence-unit name="my_pu_name" >>>>>> transaction-type="RESOURCE_LOCAL"> >>>>>> <non-jta-data-source>jdbc/my_jdbc_name</non-jta-data-source> >>>>>> </persistence-unit> >>>>>> >>>>>> Here is what I get in my tomcat logs: >>>>>> >>>>>> 08/12/21 17:32:17 ERROR ceConnectionProvider: Could not find >>>>>> datasource: >>>>>> jdbc/workout_logger >>>>>> javax.naming.NameNotFoundException: Name jdbc is not bound in this >>>>>> Context >>>>>> at org.apache.naming.NamingContext.lookup(NamingContext.java:770) >>>>>> at org.apache.naming.NamingContext.lookup(NamingContext.java:153) >>>>>> at >>>>>> org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) >>>>>> at javax.naming.InitialContext.lookup(InitialContext.java:392) >>>>>> at >>>>>> org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75) >>>>>> at >>>>>> org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137) >>>>>> at >>>>>> org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29) >>>>>> at >>>>>> org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89) >>>>>> at >>>>>> org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101) >>>>>> at >>>>>> org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325) >>>>>> at >>>>>> org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867) >>>>>> at >>>>>> org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669) >>>>>> at >>>>>> org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126) >>>>>> at >>>>>> javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52) >>>>>> .... >>>>>> >>>>>> >>>>>> >>>>>> Does anybody know what I am doing wrong? Is there any way to check >>>>>> which >>>>>> resources Tomcat makes avaiable? I am having a really hard time >>>>>> understanding what I am doing wrong. >>>>>> >>>>>> >>>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >>>>> For additional commands, e-mail: users-h...@tomcat.apache.org >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >>> For additional commands, e-mail: users-h...@tomcat.apache.org >>> >>> >>> >>> >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > > -- View this message in context: http://www.nabble.com/Tomcat-6-JDBC-connection-not-found-tp21120259p21154279.html Sent from the Tomcat - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org