javasql-servermavenintellij-ideajtds

JTDS ClassNotFoundException


I'm tired googling for this error. Please help me. I found suggestuion to add jtds-1.3.1.jar to class path or edit your web.xml.

Please tell me how can I do that? I use Idea, Maven, Gwt and want connect to MS SQL 2008 Express.

java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Drive
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:260)

........ ....

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0

<groupId>gr1</groupId>
<artifactId>art1</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>war</packaging>

<name>search</name>

<properties>
    <gwt.version>2.7.0</gwt.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <web.xml.path>src/main/webapp/WEB-INF/web.xml</web.xml.path>
</properties>


<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>${gwt.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-servlet</artifactId>
        <version>${gwt.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.ow2.asm</groupId>
        <artifactId>asm</artifactId>
        <version>5.0.3</version>
    </dependency>
    <dependency>
        <groupId>com.cloudbees.thirdparty</groupId>
        <artifactId>vijava</artifactId>
        <version>5.5-beta</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
        <version>1.3.1</version>
    </dependency>
</dependencies>

<build>
    <finalName>adsearch</finalName>
</build>

<profiles>
    <!-- LOCAL TOMCAT DEPLOY  -->
    <profile>
        <id>Local Tomcat</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <server>localhost</server>
                        <url>http://localhost:8080/manager/text</url>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                    <version>${gwt.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </build>
    </profile>

    <!-- PRODUCTION TOMCAT DEPLOY  -->
    <profile>
        <id>Production Tomcat</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                    <version>${gwt.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </build>
    </profile>

</profiles>

enter image description here


Solution

  • Check that you are specifying net.sourceforge.jtds.jdbc.Driver and not net.sourceforge.jtds.jdbc.Drive when you do Class.forName(...)