Primefaces - 没有taglibrary存在 - configurated pom.xml

时间:2014-04-08 16:16:32

标签: xml eclipse maven jsf primefaces

我收到了错误

Warning: This page calls for XML namespace http://primefaces.prime.com.tr/ui declared with prefix p but no taglibrary exists for that namespace

我的问题类似于这个问题: Link to Questtion

我包含在pom.xml文件中

  <repositories>
        <repository>  
            <id>prime-repo</id>  
            <name>PrimeFaces Maven Repository</name>  
            <url>http://repository.primefaces.org</url>  
            <layout>default</layout>  
        </repository>
    </repositories>

...
<dependencyManagement>
...
   <dependency>
     <groupId>org.primefaces</groupId>
     <artifactId>primefaces</artifactId>
     <version>3.5</version>
   </dependency>
</dependencyManagement>

xhtml页面importData如下所示:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:p="http://primefaces.org/ui">
<h:head><title>Test</title></h:head>
<h:body>
  <p:panel header="Test" toggleable="true">
    <h:outputText value="Hallo, hier spricht PrimeFaces!"/>
  </p:panel>
</h:body>
</html>

我使用了Tomcat 7,Eclipse Kepler和Maven。有什么想法吗?

更新: 如果我在<dependencies>中写下表面依赖性,我会得到错误

Path ./WEB-INF/resources/primefaces-aristo does not start with a "/" character

Eclipse在konsole中写道:

Apr 09, 2014 10:19:23 AM com.sun.faces.config.AnnotationScanner processClassList
Schwerwiegend: Unable to load annotated class: WEB-INF.classes. [...], reason: java.lang.NoClassDefFoundError: [...] (wrong name: [...])

Apr 09, 2014 10:19:24 AM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
Schwerwiegend: Error Rendering View[/login.xhtml]
java.lang.IllegalArgumentException: Path ./WEB-INF/resources/primefaces-aristo does not start with a "/" character
    at org.apache.catalina.core.ApplicationContext.getResourcePaths(ApplicationContext.java:610)
    at org.apache.catalina.core.ApplicationContextFacade.getResourcePaths(ApplicationContextFacade.java:181)
    at com.sun.faces.context.ExternalContextImpl.getResourcePaths(ExternalContextImpl.java:520)
    at com.sun.faces.application.resource.WebappResourceHelper.findLibrary(WebappResourceHelper.java:190)
    at com.sun.faces.application.resource.ResourceManager.findLibrary(ResourceManager.java:458)
    at com.sun.faces.application.resource.ResourceManager.getResourceInfo(ResourceManager.java:286)
    at com.sun.faces.application.resource.ResourceManager.doLookup(ResourceManager.java:280)
    at com.sun.faces.application.resource.ResourceManager.findResource(ResourceManager.java:214)
    at com.sun.faces.application.resource.ResourceManager.findResource(ResourceManager.java:180)
    at com.sun.faces.application.resource.ResourceHandlerImpl.createResource(ResourceHandlerImpl.java:201)
    at com.sun.faces.application.resource.ResourceHandlerImpl.createResource(ResourceHandlerImpl.java:181)
    at javax.faces.application.ResourceHandlerWrapper.createResource(ResourceHandlerWrapper.java:112)
    at org.primefaces.application.PrimeResourceHandler.createResource(PrimeResourceHandler.java:57)
    at org.primefaces.renderkit.HeadRenderer.encodeTheme(HeadRenderer.java:115)
    at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:72)
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1894)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:451)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

