- This topic has 3 replies, 3 voices, and was last updated 20 years, 9 months ago by
Javier Ramos.
-
AuthorPosts
-
Hi,
I am working on a web project that will be deployed to a Tomcat 5 server. The persistence is done with Hibernate. I want to use also tomcat’s built in connection pooling (DBCP), so I created a context configuration for my project in server.xml, including a JNDI entry for the DBCP data source.
When creating the config file for Hibernate, I can set the JNDI name that I configured before, but I need to provide also an InitialContextFactory class. After searching the web I reached the conclusion that this class must be:
org.apache.catalina.naming.java.javaURLContextFactory
if my webapp is going to run inside Tomcat.
The problem is that this does not work… when loading a page that acesses data I get:
java.lang.ClassNotFoundException: org.apache.catalina.naming.java.javaURLContextFactory
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)Can anyone help here? Am I doing something wrong? Should I be using some other InitialContextFactory class?
Any help would be very much appreaciated.
Thanks for your attention,
Javier
August 30, 2004 at 9:59 am #213951
snpeMembertry set hibernate.connection.datasource parametar in your JNDI name
Hibernate will choose defaultregards
August 30, 2004 at 10:19 am #213955
Riyad KallaMemberJavier,
Your file should look something like this:<hibernate-configuration> <session-factory> <property name="connection.datasource">java:comp/env/jdbc/quickstart</property> <property name="show_sql">false</property> <property name="dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property> <!-- Mapping files --> <mapping resource="Cat.hbm.xml"/> </session-factory> </hibernate-configuration>
No need for InitialContextFactory that I’m aware of.
August 30, 2004 at 10:24 am #213957This works, thanks.
Javier
-
AuthorPosts