【问题标题】:dependencies for jsf (like servlet) prevent application from startingjsf 的依赖项(如 servlet)阻止应用程序启动
【发布时间】:2014-09-18 12:02:02
【问题描述】:

我有一个相当大的 Java 应用程序,它使用一些作业以及大量的 http 和 db 活动。这个应用程序是使用 maven 构建的,有很多依赖项并在 tomcat 6 上运行 - 好消息是,它可以工作。

但是,我现在想添加一些 JSF 功能,即我希望能够从网站手动启动和停止石英作业,因此我在 pom.xml 中激活了另外两个依赖项:

    <!-- to get the servlet container --> 
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>


    <!-- To work with java server faces --> 
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.7</version>
    </dependency>

这样做后,我的应用程序不再出现。它开始了,但我没有看到任何我常用的调试消息,告诉我该应用程序实际上正在做某事。它也没有崩溃。它似乎只是坐在那里,什么都不做。奇怪的是,使用这些依赖关系的 java 类甚至都没有启动。

谁能告诉我,JSF 是什么?我必须做一些故障转移配置吗?还是什么???

我会附上正常启动日志和激活这两个依赖后的日志。

正常启动:

[INFO] Scanning for projects...

[WARNING] 

[WARNING] Some problems were encountered while building the effective model for de.comlineag.snc:SocialNetworkConnector:war:0.2.5-SNAPSHOT

[WARNING] 'dependencies.dependency.systemPath' for ngdbc:ngdbc:jar should use a variable instead of a hard-coded path /Applications/eclipse/plugins/ngdbc.jar @ line 281, column 16

[WARNING] 

[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.

[WARNING] 

[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

[WARNING] 

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building Social Network Connector 0.2.5-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO] 

[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) @ SocialNetworkConnector >>>

[INFO] 

[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ SocialNetworkConnector ---

[debug] execute contextualize

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory 
/Users/chris/Developer/workspace/socialnetworkconnector/src/main/resources

[INFO] 

[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ SocialNetworkConnector ---

[INFO] Nothing to compile - all classes are up to date

[INFO] 

[INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) @ SocialNetworkConnector <<<

[INFO] 

[INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @ SocialNetworkConnector ---

[INFO] Running war on http : // localhost : 8080 / SocialNetworkConnector

[INFO] Using existing Tomcat server configuration at /Users/chris/Developer/workspace/socialnetworkconnector/target/tomcat Jul 26, 2014 11:54:38 PM org.apache.catalina.startup.Embedded start

INFO: Starting tomcat server Jul 26, 2014 11:54:38 PM org.apache.catalina.core.StandardEngine start

INFO: Starting Servlet Engine: Apache Tomcat/6.0.29 Jul 26, 2014 11:54:38 PM org.apache.catalina.core.ApplicationContext log

INFO: Set web app root system property: 'webapp.root' = [/Users/chris/Developer/workspace/socialnetworkconnector/src/main/webapp/]
Jul 26, 2014 11:54:38 PM org.apache.catalina.core.ApplicationContext log

INFO: Initializing log4j from [/Users/chris/Developer/workspace/socialnetworkconnector/src/main/webapp/WEB-INF/log4j.xml]
Jul 26, 2014 11:54:38 PM org.apache.catalina.core.ApplicationContext log

INFO: Initializing Spring root WebApplicationContext

INFO  ContextLoader - Root WebApplicationContext: initialization started

INFO  XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Sat Jul 26 23:54:38 CEST 2014]; root of context hierarchy

INFO  XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

INFO  DefaultLifecycleProcessor - Starting beans in phase 2147483647

INFO  SchedulerFactoryBean - Starting Quartz Scheduler now

INFO  ContextLoader - Root WebApplicationContext: initialization completed in 808 ms

DEBUG GeneralConfiguration - using configuration file from job control src/main/webapp/WEB-INF/GeneralConfiguration.xml
Jul 26, 2014 11:54:39 PM org.apache.coyote.http11.Http11Protocol init

INFO: Initializing Coyote HTTP/1.1 on http-8080
Jul 26, 2014 11:54:39 PM org.apache.coyote.http11.Http11Protocol start

INFO: Starting Coyote HTTP/1.1 on http-8080

DEBUG ComplexXmlConfigurationPersistence - the domain Banking is active true and has priority 0

什么都没有发生的启动:

[INFO] Scanning for projects...

[WARNING] 

[WARNING] Some problems were encountered while building the effective model for de.comlineag.snc:SocialNetworkConnector:war:0.2.5-SNAPSHOT

[WARNING] 'dependencies.dependency.systemPath' for ngdbc:ngdbc:jar should use a variable instead of a hard-coded path /Applications/eclipse/plugins/ngdbc.jar @ line 280, column 16

[WARNING] 

[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.

[WARNING] 

[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

[WARNING] 

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building Social Network Connector 0.2.5-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO] 

[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) @ SocialNetworkConnector >>>

[INFO] 

[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ SocialNetworkConnector ---

[debug] execute contextualize

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory /Users/chris/Developer/workspace/socialnetworkconnector/src/main/resources

[INFO] 

[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ SocialNetworkConnector ---

[INFO] Nothing to compile - all classes are up to date

[INFO] 

[INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) @ SocialNetworkConnector <<<

[INFO] 

[INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @ SocialNetworkConnector ---

[INFO] Running war on http : // localhost : 8080 / SocialNetworkConnector

[INFO] Using existing Tomcat server configuration at /Users/chris/Developer/workspace/socialnetworkconnector/target/tomcat
Jul 26, 2014 11:46:58 PM org.apache.catalina.startup.Embedded start

INFO: Starting tomcat server
Jul 26, 2014 11:46:59 PM org.apache.catalina.core.StandardEngine start
     INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
     Jul 26, 2014 11:46:59 PM org.apache.coyote.http11.Http11Protocol init
     INFO: Initializing Coyote HTTP/1.1 on http-8080
     Jul 26, 2014 11:46:59 PM org.apache.coyote.http11.Http11Protocol start
     INFO: Starting Coyote HTTP/1.1 on http-8080

【问题讨论】:

    标签: java maven tomcat servlets jsf-2


    【解决方案1】:

    您包含的 servlet API 很可能与 tomcat 提供的版本冲突。请改用此依赖项(将 6.0.41 版本替换为您的 tomcat 版本):

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>servlet-api</artifactId>
        <version>6.0.41</version>
        <scope>provided</scope>
    </dependency>
    

    注意范围设置为提供。这意味着 jar 将用于编译您的代码,但不会包含在您的 WAR 文件中。这就是你想要的,因为 tomcat 会在运行时从它的 lib 目录提供你需要的 servlet api jar - 因此没有冲突。

    【讨论】:

      猜你喜欢
      • 2017-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-13
      • 2013-11-12
      • 2018-01-30
      • 1970-01-01
      相关资源
      最近更新 更多