Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added(getting a class not found exception for DB2Driver even though db2jcc4.jar is added as library.)
java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added [message #1385350] Thu, 05 June 2014 18:47 Go to next message
Zachary Marlow is currently offline Zachary MarlowFriend
Messages: 4
Registered: June 2014
Junior Member
I am getting a java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though the db2jcc4.jar is added as a library.

The using class can import com.ibm.db2.jcc.DB2Driver just fine. I also have a test case to test the method in question and it completes successfully.

Any idea what the problem could be?
Re: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added [message #1385392 is a reply to message #1385350] Fri, 06 June 2014 06:38 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3518
Registered: July 2009
Senior Member

Do you have a more complete stack trace? Whatever's trying to find the class isn't using the classpath that was used to launch your Java Application.

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added [message #1386169 is a reply to message #1385392] Sat, 14 June 2014 00:03 Go to previous messageGo to next message
Zachary Marlow is currently offline Zachary MarlowFriend
Messages: 4
Registered: June 2014
Junior Member
Strange. For some reason the db2jcc4.jar isn't getting deployed with the rest of the files. I had to manually add it to glassfish's lib and then do a full stop and clean. This all despite the fact that I have the jar marked for export (if this doesn't have anything to do with making it available to glassfish, would someone please tell me?).
Re: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added [message #1386177 is a reply to message #1386169] Sat, 14 June 2014 06:25 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3518
Registered: July 2009
Senior Member

Marked for export? Where?

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added [message #1386195 is a reply to message #1386177] Sat, 14 June 2014 17:27 Go to previous messageGo to next message
Zachary Marlow is currently offline Zachary MarlowFriend
Messages: 4
Registered: June 2014
Junior Member
In the Java Build Path section of the project properties, under the Order and Export tab, db2jcc4.jar is checked. It was added as an external jar. Another weird thing is that I used to not have to copy any files around. I don't remember what I did right before the problem started happening, so unfortunately I don't know how to reproduce the problem...
Re: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added [message #1386313 is a reply to message #1386195] Mon, 16 June 2014 13:18 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3071
Registered: July 2009
Senior Member
If this is a Dynamic Web project, you should check its Deployment Assembly (in the project properties dialog). The packaged app doesn't necessarily use libraries that are exported from the build path; they must be included in a place that is part of the Deployment Assembly (which is basically the configuration of what Eclipse will package into the app/WAR when it's building and deploying it).
Re: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added [message #1386324 is a reply to message #1386313] Mon, 16 June 2014 14:33 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3518
Registered: July 2009
Senior Member

The Order and Export property page states that "Exported entries are contributed to dependent projects", meaning they're visible to other projects that depend on this one. It has no relation to anything else. If your web application requires a jar that isn't already exposed to all web apps through the app server, you should physically put them into the project's WEB-INF/lib folder if possible--assuming the app server itself is not the one trying to load the driver class.

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added [message #1386464 is a reply to message #1386324] Tue, 17 June 2014 17:41 Go to previous messageGo to next message
Zachary Marlow is currently offline Zachary MarlowFriend
Messages: 4
Registered: June 2014
Junior Member
Thank you two for your replies. I placed the jar in the WEB-INF/lib folder in the project ( and removed it from the build path ), which solved the problem. Is this the preferred way to do things? I did not have to change anything in the Deployment Assembly properties window, which only includes /src ( Source ), WEB-INF/classes ( Deploy Path ); /WebContent ( Source ), / ( Deploy Path ).
Re: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver even though db2jcc4.jar lib added [message #1386473 is a reply to message #1386464] Tue, 17 June 2014 18:18 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3518
Registered: July 2009
Senior Member

It is the preferred way. At runtime, jars in WEB-INF/lib are automatically added to the web app's classpath.

Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Marketplace updates for closed network.
Next Topic:cannot create extension.... blerg
Goto Forum:
  


Current Time: Wed Oct 23 16:41:05 GMT 2019

Powered by FUDForum. Page generated in 0.03471 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top