简体   繁体   中英

Found multiple versions of the required class javax.faces.FactoryFinder

I started on JSF2.0. I followed a tutorial with no problem and all worked fine! I used Eclipse Helios. But I noticed something I can not understand. The tutorial said to add Project Facet for JSF 2. I did no such thing and all worked ok. So to follow tutorial exactly I did:

Right-click on Project -> Properties -> Project Facets

And JavaServer Faces facet check-box was not ticked. I assume this is what the tutorial means by Project Facet. I clicked on it and a

Further Configuration Needed

link appeared. I followed the link to a JSF capabilities (Modify Faceted Project) dialog, I selected as User library, my library of JSF(which is MyFaces) but I got the error message:

Found multiple versions of the required class javax.faces.FactoryFinder.

What is this error? Can't I add project facet after creating my project? And what do I need the project facet for? My (trivial) code indicates that JSF works ok, so what is the project Facet useful for?

From the Eclipse help :

Facets define characteristics and requirements for Java EE projects and are used as part of the runtime configuration.

When you add a facet to a project, that project is configured to perform a certain task, fulfill certain requirements, or have certain characteristics. For example, the EAR facet sets up a project to function as an enterprise application by adding a deployment descriptor and setting up the project's classpath.

In the case of the JSF facet :

The following features are available when the JSF facet is installed:

  • JSF Library configuration support
  • Application Configuration Management
  • JSP Source Page semantic validation and content assist for most of the JSF Core and JSF HTML tag library attribute values using Expression Language (EL) or not.
  • "Run on Server" support of a JSF JSP page

In the case of this error:

Found multiple versions of the required class javax.faces.FactoryFinder.

It looks like the tooling has detected multiple copies of the core JSF API on the project classpath. JSF has some tolerance for this and has historically supported running different versions in different classloader contexts - that is, you can put one in the WAR and one in the container. Using the Open Type dialog ( CTRL + SHIFT + T ) and searching for javax.faces.FactoryFinder should help you locate the culprit jar.

Adding the JSF nature/facet to your project adds abilities like code completion, adding jsf visual components to your web page editor etc to your project. Check your build patch and see how many jsf api jars are there. I am assuming this error is in the IDE and not in the running app.

The JSF facet helps you to property configure your project with JSF libraries. It also enables a bunch of JSF specific validation and tools from the JSF Tools project. While it certainly possible to develop a JSF app without using JSF tools like you have done, you can be more productive if you are using these tools.

If you are interested in trying out JSF tools with your tutorial, start out by creating a new web project with JSF facet. Then skip the parts of your tutorial that talk about configuring libraries or creating descriptors.

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