2017-01-07 15 views
1

Я пытаюсь получить BootsFaces, OmniFaces и PrimeFaces, работающих вместе с Tomcat 9:OmniFaces ClassNotFoundException CombinedResourceHandler

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/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 

<groupId>homepage</groupId> 
<artifactId>xxx</artifactId> 
<version>1.0-SNAPSHOT</version> 

<name>homepage xxx</name> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 

    <servlet.version>3.1.0</servlet.version> 
    <jsf.version>2.2.13</jsf.version> 
    <primefaces.version>6.0</primefaces.version> 
    <bootfaces.version>1.0.1</bootfaces.version> 
    <omnifaces.version>2.1</omnifaces.version> 

</properties> 

<dependencies> 
    <!-- Servlet --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>javax.servlet-api</artifactId> 
     <version>${servlet.version}</version> 
     <scope>provided</scope> 
    </dependency> 
    <!-- JSF --> 
    <dependency> 
     <groupId>com.sun.faces</groupId> 
     <artifactId>jsf-api</artifactId> 
     <version>${jsf.version}</version> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.faces</groupId> 
     <artifactId>jsf-impl</artifactId> 
     <version>${jsf.version}</version> 
     <scope>compile</scope> 
    </dependency> 
    <!-- PrimeFaces --> 
    <dependency> 
     <groupId>org.primefaces</groupId> 
     <artifactId>primefaces</artifactId> 
     <version>${primefaces.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.primefaces.extensions</groupId> 
     <artifactId>primefaces-extensions</artifactId> 
     <version>6.0.0</version> 
     <scope>compile</scope> 
    </dependency> 
    <!-- Bootsfaces --> 
    <dependency> 
     <groupId>net.bootsfaces</groupId> 
     <artifactId>bootsfaces</artifactId> 
     <version>${bootfaces.version}</version> 
     <scope>compile</scope> 
    </dependency> 
    <!-- Omnifaces --> 
    <dependency> 
     <groupId>org.omnifaces</groupId> 
     <artifactId>omnifaces</artifactId> 
     <version>${omnifaces.version}</version> 
     <scope>compile</scope> 
    </dependency> 
</dependencies> 

web.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app 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" 
    version="3.1"> 

<welcome-file-list> 
    <welcome-file>helloworld.xhtml</welcome-file> 
</welcome-file-list> 

<context-param> 
    <param-name>primefaces.THEME</param-name> 
    <param-value>bootstrap</param-value> 
</context-param> 
<context-param> 
    <param-name>primefaces.FONT_AWESOME</param-name> 
    <param-value>true</param-value> 
</context-param> 
<context-param> 
    <param-name>BootsFaces_USETHEME</param-name> 
    <param-value>default</param-value> 
</context-param> 

лица-config.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<faces-config 
    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-facesconfig_2_2.xsd" 
    version="2.2"> 

<application> 
    <resource-handler>org.omnifaces.resourcehandler.CombinedResourceHandler</resource-handler> 
</application> 

И я получаю следующее StackTrace при попытке запустить свой проект на Tomcat 9:

Cause: Unable to create a new instance of 'org.omnifaces.resourcehandler.CombinedResourceHandler': javax.faces.FacesException: org.omnifaces.resourcehandler.CombinedResourceHandler 
at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(AbstractConfigProcessor.java:378) 
at com.sun.faces.config.processor.ApplicationConfigProcessor.setResourceHandler(ApplicationConfigProcessor.java:856) 
at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:335) 
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152) 
at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:137) 
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:152) 
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:239) 
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:439) 
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227) 
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4715) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) 
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) 
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) 
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1702) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) 
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) 
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) 
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:482) 
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) 
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) 
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) 
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) 
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) 
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) 
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) 
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324) 
at sun.rmi.transport.Transport$1.run(Transport.java:200) 
at sun.rmi.transport.Transport$1.run(Transport.java:197) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.rmi.transport.Transport.serviceCall(Transport.java:196) 
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) 
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) 
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) 
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) 

Caused by: javax.faces.FacesException: org.omnifaces.resourcehandler.CombinedResourceHandler 
at com.sun.faces.config.processor.AbstractConfigProcessor.loadClass(AbstractConfigProcessor.java:428) 
at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(AbstractConfigProcessor.java:301) 
... 53 more 

