tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leon.m...@hccnet.nl
Subject Re: add database resource
Date Wed, 09 Jan 2013 23:14:45 GMT
Op Wo, 9 januari, 2013 11:48 pm schreef Mark Eggers:
> On 1/9/2013 1:37 PM, Christopher Schultz wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>>
>> Leon,
>>
>>
>> On 1/9/13 4:25 PM, leon.mail@hccnet.nl wrote:
>>
>>> I'm quite new with tomcat. I run 7.0.30.
>>>
>>
>> Welcome. 7.0.35 will likely be released shortly. Please upgrade when
>> you can.
>>
>>> I have successfully installed an application, however i'm facing
>>> issues with the database connection.
>>>
>>> As i understood i added the following code to server.xml
>>>
>>>
>>> <Context path="/" debug="1" reloadable="true" crossContext="true"
>>> antiJARLocking="true" antiResourceLocking="true">
>>
>> You may be following old instructions: you shouldn't use the "path"
>> attribute in a <Context> element unless it's in your server.xml file
>> (which is should not be: you should be META-INF/context.xml in your
>> webapp's base directory instead). Also, the "debug" attribute has not
>> been valid for quite some time.
>>
>> Do you really need "crossContext", "antiJARLocking", and
>> "antiResourceLocking" attributes?
>>
>>
>>> <Resource name="jdbc/atvd" type="javax.sql.DataSource"
>>> auth="container" username="atvd" password="atvd"
>>> driverClassName="com.mysql.jdbc.Driver"
>>> url="jdbc:mysql://localhost:3306/atvd12?autoReconnect=true" />
>>>
>>
>> This looks okay to me, though it's typical to set the "maxActive" and
>> "maxIdle" attributes here to size your connection pool. The defaults
>> are maxActive=8 and maxIdle=8 FYI.
>>
>> In development, I *highly* recommend that you set maxActive=1.
>>
>>
>> I usually recommend adding a "validationQuery" plus "removeAbandoned",
>> "logAbandoned", and set a reasonable "removeAbandonedTimeout" (I use
>> "30" to specify a 30-second timeout). A good validationQuery for MySQL
>> is "/* ping */ SELECT 1" because the driver will use a lightweight ping
>> instead of actually issuing a SQL query to the server: it reduces some
>> useless overhead.
>>
>>> Unfortunately I'm Getting below error. Don't get any special
>>> information from the log.
>>>
>>> type Exception report
>>>
>>> message Could not execute action
>>>
>>> description The server encountered an internal error that prevented it
>>> from fulfilling this request.
>>>
>>> exception javax.servlet.ServletException: Could not execute action
>>> com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(Dis
>>> patcherUtils.java:196)
>>>
>>>
>>>
>> com.opensymphony.webwork.dispatcher.FilterDispatcher.doFilter(FilterDis
>> patcher.java:182)
>>
>>>
>>>
>>>
>>> root cause java.lang.NullPointerException
>>> nl.dolhuis.util.hibernate.HibernateSession.getSession(HibernateSessio
>>> n.java:25)
>>>
>>>
>>>
>> nl.dolhuis.util.hibernate.HibernateInterceptor.intercept(HibernateInter
>> ceptor.java:83)
>>
>>> com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionIn
>>> vocation.java:180)
>>>
>>>
>>>
>> com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundIn
>> terceptor.java:32)
>>
>>> com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionIn
>>> vocation.java:180)
>>>
>>>
>>>
>> com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.ja
>> va:119)
>>
>>> com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(Dis
>>> patcherUtils.java:183)
>>>
>>>
>>>
>> com.opensymphony.webwork.dispatcher.FilterDispatcher.doFilter(FilterDis
>> patcher.java:182)
>>
>>>
>>>
>>> note The full stack trace of the root cause is available in the Apache
>>> Tomcat/7.0.30 logs.
>>>
>>
>> Have you checked logs/catalina.out or anything else in logs/? You said
>> there was no special information... does it just have the same stack
>> trace or is there nothing?
>>
>> I know nothing about Hibernate, but you may have to post your
>> Hibernate configuration in order to get any further, here.
>>
>>
>> - -chris
>>
>
> Leon,
>
>
> Looks like you're using Hibernate.
>
>
> Try the following in your hibernate.cfg.xml file:
>
>
> <!-- using container-managed JNDI -->
> <property name="hibernate.connection.datasource">
> java:comp/env/jdbc/atvd
> </property>
>
>
> You'll still need the database dialect properties; in other words:
>
>
> <property name="hibernate.dialect">
> org.hibernate.dialect.MySQLDialect </property>
>
>
> You won't need any of the other connection properties in
> hibernate.cfg.xml
>
> I wrote up a Wiki page on the Tomcat site, but it really needs an update.
>
>
> 1. Uses path in context.xml (NetBeans-ism)
> 2. Doesn't use best practices in setting maxIdle and maxActive
> 3. Doesn't use a validationQuery
> 4. Doesn't use removeAbandoned
> 5. Doesn't use logAbandoned
>
>
> With a now-ancient version of Hibernate / Tomcat / Java / OS
>
>
> Hibernate 3.2.5ga
> Tomcat 6.0.26
> JRE 1.6.0_20 (32 bit)
> OS Fedora 11 (32 bit)
>
>
> However, that may be enough to get you started.
>
>
> I'll hopefully take a look at it sometime soon.
>
>
> . . . . just my two cents.
> /mde/
>
Hi Chris,

Tx for your reply.
I've added the two properte names to the hibernate.cfg.xml., within the
webapp.
I didn't write the app, somebody else did.

So where do you recommend to add the database name, user and password.
in server.xml or context.xml witin META-INF?

Regards,

Léon
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>



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


Mime
View raw message