473,503 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NoClassDefFoundError - please help

15 New Member
I'm using MyEclipse to make a quick one or two use jar utility file to connect to a database and run some updates. I can get everything to compile fine, and create the jar without an issue, but when I execute it from the command prompt I get a NoClassDefFoundError.

Here is the stack trace:

Exception in thread "main" java.lang.NoClassDefFoundError: com/microsoft/jdbc/sq
lserver/SQLServerDriver
at com.dbinterface.DatabaseAccess.execute(DatabaseAcc ess.java:108)
at com.dbinterface.DatabaseAccess.loadSqlfiles(Databa seAccess.java:81)
at com.dbinterface.DatabaseAccess.getFileList(Databas eAccess.java:39)
at com.dbinterface.RunSqlScripts.main(RunSqlScripts.j ava:24)

This is the method where the error is thrown -

Expand|Select|Wrap|Line Numbers
  1. public void execute(StringBuffer sb)
  2.     {
  3.         Connection conn = null;
  4.         Statement stmt = null;
  5.         ResultSet rs = null;
  6.  
  7.         try{
  8.             DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
  9.             conn = DriverManager.getConnection(Constants.DATABASE_NAME, Constants.USERNAME, Constants.PASSWORD);
  10.             stmt = conn.createStatement();            
  11.  
  12.             stmt.execute(sb.toString());
  13.  
  14.             rs.close();
  15.             stmt.close();
  16.             conn.close();            
  17.  
  18.         }
  19.         catch(Exception e)
  20.         {
  21.             e.printStackTrace();
  22.         }        
  23.         finally
  24.         {
  25.             try{
  26.                 if(null != rs)
  27.                     rs.close();
  28.                 if(null != stmt)
  29.                     stmt.close();
  30.                 if(null != conn)
  31.                     conn.close();
  32.             }
  33.             catch(Exception e)
  34.             {
  35.                 e.printStackTrace();
  36.             }
  37.         }
  38.     }
All the forums I find ask about the classpaths so here is my .classpath file created by MyEclipse:

[HTML]<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="C:/temp/dbInterface/sqljdbc.jar"/>
<classpathentry exported="true" kind="lib" path="C:/temp/dbInterface/msbase.jar"/>
<classpathentry exported="true" kind="lib" path="C:/temp/dbInterface/mssqlserver.jar"/>
<classpathentry exported="true" kind="lib" path="C:/temp/dbInterface/msutil.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>[/HTML]

My jar file is located in C:/temp/dbInterface.

This is what my MANIFEST.MF file contains:

Manifest-Version: 1.0
Main-Class: com.dbinterface.RunSqlScripts

Please help. As far as I see my classpaths are correct. I'm not sure what to try from here.

------------UPDATE------------

I just attempted adding the classpaths to my manifest so it would now look like:

Manifest-Version: 1.0
Class-Path: .;C:\temp\dbInterface\msbase.jar;C:\temp\dbInterfa ce\mssqlserver.jar;C:\temp\dbInterface\msutil.jar; C:\temp\dbInterface\sqljdbc.jar
Main-Class: com.dbinterface.RunSqlScripts


Still didn't work. I quite desperate at this point.
Aug 2 '07 #1
3 2198
JosAH
11,448 Recognized Expert MVP
I'm using MyEclipse to make a quick one or two use jar utility file to connect to a database and run some updates. I can get everything to compile fine, and create the jar without an issue, but when I execute it from the command prompt I get a NoClassDefFoundError.

Here is the stack trace:

Exception in thread "main" java.lang.NoClassDefFoundError: com/microsoft/jdbc/sq
lserver/SQLServerDriver
at com.dbinterface.DatabaseAccess.execute(DatabaseAcc ess.java:108)
at com.dbinterface.DatabaseAccess.loadSqlfiles(Databa seAccess.java:81)
at com.dbinterface.DatabaseAccess.getFileList(Databas eAccess.java:39)
at com.dbinterface.RunSqlScripts.main(RunSqlScripts.j ava:24)

This is the method where the error is thrown -

Expand|Select|Wrap|Line Numbers
  1. public void execute(StringBuffer sb)
  2.     {
  3.         Connection conn = null;
  4.         Statement stmt = null;
  5.         ResultSet rs = null;
  6.  
  7.         try{
  8.             DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
  9.             conn = DriverManager.getConnection(Constants.DATABASE_NAME, Constants.USERNAME, Constants.PASSWORD);
  10.             stmt = conn.createStatement();            
  11.  
  12.             stmt.execute(sb.toString());
  13.  
  14.             rs.close();
  15.             stmt.close();
  16.             conn.close();            
  17.  
  18.         }
  19.         catch(Exception e)
  20.         {
  21.             e.printStackTrace();
  22.         }        
  23.         finally
  24.         {
  25.             try{
  26.                 if(null != rs)
  27.                     rs.close();
  28.                 if(null != stmt)
  29.                     stmt.close();
  30.                 if(null != conn)
  31.                     conn.close();
  32.             }
  33.             catch(Exception e)
  34.             {
  35.                 e.printStackTrace();
  36.             }
  37.         }
  38.     }
All the forums I find ask about the classpaths so here is my .classpath file created by MyEclipse:

[HTML]<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="C:/temp/dbInterface/sqljdbc.jar"/>
<classpathentry exported="true" kind="lib" path="C:/temp/dbInterface/msbase.jar"/>
<classpathentry exported="true" kind="lib" path="C:/temp/dbInterface/mssqlserver.jar"/>
<classpathentry exported="true" kind="lib" path="C:/temp/dbInterface/msutil.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>[/HTML]

My jar file is located in C:/temp/dbInterface.

This is what my MANIFEST.MF file contains:

Manifest-Version: 1.0
Main-Class: com.dbinterface.RunSqlScripts

Please help. As far as I see my classpaths are correct. I'm not sure what to try from here.

------------UPDATE------------

I just attempted adding the classpaths to my manifest so it would now look like:

Manifest-Version: 1.0
Class-Path: .;C:\temp\dbInterface\msbase.jar;C:\temp\dbInterfa ce\mssqlserver.jar;C:\temp\dbInterface\msutil.jar; C:\temp\dbInterface\sqljdbc.jar
Main-Class: com.dbinterface.RunSqlScripts


Still didn't work. I quite desperate at this point.
In which .jar file is the class com.microsoft.jdbc.sqlserver.SQLServerDriver stored?
That's the class that can not be found so it definitely is missing in your classpath.

Tip: you can use winzip to inspect your jars.

kind regards,

Jos
Aug 2 '07 #2
NamelessNumberheadMan
15 New Member
In which .jar file is the class com.microsoft.jdbc.sqlserver.SQLServerDriver stored?
That's the class that can not be found so it definitely is missing in your classpath.

Tip: you can use winzip to inspect your jars.

kind regards,

Jos
I did notice one mistake. I was hitting the mssqlserver.jar which is for SQLServer2000. I want to hit sqljdbc.jar which if for SQLServer 2005. So I change my registerDriver to:

Expand|Select|Wrap|Line Numbers
  1. DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
I also eliminated the other jars since I ruled those out.

so my .classpath file now contains:

[HTML]<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="C:/temp/dbInterface/sqljdbc.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>[/HTML]

and my MANIFEST.MF contains:

Manifest-Version: 1.0
Class-Path: .;C:\temp\dbInterface\sqljdbc.jar
Main-Class: com.dbinterface.RunSqlScripts

I'm still getting this error (and yes SQLServerDriver is in the sqljdbc.jar file). Where can I define my classpath? The command line I guess?
-classpath .
-or-
-classpath C:\temp\dbInterface\sqljdbc.jar

These also don't seem to be working. I'm sure it has to be something small that I'm missing. Any ideas?
Aug 2 '07 #3
JosAH
11,448 Recognized Expert MVP
Where can I define my classpath? The command line I guess?
-classpath .
-or-
-classpath C:\temp\dbInterface\sqljdbc.jar

These also don't seem to be working. I'm sure it has to be something small that I'm missing. Any ideas?
You could define your classpath like that but what is the purpose of that xml file
then? It seems as if it defines your classpath in some way but evidently that
xml file isn't processed or even seen.

Try to run your class from the command line and pass the correct classpath
value as you indicated yourself and see what happens.

kind regards,

Jos
Aug 3 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4480
by: Shawn | last post by:
I am getting the following error with a Java Applet being served out by IIS over HTTPS/SSL using a Verisign certificate: java.lang.NoClassDefFoundError: javax/help/HelpSetException at...
3
6509
by: NathanK | last post by:
Hi Guys, im starting out in java and i'm getting the error: Exception in thread "main" java.lang.NoClassDefFoundError: blurf if i run "javac blurf.java", it compiles fine and without any...
2
45733
by: dave | last post by:
(Forgive all caps... they are there to differentiate btw question and code) THIS IS THE ERROR I KEEP GETTING. IT COMPILES BUT WHEN IT RUNS, THE FOLLOWING POPS UP: Exception in thread "main"...
1
47594
by: greg.knaddison | last post by:
Hi, I'm trying to use the httpclient within Jython (see http://jakarta.apache.org/commons/httpclient/ for more information on the httpclient). My Jython version is: Jython 2.1 on...
0
1711
by: shibubaby | last post by:
Hi All, I am trying to compile some embedded SQL using the SQLJ in DB2 environment. My setup is as follows. 1) Fedora Core 5 2)IBM DB2 V8.2 I installed both the client/admin tools in the DB2...
1
976
by: SolBet | last post by:
Hellow there ! I was working on java programming well but today morning, it compiles successfully. However when I try to execute, it throws an exceptions of NoClassDefFoundError: I can not fix...
2
1458
by: teenIce | last post by:
Hi, I try to run my applet and found this error : java.lang.NoClassDefFoundError: check/myapps/mypack/SumError Is this because I defined the classpath wrong?Please help me... Thanks in...
1
2485
by: Nimesh dadhaniya | last post by:
Hi All, I am trying to learn EJB's on my own. I installed the WebLogic Server Trial version and then wrote the Home Interface, Component Interface and the Bean Class. Now I started the WebLogic...
4
5102
by: xtremebass | last post by:
Hi Bytes, i run the sample java code(BarChartDemo.java)which is producing the Bar charts as output if no error in the program, but i got run time error like this, ...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7342
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.