Caused by: java.lang.ClassNotFoundException: org.omnifaces.resourcehandler.CombinedResourceHandler 
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275) 
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Class.java:348) 
at com.sun.faces.util.Util.loadClass(Util.java:364) 
at com.sun.faces.config.processor.AbstractConfigProcessor.loadClass(AbstractConfigProcessor.java:420) 
... 54 more 

Я также попытался использовать более старые версии OmniFaces, без успеха.

+0

Исключение выглядит очень ясно. Что вы исследовали? Действительно ли это на пути к классам? 100% уверены? Это работает, если вы удалите PrimeFaces? BootsFaces? И то и другое? – Kukeltje

ответ

4

Ваш pom.xml не заполнен. Если вы использовали точно такой же pom.xml, как указано выше, вы получили простой файл jar вместо военного файла, а Maven не добавила ни одну из библиотек в папку WEB-INF/lib.

Чтобы исправить это, выполните следующие действия:

  • задающие <packaging>.
  • добавить плагин Maven war
  • и - если вы используете Eclipse - укажите версию Java, которую вы хотите использовать. В противном случае Eclipse предполагает, что вы используете Java 1.5, который не будет работать с BootsFaces.

Кстати, вам не нужен CombinedResourceHandler. Это просто отличный инструмент для ускорения вашего приложения до прибытия http/2.

Ради удобства, вот полный работает 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/xsd/maven-4.0.0.xsd">                       
    <modelVersion>4.0.0</modelVersion>                          

    <groupId>homepage</groupId>                            
    <artifactId>xxx</artifactId>                           
    <version>1.0-SNAPSHOT</version>                           
    <packaging>war</packaging>                            


    <name>homepage xxx</name>                            

    <properties>                               
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>                 

     <servlet.version>3.1.0</servlet.version>                       
     <jsf.version>2.2.13</jsf.version>                         
     <primefaces.version>6.0</primefaces.version>                      
     <bootfaces.version>1.0.1</bootfaces.version>                      
     <omnifaces.version>1.12.1</omnifaces.version>                      
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>                 
     <maven.compiler.source>1.7</maven.compiler.source>                     
     <maven.compiler.target>1.7</maven.compiler.target>                     
     <maven.compiler.testSource>1.7</maven.compiler.testSource>                   
     <maven.compiler.testTarget>1.7</maven.compiler.testTarget>                   
    </properties>                               

    <dependencies>                               
     <dependency>                              
      <groupId>javax.servlet</groupId>                        
      <artifactId>javax.servlet-api</artifactId>                      
      <version>${servlet.version}</version>                       
      <scope>provided</scope>                           
     </dependency>                              
     <dependency>                              
      <groupId>com.sun.faces</groupId>                        
      <artifactId>jsf-api</artifactId>                        
      <version>${jsf.version}</version>                        
      <scope>compile</scope>                           
     </dependency>                              
     <dependency>                              
      <groupId>com.sun.faces</groupId>                        
      <artifactId>jsf-impl</artifactId>                        
      <version>${jsf.version}</version>                        
      <scope>compile</scope>                           
     </dependency>                              
     <dependency>                              
      <groupId>org.primefaces</groupId>                        
      <artifactId>primefaces</artifactId>                        
      <version>${primefaces.version}</version>                      
      <scope>compile</scope>                           
     </dependency>                              
     <dependency>                              
      <groupId>org.primefaces.extensions</groupId>                     
      <artifactId>primefaces-extensions</artifactId>                     
      <version>6.0.0</version>                          
      <scope>compile</scope>                           
     </dependency>                              
     <dependency>                              
      <groupId>net.bootsfaces</groupId>                        
      <artifactId>bootsfaces</artifactId>                        
      <version>${bootfaces.version}</version>                       
      <scope>compile</scope>                           
     </dependency>                              
     <dependency>                              
      <groupId>org.omnifaces</groupId>                        
      <artifactId>omnifaces</artifactId>                        
      <version>${omnifaces.version}</version>                       
      <scope>compile</scope>                           
     </dependency>                              
    </dependencies>                               
    <build>                                 
     <plugins>                               
      <plugin>                              
       <groupId>org.apache.maven.plugins</groupId>                     
       <artifactId>maven-war-plugin</artifactId>                     
       <version>2.5</version>                          
      </plugin>                              
     </plugins>                               
    </build>                                
</project>