开发者

Solving "loader constraints violated when linking [...] class" error in Java

I am new to Java and experiencing problems understanding exceptions thrown by the framework.

Right now, I am trying to implement a regular expression validator into an application consisting of Java 5 EE with myFaces 1.2 and Tobago running in an apache tomcat 5.5.

I followed a couple of tutorials (including the Java 5 EE tut from SUN) and came pretty far. However, when calling my jsp, I get the following error message:

java.lang.LinkageError: loader constraints violated when linking javax/faces/validator/Validator class

Can anyone explain to me what I need to do to solve this problem?

So far, it seems as if MyFaces 1.1.7 has a version conflict to TomCat 5.5. Both contain javax.* packages (one of them namely javax.fac开发者_JAVA百科es.validator). The validator class has a different version in the packages. The corresponding MyFaces library is called myfaces-api-1.1.7.jar and the TomCat library is called javaee.jar.

The included javax packages in the myfaces lib is a subset of the packages from within the javaee lib. However... I cannot skip any of both, because the project will fail to start then.

Any tipps?


This is almost certainly caused by your application having its own copy of Validator (in one of its JAR files), and this is clashing with the server's own copy. Something this can cause a LinkageError.

Find out which of your WAR or EAR's JAR files contains that, and remove it (along with the rest of the javax.faces classes).


Sounds like a classpath problem. Check your classpath for two jars with conflicting versions (both containing the javax.faces.validator.Validator class)


According to the MyFaces homepage. Tomcat Config: Tomcat 5.5.x

Some users have reported problems when using MyFaces with Tomcat 5.5.x. Here is a short guide that will hopefully help you not run into the same problems :-)

If your are using the binary version of MyFaces: MyFaces is packaged so that it works with Tomcat 5.0.x so the WEB-INF/lib/jsp-2.0.jar and WEB-INF/lib/commons-el.jar JAR files must be removed from your WAR files (including the examples).

If you are building from source: If you want to build MyFaces from scratch to work with Tomcat 5.5.x, you have to set the property tomcat.pre.5.5.version in the $MYFACES_HOME/build/build.default.properties file to the value false.


Perhaps you've got two conflicting versions of the same library available on your classpath. For example, you might have a jar file in WEB-INF/lib that's already provided in TOMCAT_HOME/lib. (el-api.jar is a common culprit, but there are other possibilities.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