不断获取java.lang.ClassNotFoundException:com.sun.faces.config.ConfigureListener

时间:2017-04-17 03:31:24

标签: java spring hibernate maven

我正在努力解决以下异常:

INFO: No Spring WebApplicationInitializer types detected on classpath
Apr 17, 2017 8:48:01 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.apache.tomcat.util.descriptor.web.ApplicationListener@1e856aa
java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1465)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1310)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:531)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:513)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:141)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4756)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5288)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1390)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1380)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Apr 17, 2017 8:48:01 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Apr 17, 2017 8:48:01 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart

我正在使用maven并添加了以下依赖项来解决这个问题,但没有得到结果,仍面临同样的问题。

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.1</version>
</dependency>

<dependency>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>jstl-api</artifactId>
    <version>1.2</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
</dependency>

我已经添加了maven依赖项。对于Spring和Hibernate,我添加了所有必需的依赖项。

2 个答案:

答案 0 :(得分:0)

我认为问题不在于您的依赖项。我也是新手,但我认为这可能对你有所帮助:

@Configuration
public class SpringWebAppInitializer implements WebApplicationInitializer{

     @Override
     public void onStartup(ServletContext sc) throws ServletException {
         AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
         context.register(ApplicationContextConfig.class);

         ServletRegistration.Dynamic dispatcher = sc.addServlet("dispatcher", new DispatcherServlet(context));
         dispatcher.setLoadOnStartup(1);
         dispatcher.addMapping("/");
     }
}

答案 1 :(得分:0)

如果错误表明找不到该类,那么它实际上是说JVM无法加载该类,因为JVM无法在类路径中找到该类。

然后你需要使用maven再次构建项目,以便为你的JVM创建.class文件,

或者在此之前,尝试将项目依赖项从远程maven存储库再次提取到本地maven存储库,然后执行maven构建项目以填充.class文件。

希望这会有所帮助。