简体   繁体   English

java.lang.NoClassDefFoundError响应Hanlder apache tomcat

[英]java.lang.NoClassDefFoundError ResponseHanlder apache tomcat

I meet at the moment a problem in my project. 目前,我在项目中遇到问题。 I explain the context. 我解释了上下文。 I conceived Web Service with the framework Sparkjava http://sparkjava.com Then I generated one to do war. 我用Sparkjava http://sparkjava.com构想了Web服务,然后生成了一个进行战争的程序。 But when I deploy my application on tomcat Apache and when I start him, I obtain this error OK- Application not deployed for the path of context. 但是,当我在tomcat Apache上部署我的应用程序并启动他时,我收到此错误,确定-没有为上下文路径部署应用程序。 In the file log Localhost, I have this error java.lang.ClassNotFoundException: com.wialon.remote.handlers.ResponseHandler. 在文件日志Localhost中,出现以下错误java.lang.ClassNotFoundException:com.wialon.remote.handlers.ResponseHandler。

pom.xml pom.xml

  <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0      http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>transplusafrica</groupId>
<artifactId>api-delydress</artifactId>
<version>0.0.6</version>
<packaging>war</packaging>
<name>WebServiceDelyDress</name>

<properties>
    <properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.testTarget>1.8</maven.compiler.testTarget>
    <maven.compiler.testSource>1.8</maven.compiler.testSource>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <executions>
                <execution>
                    <id>default-compile</id>
                    <configuration>
                        <showDeprecation>true</showDeprecation>
                        <showWarnings>true</showWarnings>
                        <compilerArguments>
                            <source>${maven.compiler.target}</source>
                            <target>${maven.compiler.source}</target>
                        </compilerArguments>
                    </configuration>
                </execution>
                <execution>
                    <id>default-testCompile</id>
                    <configuration>
                        <showDeprecation>true</showDeprecation>
                        <showWarnings>true</showWarnings>
                        <compilerArguments>
                            <source>${maven.compiler.testTarget}</source>
                            <target>${maven.compiler.testSource}</target>
                        </compilerArguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <webXml>src\main\webapp\WEB-INF\web.xml</webXml>
                <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.sparkjava</groupId>
        <artifactId>spark-core</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.retrofit2</groupId>
        <artifactId>converter-gson</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.retrofit2</groupId>
        <artifactId>retrofit</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>3.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpmime</artifactId>
        <version>4.5.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.0</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.8.0</version>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.9.4</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20160212</version>
    </dependency>
</dependencies>

web.xml web.xml

   <?xml version="1.0" encoding="UTF-8"?>
   <web-app version="3.0"
     xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

<display-name>WebServiceDelyDress</display-name>

<filter>
    <filter-name>SparkFilter</filter-name>
    <filter-class>spark.servlet.SparkFilter</filter-class>
    <init-param>
        <param-name>applicationClass</param-name>
        <param-value>transplus.MainSpark</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>SparkFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

I placed my two bookshops which I use in the file Webapp/lib 我将两个我使用的书店放置在Webapp / lib文件中

The problem is that files .Classe of my two Jar are not created. 问题是没有创建我的两个Jar的.Classe文件。 You can help me to solve this problem. 您可以帮助我解决这个问题。

NB : IDE- Intellij Idea; 注意:IDE- Intellij Idea; Server : Tomcat8 服务器:Tomcat8

While building application maven ignores the dependencies which are added not added by maven. 在构建应用程序时,maven忽略了maven未添加的依赖项。 you have provided the Wilson sdk in your lib path, but once war is prepared it won't have the Wilsonjar in it. 您已在自己的lib路径中提供了Wilson SDK,但一旦战争准备就绪,便不会再包含Wilsonjar。 Try to add it as a maven dependency. 尝试将其添加为Maven依赖项。

If your building this application only for the learning purpose then you can go to m2 folder and you can create a maven dummy maven structure which will work only in your system. 如果您仅出于学习目的构建此应用程序,则可以转到m2文件夹,然后可以创建仅在您的系统中有效的maven虚拟maven结构。 That way you will have the dependency jar always available inside your war. 这样一来,您的战争中将始终有可用的依赖项jar。

Or else go to your tomcat folder and find your application add this jar file inside lib folder of your application directory. 否则转到您的tomcat文件夹并找到您的应用程序,将此jar文件添加到您的应用程序目录的lib文件夹中。

You need to add your bookshop jar files as "local dependency" in pom.xml. 您需要在pom.xml中将书店jar文件添加为“本地依赖项”。

<dependency>
    <groupId>sample</groupId>
    <artifactId>com.sample</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/yourJar.jar</systemPath>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM