我正在尝试将JSF war文件部署到jetty服务器(或者至少我认为我是)。这是一个学习项目'用于部署使用单个JSF托管bean的JSF应用程序。我有一个main来初始化jetty服务器。
package root;
import org.eclipse.jetty.server.Server;
//import org.eclipse.jetty.server.handler.ContextHandler.Context;
import org.eclipse.jetty.webapp.WebAppContext;
public class Main {
public static void main(String[] args) throws Exception {
String portStr = System.getenv("PORT");
int port = (portStr == null) ? 8085 : Integer.parseInt(portStr);
Server server = new Server(port);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
// change the name of the war as needed.
webapp.setWar("target/maven_webType_example-1.0-SNAPSHOT.war");
server.setHandler(webapp);
server.start();
server.join();
}
}
我无法判断这是否与我的pom或web(或两者)xml文件的xml定义发生冲突。
的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>maven_webType_example</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.3.7.v20160115</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.3.7.v20160115</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-deploy</artifactId>
<version>9.3.7.v20160115</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>9.0.0.M3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-jdbc</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.13</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
<!--<configuration>
<artifactItems>
<artifactItem>
<groupId>com.githum.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<destFileName>webapp-runner.jar</destFileName>
<version>7.0.27.1</version>
</artifactItem>
</artifactItems>
</configuration>-->
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<assembleDirectory>target</assembleDirectory>
<generateRepository>true</generateRepository>
<programs>
<program>
<mainClass>root.Main</mainClass>
<name>webapp</name>
</program>
</programs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.forceLoadConfiguration</param-name>
<param-value>true</param-value>
</context-param>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
<!--<prefer-application-resources>
<resource-name>javax.faces.*</resource-name>
<resource-name>com.sun.faces.*</resource-name>
<resource-name>com.bea.faces.*</resource-name>
<resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
<resource-name>META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider</resource-name>
</prefer-application-resources>-->
</container-descriptor>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
执行期间发生的错误: java -verbose:class -cp target / classes:target / dependency / * root / Main
这发生在main中的server.start():
SEVERE: Critical error during deployment:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED!
com.sun.faces.vendor.WebContainerInjectionProvider cannot be cast to com.sun.faces.spi.InjectionProvider
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:453)
我看到的大多数建议是与应用程序的资源库存在某种冲突。
我在NetBeans中开发,为net beans添加了一些依赖项,比如glassfish。最终目标是将其推向Heroku。我对图书馆了解不足以了解为什么在部署时会发生演员表。
感谢任何帮助。这是我的依赖树:
[INFO]
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ maven_webType_example ---
[INFO] com.example:maven_webType_example:war:1.0-SNAPSHOT
[INFO] +- org.eclipse.jetty:jetty-server:jar:9.3.7.v20160115:compile
[INFO] | +- org.eclipse.jetty:jetty-http:jar:9.3.7.v20160115:compile
[INFO] | | \- org.eclipse.jetty:jetty-util:jar:9.3.7.v20160115:compile
[INFO] | \- org.eclipse.jetty:jetty-io:jar:9.3.7.v20160115:compile
[INFO] com.example:maven_webType_example:war:1.0-SNAPSHOT
[INFO] +- org.eclipse.jetty:jetty-server:jar:9.3.7.v20160115:compile
[INFO] | +- org.eclipse.jetty:jetty-http:jar:9.3.7.v20160115:compile
[INFO] | | \- org.eclipse.jetty:jetty-util:jar:9.3.7.v20160115:compile
[INFO] | \- org.eclipse.jetty:jetty-io:jar:9.3.7.v20160115:compile
[INFO] +- org.eclipse.jetty:jetty-webapp:jar:9.3.7.v20160115:compile
[INFO] | +- org.eclipse.jetty:jetty-xml:jar:9.3.7.v20160115:compile
[INFO] | \- org.eclipse.jetty:jetty-servlet:jar:9.3.7.v20160115:compile
[INFO] | \- org.eclipse.jetty:jetty-security:jar:9.3.7.v20160115:compile
[INFO] | \- org.eclipse.jetty:jetty-security:jar:9.3.7.v20160115:compile
[INFO] +- org.eclipse.jetty:jetty-deploy:jar:9.3.7.v20160115:compile
[INFO] +- org.apache.tomcat:tomcat-jasper:jar:9.0.0.M3:compile
[INFO] | +- org.apache.tomcat:tomcat-servlet-api:jar:9.0.0.M3:compile
[INFO] | +- org.apache.tomcat:tomcat-juli:jar:9.0.0.M3:compile
[INFO] | +- org.apache.tomcat:tomcat-jsp-api:jar:9.0.0.M3:compile
[INFO] | +- org.apache.tomcat:tomcat-el-api:jar:9.0.0.M3:compile
[INFO] | +- org.eclipse.jdt.core.compiler:ecj:jar:4.5:compile
[INFO] | +- org.apache.tomcat:tomcat-jasper-el:jar:9.0.0.M3:compile
[INFO] | +- org.apache.tomcat:tomcat-api:jar:9.0.0.M3:compile
[INFO] | \- org.apache.tomcat:tomcat-util-scan:jar:9.0.0.M3:compile
[INFO] | \- org.apache.tomcat:tomcat-util:jar:9.0.0.M3:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] +- javax:javaee-web-api:jar:7.0:compile
[INFO] +- javax:javaee-api:jar:7.0:compile
[INFO] | \- com.sun.mail:javax.mail:jar:1.5.0:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- com.heroku.sdk:heroku-jdbc:jar:0.1.1:compile
[INFO] +- org.glassfish:javax.faces:jar:2.2.13:compile
[INFO] +- com.sun.faces:jsf-impl:jar:2.1.2:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] \- taglibs:standard:jar:1.1.2:compile
答案 0 :(得分:0)
我对pom和web xml文件进行了一些更改,并且能够启动容器。
新的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>maven_webType_example</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.3.7.v20160115</version>
<optional>true</optional>
</dependency>
<!--<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp-2.1</artifactId>
<version>7.5.4.v20111024</version>
</dependency>-->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.3.7.v20160115</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-deploy</artifactId>
<version>9.3.7.v20160115</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-digester3</artifactId>
<version>3.2</version>
</dependency>
<!--<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>9.0.0.M3</version>
</dependency>-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2_15</version>
</dependency>
<dependency>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-jdbc</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>
<!--<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.13</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.13</version>
</dependency>-->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.githum.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<destFileName>webapp-runner.jar</destFileName>
<version>7.0.27.1</version>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<assembleDirectory>target</assembleDirectory>
<generateRepository>true</generateRepository>
<programs>
<program>
<mainClass>root.Main</mainClass>
<name>webapp</name>
</program>
</programs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
new web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.el.expressionFactory</param-name>
<param-value>javax.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.forceLoadConfiguration</param-name>
<param-value>true</param-value>
</context-param>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
<!--<prefer-application-resources>
<resource-name>javax.faces.*</resource-name>
<resource-name>com.sun.faces.*</resource-name>
<resource-name>com.bea.faces.*</resource-name>
<resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
<resource-name>META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider</resource-name>
</prefer-application-resources>-->
</container-descriptor>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
唯一的问题是XML无法在页面上呈现(新问题)。
我会搜索新的错误:
SEVERE: Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI?