ivy.xml for Spring 3

Here’s an ivy.xml with a dependency on Spring MVC. Please fill in the organisation and module attributes. It excludes the Unified Expression Language library because it conflicts with Tomcat 7.

<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
    <info organisation="..." module="..." />

	<dependencies>
		<dependency org="org.springframework" name="org.springframework.web.servlet" rev="3.0.5.RELEASE">
			<!-- Fix for java.lang.LinkageError: loader constraint violation -->
			<exclude name="com.springsource.javax.el" />
		</dependency>
	</dependencies>
</ivy-module>

Here’s the corresponding ivysettings.xml. It uses the SpringSource Bundle Repository instead of the default Maven repository.

<ivysettings>
	<settings defaultResolver="spring" />
	<resolvers>
		<chain name="spring">
			<url name="com.springsource.repository.bundles.release">
				<ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
				<artifact pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
			</url>
			<url name="com.springsource.repository.bundles.external">
				<ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
				<artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
			</url>
		</chain>
	</resolvers>
</ivysettings>

Loader Constraint Violation

If you are using Ivy to manage Spring dependencies and trying to deploy to Tomcat 7, you might have encountered the error.

java.lang.LinkageError: loader constraint violation: 
when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature

This seems to be a conflict between the javax.el classes. To fix it, just remove javax.el from your Ivy Spring dependency.

		<dependency org="org.springframework" name="org.springframework.web.servlet" rev="3.0.5.RELEASE">
			<!-- Fix for java.lang.LinkageError -->
			<exclude name="com.springsource.javax.el" />
		</dependency>