0

I am attempting to deploy a JSF war file into a jetty sever ( or at least I think I am ). This is a 'learning project' for deploying a JSF application that uses a single JSF managed bean. I have a main that initializes the jetty server.

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();

    }


}

I am unable to tell if this is a conflict the the xml definitions for my pom or web ( or both ) xml files.

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>

The error that occurs during execution: java -verbose:class -cp target/classes:target/dependency/* root/Main

This occurs at server.start() in main:

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)

Most of the advice I see is there is a some kind of conflict with the resource libraries for the app.

I am developing in NetBeans that adds some dependencies for net beans, like glassfish. The end goal is to push this to Heroku. I do not know enough about the libraries to understand why there is a cast taking place at deployment.

Any help is appreciated. Here is my dependency tree:

[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
Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
CaptnJunks
  • 33
  • 10

1 Answers1

0

I made some changes to the pom and web xml files and was able to get the container to launch.

New 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>

Only problem is the XML is failing to render on the page ( new issue ).

I'll do some searching for the new error:

SEVERE: Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI?
CaptnJunks
  • 33
  • 10