简体   繁体   中英

Adding Richfaces to Maven based project

Good evening,

Currently I'm trying to add Richfaces to a Maven based project in Eclipse. However, when I deploy my application (Glassfish) I get the following warnings in my browser:

Warning: This page calls for XML namespace h++p://richfaces.org/rich declared with prefix rich but no taglibrary exists for that namespace.

Additionally, I get no error messages in my console.

In Netbeans, I had the same problem when trying Richfaces the first time. However, I was able to solve this by doing Right-click on the Dependencies folder in my web project, and then selecting Download Declared Dependencies. However, I don't have this option in Eclipse.

The project in Eclipse uses JSF 2.1 (Apache MyFaces 2.1.5). The dependencies were added as follows:

    <dependency>
        <groupId>org.richfaces.ui</groupId>
        <artifactId>richfaces-components-api</artifactId>
        <version>4.2.2.Final</version>
    </dependency>
    <dependency>
        <groupId>org.richfaces.ui</groupId>
        <artifactId>richfaces-components-ui</artifactId>
        <version>4.2.2.Final</version>
    </dependency>
    <dependency>
        <groupId>org.richfaces.core</groupId>
        <artifactId>richfaces-core-api</artifactId>
        <version>4.2.2.Final</version>
    </dependency>
    <dependency>
        <groupId>org.richfaces.core</groupId>
        <artifactId>richfaces-core-impl</artifactId>
        <version>4.2.2.Final</version>
    </dependency>

Although this code worked fine in Netbeans I also tried following the advice on:

https://community.jboss.org/wiki/HowToAddRichFaces4xToMavenBasedProject https://community.jboss.org/wiki/MavenGettingStarted-Users

However, the problem persisted. Any ideas why this is happening?

This looks as though Maven hasn't downloaded the dependencies into its local repo. The easiest way to do this in eclipse is to use the m2e plugin. Once installed, right click on your project and select;

Run As > Maven Clean

which attempts to clean a project's working directory of the files that we're generated at build-time. You can read about it here: http://maven.apache.org/plugins/maven-clean-plugin/

The again do right click on your project and select:

Run As > Maven Install

which is used to add artifact(s) to your local repository. You can read about it here: http://maven.apache.org/plugins/maven-install-plugin/

Try deploying that to your server, and it should'nt moan about missing dependencies. Also I suggest once you're happy with the concepts of maven, to get familiar with using it from the command line. Good luck!

Here's a short cookbook approach I found worked after about a dozen promised simple JSF Get Started. I have a target dictated by other areas of a project. Netbeans and no big server (eg) Glassfish, JBOSS. I want to start with Tomcat and migrate to an embedded server. I expected the problems with the migration. It has taken about 4 days off and on to find an example that works. Start here:

It is really disappointing because exact same demo took 30 min AngularJS. The first problem is there's no ready examples that run. People writing these projects just want flash examples that don't explain the basics. Secondly there's not much (virtually) nothing that works when you do it with Netbeans 8. So be prepared to hack about at first until you find what works for you.

So far I got Netbeans 8 and Tomcat 8 to run this example. I'm happy enough but there's still an error on starting. The index.xhtml works OK, so I'm counting a ' win '. If you are on Windows, you may wan to edit this on one line.

 mvn archetype:generate \
        -DarchetypeGroupId=org.richfaces.archetypes \
        -DarchetypeArtifactId=richfaces-archetype-simpleapp \
        -DarchetypeVersion=4.0.0.Final \
        -DgroupId=com.jasmineconseil.samples.richfaces4  \
        -DartifactId=richfaces4-start

This generatd doesn't completely work. It flounder on a missing resources/ folder. Odd since it was responsible for generating the resources folder imho. I made the resouces folder and re-did the generate. That at least gave me a POM file. Oh, yes, I'm using maven 3 if that helps people.

I moved to the project directory, and the next step of installing the POM:

mvn install

That also did some stuff and failed. Something to do with a compile. At this point I shifted to Netbeans. The POM file doesn't load as a project, I had to click on the "resolved problems" menu choice.

When I clicked resolve, most of the issues went away.

Next, Project Properties. The main thing was to set the Java version (1.8 on this project). Set the Tomcat server of choice. Check the component libraries and ensure RichFaces is ticked.

Click build -- It builds. Click Run/Debug ... If your Tomcat install is all set-up, it works! With a runtime error from Catalina. Still the web page comes up and the error doesn't display after that (so far, so good....)

 13-Aug-2014 00:04:11.058 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
  org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hellojsf]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:697)
      .... 

I haven't looked at that yet. There are notes on JavaHotChocolate about different kinds of poblems with Jars and errors. I'm hoping I'll come across something or I'll be back here with a question on the error.

You may also find these useful to unravel the ball of wool.

Gotcha ...

Some things I found with Netbeans(?) especially after a clean or closing Netbeans and reopening the project.

Hopefully some of the people looking on this topic can take one step forward with these examples. Bon chance!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM