ke, 2003-12-03 kello 04:19, Doug Parsons wrote

> Had the same problem on 4.1.29 and 3.23.58
>  Try adding this to the Web.xml
> <servlet-mapping>
> 
> <servlet-name>invoker</servlet-name>
> 
> <url-pattern>/servlet/*</url-pattern>
> 
> </servlet-mapping>
> 

Does not make sense, since I do not have servlets in my web app...

> 
> 
> > Server.xml (important parts):
> >   <GlobalNamingResources>
> >     <Resource name="jdbc/TestDB" auth="Container"
> >               type="javax.sql.DataSource"/>
> >     <ResourceParams name="jdbc/TestDB">
>     |
>     |
>     |
> >         <name>url</name>
> >         <value>jdbc:mysql://localhost/TestDB?autoReconnect=true</value>
> >       </parameter>
> >     </ResourceParams>
> 
> This section of my code is in a set of context tags.

I need it in GlobalNamingResources, since the realm uses the same DBCP.

> 
> 
> >   </GlobalNamingResources>
> >   <Service...>
> >   <Engine...>
> >   <Realm className="org.apache.catalina.realm.DataSourceRealm"
> >     debug="99" dataSourceName="jdbc/TestDB" userTable="UserTBL"
> >     userNameCol="userid" userCredCol="pass" userRoleTable="RoleTBL"
> >     roleNameCol="role"/>
> >   </Engine>
> >   </Service>
> 
> Not used in my case yet.

Works well in my case...

> Everything else looks like my code. I'm no expert and don't know how most of
> it works but it does.
> 
> I have one catch on my system. I have to restart Tomcat after I deploy the
> war file via manager. I get null pointer exceptions if I don't.

Actually I was lucky enough to solve this problem myself. Hints for the
solution was in the examples section of the default server.xml. I had to
add a Context-element for my web application into the server.xml, and in
that I needed to include ResourceLink-element telling the use of the
global datasource. Then I needed to delete the resource-ref element from
the web.xml of my web app. And voila, it started working... The downside
is that I cannot anymore use the manager ant-task to install or reload
the web application context (resulting exception when trying to use it:
javax.naming.NameNotFoundException: Name jdbc is not bound in this
Context).

I have included parts of the server.xml if someone else has the same
problem:
</GlobalNamingResources>
  <Resource name="TestDB" auth="Container"
              type="javax.sql.DataSource"
  </Resource>
  <ResourceParams name="TestDB">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
      <name>maxActive</name>
      <value>100</value>
    </parameter>
    <parameter>
      <name>maxIdle</name>
      <value>30</value>
    </parameter>
    <parameter>
      <name>maxWait</name>
      <value>10000</value>
    </parameter>
    <parameter>
      <name>username</name>
      <value>userx</value>
    </parameter>
    <parameter>
      <name>password</name>
      <value>passx</value>
    </parameter>
    <parameter>
      <name>driverClassName</name>
      <value>com.mysql.jdbc.Driver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <value>jdbc:mysql://localhost/TestDB?autoReconnect=true</value>
    </parameter>
  </ResourceParams>
</GlobalNamingResources>
...
<Context path="/testapp" docBase="testapp" debug="0"
  reloadable="true" crossContext="true">
  <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="localhost_testapp_log." suffix=".txt" timestamp="true"/>
  <ResourceLink name="jdbc/TestDB" global="TestDB"
    type="javax.sql.DataSource"/>
</Context>

The <Realm> did not change.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to