Jump to content
We've recently updated our Privacy Statement, available here ×

Unable to connect via JNDI


markmaslow

Recommended Posts

I am unable to create a JNDI database connection in JasperServer.

The following is in the Tomcat server.xml file, inside the GlobalNamingResources section:

    <Resource name="jdbc/ClubOnBarbeau" auth="Container"
       type="javax.sql.DataSource"
  driverClassName="com.sybase.jdbc3.jdbc.SybDriver"
  url="jdbc:sybase:Tds:10.1.1.xx:xx/xxxx"
  username="*****"
  password="*****"
       maxActive="20"
         maxIdle="10"
         maxWait="20000"
 />
 

I am able to connect to this datasource in another web application.  In the web.xml for that application, I put the following:

      <ResourceLink
             name="jdbc/ClubOnBarbeau"
             global="jdbc/ClubOnBarbeau"
             type="javax.sql.DataSource"
           />
 

The application connects without problem.

But if I try creating a new JNDI datasource in JasperServer, using the following Service Name:

jdbc/ClubOnBarbeau

When I press "Test connection", I get "Test failed".  No other information seems to be available.

Am I missing something?

 

 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Yes, I want to use a JNDI connection in order to take advantage of connection pooling.  Connecting to the DB is a relatively high overhead operation, so it is more efficient to reuse connections than to open a new one every time a report is run.

I have a JNDI datasource defined in the GlobalNamingResources section of the server.xml file for the tomcat server.  I know that it works, because another web app on the same server uses it.  I copied the resource from server.xml into context.xml in the META-INF folder of the jasperserver application directory.  Stopped and restarted the server, but still get "Test failed" when pressing the "Test connection" button after trying to set up a datasource that uses it.

The server must be able to find the driver, since I can set up a regular JDBC connection with that driver.

Unfortunately, there seems to be no information whatsoever available to give me any clues as to what the cause of the problem might be, and I have run out of ideas.

If anyone has any ideas as to things to try, I would greatly appreciate hearing them.

 

Link to comment
Share on other sites

What app server are you deploying on...Tomcat, Glassfish, JBoss???

 

I am using Glassfish and had to update the web.xml and sun-web.xml files within the JasperServer-pro.war file that is deployed...I had to add resource ref entries

so that Jasper could find the JNDI entries

 

web.xml: I added

<resource-ref>

<description>WCS database</description>

<res-ref-name>jdbc/wcsReports</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>

 

sun-web.xml: I added

<resource-ref>

<res-ref-name>jdbc/wcsReports</res-ref-name>

<jndi-name>jdbc/wcsReports</jndi-name>

</resource-ref>

 

Link to comment
Share on other sites

I am deploying to Tomcat 6.

I tried cloning one of the existing jndi datasources, but that didn't work either.

In the META-INF/context.xml, I have the following 2 entries:

    <Resource name="jdbc/foodmart" auth="Container" type="javax.sql.DataSource"
        maxActive="100" maxIdle="30" maxWait="10000"
            username="jasperdb" password="password" driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://127.0.0.1:3306/foodmart"/>
       
    <Resource name="jdbc/testfoodmart" auth="Container" type="javax.sql.DataSource"
        maxActive="100" maxIdle="30" maxWait="10000"
            username="jasperdb" password="password" driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://127.0.0.1:3306/foodmart"/>

In thet WEB-INF/web.xml, I have the following 2 entries:

  <resource-ref>
    <description>Foodmart database</description>
    <res-ref-name>jdbc/foodmart</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
  <resource-ref>
    <description>Test Foodmart database</description>
    <res-ref-name>jdbc/testfoodmart</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
 

I can successfully connect to the jdbc/foodmart datasource, but the test on the jdbc/testfoodmart datasource fails.

Very mysterious.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...