4

I have packaged a number of composite components in a JAR. However, when using them in another project (using Maven), Netbeans editor puts red error lines under lines which use the composite component, even though the project compiles and runs as expected.

The folder structure for the composite component JAR look like:

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


The highcharts.taglib.xml looks like:

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


[Side note: The faces-config.xml and web.xml are present to allow the 'JAR' to be deployed as a WAR by changing the file extension to WAR (this is to done to run the examples).]


In my current project, I have specify a Maven dependency on the above project like so:

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

In a JSF page, I use on of the composite components like so:

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

Red error lines appear under all lines above, with message: "No library found for namespace http://nz.co.kevindoran/highcharts-jsf"

How do I get these error lines to be removed? I have seen many Netbeans bug reports for similar issues, but all seem resolved.

This error occurs on Netbeans 7.1, 7.2 and 7.3 (including 7.3.1).

Kevin
  • 4,070
  • 4
  • 45
  • 67

1 Answers1

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.

K_B
  • 31
  • 3