【问题标题】:Composite components in an external JAR are not recognized in NetbeansNetbeans 无法识别外部 JAR 中的复合组件
【发布时间】:2013-06-12 10:00:07
【问题描述】:

我在一个 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)上。

【问题讨论】:

标签: java jsf jakarta-ee netbeans jar


【解决方案1】:

我也有同样的问题。在我的情况下,它取决于 /src/main/java 文件夹。如果它存在(仅在项目中,甚至在 jar 中),包含此库的项目将显示“No library found for namespace...” 当我删除“java”文件夹时它可以工作。但是后来我的支持 bean 类在 jar 中丢失了......

尝试使用 Netbeans 7.2 和 7.3,maven 2

解决方案:

  1. 生成包含 Java 源文件的第二个项目。 (称为:jsf-lib-java)
  2. 在 jsf-lib 项目(您的带有 xhtml 的复合组件项目)中,删除“java”文件夹和所有 *.java 源。
  3. 在jsf-lib pom.xml中添加如下配置:


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

就是这样。这将生成一个带有所需 *.class 文件的“好”jar 文件。所以有可能“欺骗”Netbeans。

现在我使用这个解决方案。这是一个 hack,但没有找到更好的解决方案。

【讨论】:

    猜你喜欢
    • 2014-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    相关资源
    最近更新 更多