Link to home
Start Free TrialLog in
Avatar of Bjo020
Bjo020

asked on

connection to db2 through datasource in websphere 4.0.3

Hi

When trying to connect to db2 through a datasource in websphere 4.0.3 i get this error :

[30/03/04 15:56:11:312 CEST] 6c1cef40 Helpers       W NMSV0605E: A Reference object looked up from the context "domainRoots/UnspecifiedDomainName/legacyRoot" with the name "jdbc/webreport" was sent to the JNDI Naming Manager and an exception resulted.
Reference data follows:
Reference Factory Class Name: com.ibm.websphere.advanced.cm.factory.DataSourceFactory$ResourceReferenceObjectFactory
Reference Factory Class Location URLs: <null>
Reference Class Name: com.ibm.ejs.cm.portability.PortableDataSource
Type: name
Content: webreport
Type: minimumPoolSize
Content: 1
Type: maximumPoolSize
Content: 30
Type: connectionTimeout
Content: 180
Type: idleTimeout
Content: 1800
Type: orphanTimeout
Content: 1800
Type: statementCacheSize
Content: 100
Type: disableAutoConnectionCleanup
Content: false
Type: oemId
Content: WebSphereSequeLinkClient
Type: informixLockModeWait
Content: 0
Type: oracleStmtCacheSize
Content: 0
Type: disable2Phase
Content: false
Type: dataSourceClassName
Content: COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource
Type: user
Content: webreport
Type: password
Content: {xor}DCs+LStubWw=
Type: description
Content: New DB2 Data source
Type: databaseName
Content: db2hdesk

Exception data follows:
java.lang.NoClassDefFoundError: javax/sql/ConnectionPoolDataSource
      at java.lang.ClassLoader.defineClass0(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java(Compiled Code))
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java(Compiled Code))
      at java.net.URLClassLoader.defineClass(URLClassLoader.java(Compiled Code))
      at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java(Compiled Code))
      at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java(Compiled Code))
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled Code))
      at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java(Compiled Code))
      at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
      at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
      at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:261)
      at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
      at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:261)
      at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
      at com.ibm.ws.classloader.ReloadableClassLoader.loadClass(ReloadableClassLoader.java:79)
      at com.ibm.websphere.advanced.cm.factory.DataSourceFactory.isJTAEnabled(DataSourceFactory.java:508)
      at com.ibm.ejs.cm.DataSourceFactory.createDataSource(DataSourceFactory.java:156)
      at com.ibm.ejs.cm.DataSourceFactory.getDataSource(DataSourceFactory.java:114)
      at com.ibm.websphere.advanced.cm.factory.DataSourceFactory.getDataSource(DataSourceFactory.java:386)
      at com.ibm.websphere.advanced.cm.factory.DataSourceFactory$ResourceReferenceObjectFactory.getObjectInstance(DataSourceFactory.java:701)
      at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
      at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:736)
      at com.ibm.ejs.ns.jndi.CNContextImpl.cacheLookup(CNContextImpl.java:2683)
      at com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(CNContextImpl.java:1416)
      at com.ibm.ejs.ns.jndi.CNContextImpl.lookup(CNContextImpl.java:1121)
      at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:128)
      at javax.naming.InitialContext.lookup(InitialContext.java:359)
      at hdesk.fps.SQLUtil.<clinit>(SQLUtil.java:162)
      at _leftnavi_jsp_24._jspService(_leftnavi_jsp_24.java:158)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:142)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:301)
      at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:445)
      at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:579)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
      at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:167)
      at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
      at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
      at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
      at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
      at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
      at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:665)
      at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:331)
      at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:117)
      at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:124)
      at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:218)
      at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
      at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:122)
      at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:315)
      at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
      at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:323)
      at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:252)
      at com.ibm.ws.util.CachedThread.run(ThreadPool.java:137)

I can see that I do connect to datasource as the datasource information is pulled out.


   static
    {
        try
        {
        if(source==null) {
           java.util.Properties parms = new java.util.Properties();      
           parms.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");      
           
           javax.naming.Context context = new javax.naming.InitialContext(parms);                        
           source = (javax.sql.DataSource)context.lookup("jdbc/webreport");

           context.close();
          }
        }
        catch(Exception exception)
        {        
          System.out.println(exception);
        }
    }


    public Connection getConnection()
        throws SQLException
    {
        return source.getConnection("XXXX", "YYYY"); // ERROR
    }


 
Avatar of Stan Reeser
Stan Reeser
Flag of United States of America image

Did you define your data source?
Avatar of Bjo020
Bjo020

ASKER

Yes.

All this is variables set in the data source :

Type: name
Content: webreport
Type: minimumPoolSize
Content: 1
Type: maximumPoolSize
Content: 30
Type: connectionTimeout
Content: 180
Type: idleTimeout
Content: 1800
Type: orphanTimeout
Content: 1800
Type: statementCacheSize
Content: 100
Type: disableAutoConnectionCleanup
Content: false
Type: oemId
Content: WebSphereSequeLinkClient
Type: informixLockModeWait
Content: 0
Type: oracleStmtCacheSize
Content: 0
Type: disable2Phase
Content: false
Type: dataSourceClassName
Content: COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource
Type: user
Content: webreport
Type: password
Content: {xor}DCs+LStubWw=
Type: description
Content: New DB2 Data source
Type: databaseName
Content: db2hdesk
ASKER CERTIFIED SOLUTION
Avatar of Stan Reeser
Stan Reeser
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> java.lang.NoClassDefFoundError: javax/sql/ConnectionPoolDataSource

From this, I can say, you are running in a low version JDK which doesn't support this.
You can have a higher version of JDK in which the websphere runs, then you can rectify this problem
>> javax/sql/ConnectionPoolDataSource

is part of JRE's rt.jar.  So that is the culprit.
Change your JVM...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
looks like  sreeser made a valid point, and damonf's suggestion is certainly something to try.  mmuruganandam looks inaccurate to me.
hard to pinpoint the problem with the minimal interaction, he clearly doesnt have his data sources set up correctly, and I dont't have the errors committed to memory but

A Reference object looked up from the context "domainRoots/UnspecifiedDomainName/legacyRoot" with the name "jdbc/webreport" was sent to the JNDI Naming Manager and an exception resulted.


This looks pretty clear that he cant log in.  Could be the drivers that damonf suggested, it could be the data source isn't registered ... I know that is a fairly complicated endevor the first time in WS, or it could be the database webuser doesnt exist (its odd that the db name and the user name are the same, is it not?)  I agree that I dont think it is the version of java as it gives u the java at install if I remember correctly (and WS 4 is lmost 3 years old now so unless he's not at Java 2 that really shouldn't be the problem)

HTH