2017-04-17 62 views
0

我奮力解決以下異常:不斷得到拋出java.lang.ClassNotFoundException:com.sun.faces.config.ConfigureListener

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 [email protected]a 
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,我添加了所有必需的依賴項。

+0

參考這個問題(http://stackoverflow.com/questions/22938689/info-no-spring-webapplicationinitializer-types-detected-on-classpath) –

+0

@vikram 1)請添加整個pom.xml這裏。 2)你在你的項目中使用JSF嗎? –

+0

@PratikShah我沒有在我的項目中使用JSF。 PFB pom.xml –

回答

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("/"); 
    } 
} 
0

如果錯誤是說,類沒有找到,那麼它實際上是說,類不能被JVM加載,因爲JVM無法在您的類路徑中找到該類。

然後,你需要使用Maven再次生成項目,以創建.class文件JVM的,

或者在此之前,嘗試從遠程Maven倉庫項目的依賴再次拉進你的本地Maven倉庫,然後執行maven構建項目以填充.class文件。

希望這可以幫助。