8
回答
maven 运行 jetty 出错
终于搞明白,存储TCO原来是这样算的>>>   

有用到 jsp  所以加上 这几个 jar  然后直接用jetty 

运行 报错 java.lang.NoClassDefFoundError: javax/servlet/HttpConstraintElement

去掉 下面几个 jar 就正常了 不过需要 jsp 报错 有啥 解决方法 1天了没搞定


<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>org.apache.taglibs.standard.glassfish</artifactId>
<version>1.2.0.v201112081803</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
<version>2.5.0.v201103041518</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet.jsp</artifactId>
<version>2.1.0.v201105211820</version>
<scope>provided</scope>
</dependency>



Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/HttpConstraintElement

at com.jfinal.server.JettyServer.doStart(JettyServer.java:87)
at com.jfinal.server.JettyServer.start(JettyServer.java:64)
at com.jfinal.core.JFinal.start(JFinal.java:159)
at com.jayqqaa12.MyConfig.main(MyConfig.java:168)
Caused by: java.lang.ClassNotFoundException: javax.servlet.HttpConstraintElement
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 4 more

举报
12叔
发帖于3年前 8回/3K+阅
共有8个答案 最后回答: 3年前

引用来自“JFinal”的评论

缺包,将正确的包依赖补充完全即可打完收工,注意包的版本和可用性,有些maven库中的包并非官方发布
原来 jetty8 要用 servlet 3  失误了  

还有个 问题  start的时候 要扫描jar 但是 扫描不到

E:\workspace\jump-Jetty\src\main\webapp\WEB-INF\lib

不过我直接复制到 webapp 里面也扫描不到


servet-api.jar是部署在那个容器里的? 如果是tomcat好像不要加,如果不是要加进来.

这种有jar包.导入正确还报.一般是jar冲突了.

这个是我运行Jetty的Maven的pom.xml,好像没你的复杂,用的是servlet api 2.5

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.tur</groupId>
    <artifactId>Jetty</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Jetty Maven Webapp</name>
    <url>http://maven.apache.org</url>
    
    <dependencies>
        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>9.2.2.v20140723</version>
        </dependency>

        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.20</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>Jetty</finalName>

        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.2.v20140723</version>
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>



顶部