4

我在一个 JAR 中打包了许多复合组件。但是,当在另一个项目(使用 Maven)中使用它们时,Netbeans 编辑器会将红色错误行放在使用复合组件的行下方,即使项目按预期编译和运行。

复合组件 JAR 的文件夹结构如下所示:

compositeComponent.jar
   META-INF
      faces-config.xml
      highcharts-taglib.xml
      MANIFEST.MF
      web.xml
      maven
         // maven stuff.
      resources
          highcharts
             Chart.xhtml
             Series.xhtml
             Tooltip.xml          
   nz
      co
         kevindoran
            highcharts
               example
                  NZPopulationTrend.class


highcharts.taglib.xml看起来像 :

<facelet-taglib version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd">

    <namespace>http://nz.co.kevindoran/highcharts-jsf</namespace>
    <composite-library-name>highcharts</composite-library-name>

</facelet-taglib>


[旁注:faces-config.xmlweb.xml的存在是为了允许通过将文件扩展名更改为 WAR 将“JAR”部署为 WAR(这是为了运行示例)。]


在我当前的项目中,我已经指定了对上述项目的 Maven 依赖项,如下所示:

<dependency>
    <groupId>nz.co.kevindoran</groupId>
    <artifactId>jsf-menu</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency> 

在一个 JSF 页面中,我使用了一个复合组件,如下所示:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:hc="http://nz.co.kevindoran/highcharts-jsf">

....

<hc:TimeChart title="Price Over Time" xLabel="Date" yLabel="Sold Price (NZD)">
    <hc:TimeSeries name="Sold" series="#{cc.attrs.model.priceVsTimeChart.soldSeries}"/>
</hc:TimeChart>  

....
</html>

红色错误行出现在上述所有行下方,并带有消息:“No library found for namespace http://nz.co.kevindoran/highcharts-jsf

如何删除这些错误行?我已经看到了许多针对类似问题的 Netbeans 错误报告,但似乎都已解决。

此错误发生在 Netbeans 7.1、7.2 和 7.3(包括 7.3.1)上。

4

1 回答 1

0

I have absolutely the same problem. In my case it depends on the /src/main/java folder. If it's exist (only in the project and not even in the jar) the project which includes this library shows the "No library found for namespace... " When i remove the "java" folder it works. But then my backing bean class is missed in the jar...

Tried with Netbeans 7.2 and 7.3, maven 2

Solution:

  1. Generate a second project which contains the Java source files. (called: jsf-lib-java)
  2. In jsf-lib project (your composite component project with xhtml) delete the "java" folder and all *.java sources.
  3. add in the jsf-lib pom.xml following configuration:


<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
      <execution>
        <id>unpack</id>
        <phase>generate-resources</phase>
        <goals>
          <goal>unpack</goal>
        </goals>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>com.mycompany.project</groupId>
              <artifactId>jsf-lib-java</artifactId>
              <version>1.0-SNAPSHOT</version>
              <type>jar</type>
              <overWrite>true</overWrite>
              <outputDirectory>src/main/</outputDirectory>
              <includes>**/*.class</includes>
            </artifactItem>
          </artifactItems>
        </configuration>
      </execution>
    </executions>
  </plugin>

That's it. This will generate a "good" jar file with the required *.class files. So it's possible to "trick" Netbeans.

Now i work with this solution. It's a hack but didn't found a better solution.

于 2013-07-02T12:13:07.787 回答