2

I am developing a web application and have hit a wall and could use some advice. So the application was written by a coworker who is no longer at our company. They wrote a web application for Apache Tomcat with Java and Javascript in the back end. The application makes use of the JDBC api to interface with a SQL Server database. This person did all the development in Eclipse and running it this way.

I am trying to take this web application and move it to a server. I attempted this by using Eclipse to export a WAR file and then placing this within the Tomcat webapps folder. Then when I started Tomcat the program was extracted. So far so good. The website comes up and works well. However, when I try to access the pages which rely upon database info everything is coming up NULL. I went through the Tomcat logs and found that in the standard out the following message was given:

ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

I had assumed that the WAR file would include all dependencies but I am guessing that probably this is not the case. If anyone is experienced, is this what has happened? If anyone out there is aware, is there a way to tell Eclipse to do this? Otherwise, what is my option? I am not a Java dev and so I would not know how to install JDBC if needed.

Any help is appreciated. Mike

Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142
Michael Bauer
  • 183
  • 4
  • 15
  • You don't seem to have the JDBC driver jar installed. Do you have it in the tomcat's lib folder? May be your co-worker had it installed on his/her tomcat. – Bhesh Gurung Oct 15 '12 at 02:56
  • what build system are you using to build the war file? Ant/Maven/something else? – Vikdor Oct 15 '12 at 03:08

2 Answers2

1

You can do the following

  1. Go to Microsoft JDBC Driver download page and download the JDBC driver and install it to a location.
  2. Open the .war file using a zip utility like 7-zip or winzip.
  3. Copy the sqljdbc.jar from the sqljdb_4.0/enu directory where you installed the downloaded JDBC driver and paste it in WEB-INF/lib of the extracted war file.
  4. Zip it back as .war file and deploy it again.

This will get the application running.

If you want to fix this permanently, then you should add the stop to include sqljdbc.jar to your WEB-INF/lib while building war file, in your build system, i.e. in build.xml if you are using ANT or in your Maven's pom.xml under dependencies section for this particular dependency.

Vikdor
  • 23,934
  • 10
  • 61
  • 84
  • Thanks for the response. This seemed to fix my DJBC problem. Also to clarify for others regarding step 4, I used the following command to zip it back again: "jar cf ../app.war *". If the JDK is not in your path then you may need to supply the fully qualified extension. – Michael Bauer Oct 15 '12 at 20:21
0

You don't need to do the "Export WAR > copy to tomcat > start tomcat" manually, you could configure eclipse to do the deploy directly in your tomcat installation, firts double click tomcat server, and then select "Use tomcat installation" in the "Server Locations" section. enter image description here

Make sure that your application contains the SQLServer JDBC driver (sqljdbc4.jar) in your project WebContent/WEB-INF/lib directory (assuming your coworker used the Eclipse "Dynamic Web Project" for the project layout), if not, download from here, unzip and copy it to the mentioned folder, the next time you start tomcat, it will automatically add it for you.

If the project uses the maven project layout (there is a file named pom.xml in the project root folder), use the following instructions to install the dependency in your local repository (there are some disagreements between Maven and Microsoft about licensing and redistribution of the driver, so there is no repo)

Community
  • 1
  • 1
higuaro
  • 15,730
  • 4
  • 36
  • 43