相关疑难解决方法(0)

错误:Servlet Jar未加载...违规类:javax/servlet/Servlet.class

我收到以下错误:

INFO:validateJarFile(C:\ dev\server\tomcat6\webapps Sempedia\WEB-INF\lib\servlet-api.jar) - jar未加载.参见Servlet Spec 2.3,sectoin 9.7.2.违规类:javax/servlet/Servlet.class

那里的现有资源说它是由于与servlet.jar的冲突或在我的情况下命名为servlet-api.jar文件.我已经从/ webapps文件夹中删除了所有其他项目,我已经获取了tomcat6/lib目录中的servlet-api.jar文件,并将其添加到项目构建路径中,所以我看不到它是怎么回事仍然是一场冲突.

当我尝试运行应用程序时,我得到以下堆栈跟踪.

org.apache.jasper.JasperException:无法为JSP编译类:

生成的java文件中的第22行发生错误方法getJspApplicationContext(ServletContext)未定义类型JspFactory

堆栈跟踪:

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler. java:439)org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)org.apache.jasper.compiler.Compiler. compile(Compiler.java:299)org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)org.apache.jasper.servlet. JspServlet.serviceJspFile(JspServlet.java:342)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)javax.servlet.http.HttpServlet.service(httpServlet.java:717)

java dependencies tomcat

30
推荐指数
2
解决办法
8万
查看次数

java.lang.NoClassDefFoundError:javax/el/ELManager

我正在使用Spring Tool Suite在Spring上开发一个webapp.如果我使用IDE在所提供的Pivotal tc服务器上构建和部署应用程序,它就可以正常工作.但是,如果我执行手动"mvn clean package"构建并尝试将其部署到独立的Tomcat服务器(使用最新的Tomcat 7),则会引发以下异常:

2017-08-23 15:24:13 WARN  AnnotationConfigWebApplicationContext:551 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager
2017-08-23 15:24:13 ERROR DispatcherServlet:502 - Context initialization …
Run Code Online (Sandbox Code Playgroud)

java tomcat noclassdeffounderror maven

21
推荐指数
4
解决办法
3万
查看次数

如何使用eclipse + m2eclipse防止重复的servlet jar

我正在使用Eclipse + Maven + m2eclipse在Apache Tomcat中构建和测试Web应用程序.

我在Eclipse中配置了Tomcat服务器,并为我的Web应用程序配置了部署程序集,包括"Maven Dependencies"(Java Build Path Entries专业化).

当我部署并启动服务器时,Tomcat/Catalina总是警告我:

INFO:validateJarFile(/projects/src/main/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/webapp/WEB-INF/lib/servlet-api-2.5.jar) - 罐子没装.请参阅Servlet规范2.3,第9.7.2节.违规类:javax/servlet/Servlet.class

这是因为m2eclipse将servlet-api-2.5视为我项目的依赖项,并将其视为"Maven依赖项"的一部分,并将其作为部署程序集的一部分进行复制,但Tomcat servlet容器有自己的副本,并且不喜欢在课程路径上看到2个副本.

我在我的pom.xml中标记了从我的项目到servlet-api-2.5的依赖关系

<scope>
provided
</scope>
Run Code Online (Sandbox Code Playgroud)

这确实阻止了独立的Maven将servlet-api-2.5打包到我的构建中,但m2eclipse并没有这样看.

(这不是一个大问题,因为警告是无害的,我只在IDE内部测试期间看到它,真正的客户不会看到它,但我仍然想知道如何解决它,因为我喜欢清洁和我喜欢知道事情是如何运作的.)

有没有一种正确的方法告诉m2eclipse不要部署这个文件,或告诉Eclipse不要让m2eclipse对哪些依赖项是运行时依赖项有最终决定权?

我找到https://issues.sonatype.org/browse/MNGECLIPSE-1193其中提到

"Maven Dependencies"容器反映了测试编译时间范围,因此它应该具有范围"提供"的依赖项

m2eclipse maven

14
推荐指数
3
解决办法
2万
查看次数

使用mvn jetty的不同行为:run或jetty standalone

我有一个包含多个模块的项目.

其中两个生成war文件.

  • 一个war文件是一个REST应用程序,它提供了一些资源.

  • Other war文件是一个与REST后端通信的Angular JS Web应用程序(仅限静态内容).

出于演示目的,我想非常轻松地部署两个war文件 mvn jetty:run

出于开发目的,我想从我的IDE(例如Eclipse Servers View)部署它们.

当我通过启动服务器并将war文件复制到部署文件夹手动在单个Jetty服务器(v9.0.7.v20131107)上进行部署时,一切都会出现.

mvn jetty:run两个war文件启动jetty时,部署了,但不知何时REST资源没有部署.

我正在使用Jersey 2.手动部署时,我收到一条日志消息

Nov 14, 2013 10:44:37 PM org.glassfish.jersey.server.ApplicationHandler initialize INFO: Initiating Jersey application, version Jersey: 2.4 2013-10-24 18:25:49...

但是,在开始时未显示此消息mvn jetty:run.所以我认为泽西岛没有踢球.

对于依赖注入我使用spring.


这是/pom.xml中的父pom,带有jetty-maven-plugin配置

<project ...>
...
<build>
    <plugins>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.0.7.v20131107</version>
        <configuration>
            <scanIntervalSeconds>2</scanIntervalSeconds>
            <contextHandlers>
                <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                    <war>module1/target/module1-${project-version}.war</war>
                    <contextPath>/module1</contextPath>
                </contextHandler>
                <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                    <war>module2/target/module2-${project.version}.war</war>
                    <contextPath>/module2/contextPath>
                </contextHandler>
            </contextHandlers>
        </configuration>
    </plugins>
</build>
...
</project>
Run Code Online (Sandbox Code Playgroud)

这是module1(REST模块)的pom

    <parent>
        ...
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>module1</artifactId>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId> …
Run Code Online (Sandbox Code Playgroud)

java jetty maven

5
推荐指数
1
解决办法
1500
查看次数