9

I tested to deploy this example from PrimeFaces.

I don't know why it's not working. I get this error message:

Warning: This page calls for xml namespace http://primefaces.org/ui declared with prefix p but no taglibtrary exist for that namespace

I follow this tutorial to properly install the jar. I downloaded the Primefaces jar file and I added it to the resources directory into the WAR file.

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>3.3</version>
        <type>jar</type>
    </dependency>

I also added the Primefaces.jar file into Glassfish's /modules directory and I added the name of the module into default-web.xml file. It's not working.

What am I missing?

EDIT 2 I was correct the POM file is the problem:

<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>com.DX_57</groupId>
    <artifactId>History-Module-57</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>History-Module-57</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>       
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>  
            <groupId>org.primefaces</groupId>  
            <artifactId>primefaces</artifactId>  
            <version>3.3</version>  
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>4.2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.compendium</artifactId>
            <version>4.2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>osgi-cdi-api</artifactId>
            <version>3.1-b41</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>

            <plugins>
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>2.1.0</version>
                    <extensions>true</extensions>
                    <configuration>
                        <supportedProjectTypes>
                            <supportedProjectType>ejb</supportedProjectType>
                            <supportedProjectType>war</supportedProjectType>
                            <supportedProjectType>bundle</supportedProjectType>
                            <supportedProjectType>jar</supportedProjectType>
                        </supportedProjectTypes>
                        <instructions>
                            <!-- Read all OSGi configuration info from this optional file -->
                            <_include>-osgi.properties</_include>
                            <!-- By default, we don't export anything -->
                            <Export-Package>!*.impl.*, *</Export-Package>
                            <DynamicImport-Package>javax.*, org.*, com.sun.faces.*</DynamicImport-Package>
                            <Import-Package>*;resolution:=optional</Import-Package>
                            <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
                            <Embed-Transitive>true</Embed-Transitive>
                            <Embed-Directory>WEB-INF/lib</Embed-Directory>
                            <Embed-StripVersion>false</Embed-StripVersion>
                            <Embed-StripGroup>true</Embed-StripGroup>
                            <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
                        </instructions>
                    </configuration>
                    <executions>
                        <execution>
                            <id>bundle-manifest</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>manifest</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>bundle-install</id>
                            <phase>install</phase>
                            <goals>
                                <goal>install</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin> 

                <plugin> <!-- Need to use this plugin to build war files -->
                    <artifactId>maven-war-plugin</artifactId>
                    <groupId>org.apache.maven.plugins</groupId>
                    <!-- Use version 2.1-beta-1, as it supports the new property failOnMissingWebXml -->
                    <version>2.1-beta-1</version>
                    <configuration>
                        <archive>
                            <!-- add bundle plugin generated manifest to the war -->
                            <manifestFile>
                                ${project.build.outputDirectory}/META-INF/MANIFEST.MF
                            </manifestFile>
                            <!-- For some reason, adding Bundle-ClassPath in maven-bundle-plugin
                            confuses that plugin and it generates wrong Import-Package, etc.
                            So, we generate it here.
                            -->
                            <manifestEntries>
                                <Bundle-ClassPath>WEB-INF/classes/
                                </Bundle-ClassPath>
                            </manifestEntries>
                        </archive>
                    <!-- We don't have a web.xml -->
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>6.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <!-- Enable this plugin for all modules -->
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>glassfish-repo</id>
            <name>The Glassfish repository</name>
            <url>http://download.java.net/maven/glassfish/</url>
        </repository>
        <repository>  
            <id>prime-repo</id>  
            <name>PrimeFaces Maven Repository</name>  
            <url>http://repository.primefaces.org</url>  
            <layout>default</layout>  
        </repository>  
    </repositories>
    <description>Module History Module</description>
</project>

These lines must be added in order Primefaces to works:

<instructions>
    <!-- Read all OSGi configuration info from this optional file -->
    <_include>-osgi.properties</_include>
    <!-- By default, we don't export anything -->
    <Export-Package>!*.impl.*, *</Export-Package>
    <DynamicImport-Package>javax.*, org.*, com.sun.faces.*</DynamicImport-Package>
    <Import-Package>*;resolution:=optional</Import-Package>
    <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
    <Embed-Transitive>true</Embed-Transitive>
    <Embed-Directory>WEB-INF/lib</Embed-Directory>
    <Embed-StripVersion>false</Embed-StripVersion>
    <Embed-StripGroup>true</Embed-StripGroup>
    <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
</instructions>

But I noticed very strange problem. I can use for example simple PrimeFaces tags without managedbeans for example <p:spinner> but if I want to use tags with managed beans the beans are not found. Maybe they are not visible?

8
  • How I can see the path of http://primefaces.org/uii? Commented May 31, 2012 at 13:33
  • What are the versions of Netbeans and Glassfish used? Commented May 31, 2012 at 17:29
  • Netbeans 7.1.2, Glassfish 3.1.2 Commented May 31, 2012 at 17:36
  • You said "I downloaded the Primefaces jar file and I added it to the resources directory into the WAR file". It should be added to WEB-INF/lib directory, shouldn't it? Primefaces resources are loaded from the jar. If you are using Maven to generate your WAR file shouldn't it copy the dependencies to your WEB-INF/lib by default? Have you opened the maven generated WAR file to see if WEB-INF/lib directory have all the expected libraries? Try it with maven-war-plugin version 2.2 to see if it's a version issue. Sorry for so many questions on this comment. Commented Jun 1, 2012 at 14:26
  • 1. I added as dependency Primefaces into the POM file. I build the WAR package. Then I unzip the content of the package. Primefaces is there - WEB-INF/lib 2. I updated the version of the maven-war-plugin - again not result Commented Jun 1, 2012 at 15:28

2 Answers 2

11
+50

I just followed the steps from Primefaces download guide:

http://primefaces.org/downloads.html

Downloading with Maven

PrimeFaces distributions are deployed at the PrimeFaces Repository, to let maven aware of this repository, add the following repository definition to your pom.xml in repositories section.

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

And add the dependency configuration as;

<dependency>
  <groupId>org.primefaces</groupId>
  <artifactId>primefaces</artifactId>
  <version>3.3</version>
</dependency>

After that, I added the Primefaces repository to my Nexus installation and it worked as expected.

I hope it helps you!

Sign up to request clarification or add additional context in comments.

1 Comment

Based on information in deleted answers on this question, OP has the repo in his pom already (only OP didn't think about updating his question with this information). Note that OP has edited his question that he found the possible culprit already, if he removes that <build> entry, then it works fine for him. If you are familiar with Maven, you might want to edit your answer to explain that <build> entry problem instead.
6

Step1: Create a maven web application project in netbeans

Step2: Right click project in project explorer.

Step3: Select Properties

Step4: Select frameworks

Step5: Click Add

Step6: Select java server faces

Step7: Select primeface from component tab

Step8: click OK

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.