Apr 09, 2014 10:19:24 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: JSF1073: java.lang.IllegalArgumentException erfasst während Verarbeitung von RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=Path ./WEB-INF/resources/primefaces-aristo does not start with a "/" character
Apr 09, 2014 10:19:24 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: Path ./WEB-INF/resources/primefaces-aristo does not start with a "/" character
java.lang.IllegalArgumentException: Path ./WEB-INF/resources/primefaces-aristo does not start with a "/" character
    at org.apache.catalina.core.ApplicationContext.getResourcePaths(ApplicationContext.java:610)
    at org.apache.catalina.core.ApplicationContextFacade.getResourcePaths(ApplicationContextFacade.java:181)
    at com.sun.faces.context.ExternalContextImpl.getResourcePaths(ExternalContextImpl.java:520)
    at com.sun.faces.application.resource.WebappResourceHelper.findLibrary(WebappResourceHelper.java:190)
    at com.sun.faces.application.resource.ResourceManager.findLibrary(ResourceManager.java:458)
    at com.sun.faces.application.resource.ResourceManager.getResourceInfo(ResourceManager.java:286)
    at com.sun.faces.application.resource.ResourceManager.doLookup(ResourceManager.java:280)
    at com.sun.faces.application.resource.ResourceManager.findResource(ResourceManager.java:214)
    at com.sun.faces.application.resource.ResourceManager.findResource(ResourceManager.java:180)
    at com.sun.faces.application.resource.ResourceHandlerImpl.createResource(ResourceHandlerImpl.java:201)
    at com.sun.faces.application.resource.ResourceHandlerImpl.createResource(ResourceHandlerImpl.java:181)
    at javax.faces.application.ResourceHandlerWrapper.createResource(ResourceHandlerWrapper.java:112)
    at org.primefaces.application.PrimeResourceHandler.createResource(PrimeResourceHandler.java:57)
    at org.primefaces.renderkit.HeadRenderer.encodeTheme(HeadRenderer.java:115)
    at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:72)
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1894)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:451)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

UPADTE: 如果我在<dependency><dependencyManagement>

中放置了要素,我也会出错

更新: 我想我知道决议。来自maven的Taglibary消失在Web资源中 - &gt; Tag Libaries文件夹。但我添加了taglibary,如下所示。

这是完整的pom.xml

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

  <!-- The Basics -->
  <groupId>AssetDB</groupId>
  <artifactId>AssetDB</artifactId>
  <version>1.3.0</version>
  <packaging>war</packaging>

  <!-- Build Settings -->
    <build>
       <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <version>3.1</version>
               <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                </configuration>
            </plugin>                   
        </plugins>
    </build>
      <dependencies>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>2.11.3</version>
      </dependency>

     <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
     </dependency>

    <dependency>
      <groupId>org.apache.myfaces.core</groupId>
      <artifactId>myfaces-api</artifactId>
      <version>2.1.8</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.myfaces.core</groupId>
      <artifactId>myfaces-impl</artifactId>
      <version>2.1.8</version>
    </dependency>

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.6</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.faces</artifactId>
        <version>2.2.4</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>4.0</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>
    <dependency>
    <groupId>org.primefaces.themes</groupId>
    <artifactId>aristo</artifactId>
    <version>1.0.1</version>
    </dependency>
      </dependencies>

   <repositories>
        <repository>  
            <id>prime-repo</id>  
            <name>PrimeFaces Maven Repository</name>  
            <url>http://repository.primefaces.org</url>  
            <layout>default</layout>  
        </repository>
  </repositories>

</project>

3 个答案:

答案 0 :(得分:2)

您可以尝试在<dependencies>手动设置主题。

<dependency>
    <groupId>org.primefaces.themes</groupId>
    <artifactId>aristo</artifactId>
    <version>1.0.1</version>
</dependency>

或尝试其他主题,例如bootstrap

答案 1 :(得分:0)

尝试更改您的声明标签库:

xmlns="http://www.w3.org/1999/xhtml" 
xmlns:h="http://java.sun.com/jsf/html" 
xmlns:p="http://primefaces.org/ui"

答案 2 :(得分:0)

我解决了这个问题。 我曾在web.xml中写过。现在我删除了他的。

 <context-param>
  <param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
  <param-value>./WEB-INF/resources</param-value>
 </context-param>

Web-App查看此文件夹以查找primefaces资源。 我不需要依赖aristo或bootstrap。谢谢你的帮助。

Maven-build clean install -X -e帮助我删除<depedendyManagement>。谢谢你的回答。