-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to use hibernate on Tomcat 5.5
PostPosted: Mon Aug 01, 2005 12:58 am 
Beginner
Beginner

Joined: Thu Jul 28, 2005 6:40 pm
Posts: 29
Hi;

With the point system posting an answer rather than a question is strongly discouraged - but I figure this is important enough to use up a point.

Tomcat 5.5 has changed how it does the JNDI settings for a JDBC setup. I am still working through some minor details making sure I have them exactly right. But the following works.

First, do not place anything in server.xml. Everything you do will go in your webapp directory. My webapp is named store.

Note: I do not create a war when developing so this is in an exploded directory.

META-INF/context.xml(complete):
<Context path="/store" docBase="store"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/storeDB" auth="Container" type="javax.sql.DataSource"
username="sa" password="mmouse" driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=StoreTest;SelectMethod=cursor"
maxActive="8" maxIdle="4"/>
</Context>

web.xml (just the resource part):
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

...

<resource-ref>
<description>Connection to my DB.</description>
<res-ref-name>jdbc/storeDB</res-ref-name>
<res-type>javax.sql.DataSource </res-type>
<res-auth>Container</res-auth>
</resource-ref>

...

</web-app>


hibernate.cfg.xml (just DB part):
<session-factory>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

<property name="connection.datasource">java:/comp/env/jdbc/storeDB</property>

...

</session-factory>

</hibernate-configuration>

AND - this is important - this will not work when run from IntelliJ! It only works if you start Tomcat and use it normally. Will post when I figure out the IntelliJ part.

thanks - dave


Top
 Profile  
 
 Post subject: Re: How to use hibernate on Tomcat 5.5
PostPosted: Mon Aug 01, 2005 2:37 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
david@windward.net wrote:
Hi;

With the point system posting an answer rather than a question is strongly discouraged - but I figure this is important enough to use up a point.


Dave,

Posting information isn't discouraged. But, as one of the Hibernate guys has previously responded, it doesn't belong in the Forums. The forums are for questions and answers.

There is a WIKI community area on the Hibernate main page for helpful information, FAQ, etc...

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 7:09 pm 
Beginner
Beginner

Joined: Thu Jul 28, 2005 6:40 pm
Posts: 29
Hi;

First off, I didn't post to the wiki because a) I don't feel I know hibernate well enough to be posting there (using it less than a week) and b) if someone does a search in the forums for help - it won't come up.

Ok, here's the IntelliJ part you have to do. Lets assume your webapp is named store.

1) copy webapps/store/META-INF/context.xml to %Tomcat 5.5%\conf\Catalina\localhost/store.xml - not the filename change.

2) In the run/debug configuration, deployment tab, set the application context to /store (the default is /).

3) In the server tab the startup page is now http://localhost:8080/store/index.html (the store directory is added).

And then - - it works!!!

thanks - dave


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

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.