Weblogic 10.3.5 Overriding Spring Version

I am developing a web application using Oracle's OEPE distribution, including Weblogic server 10.3.5. WLS includes its own version of Spring, which appears to be 2.5.6.SEC01. However, we are trying to use Spring and Spring Security features specific to the 3.1 release.

The Maven POM defines the Spring Version as a property to be 3.1.1.RELEASE (with that property plugged in to the sections, i.e.:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${spring.version}</version>
</dependency>

I've try two separate ways in weblogic.xml of excluding the built-in Spring (one is commented out below, but rest assured I've tried both):

<wls:container-descriptor>
    <wls:prefer-application-packages>
        <wls:package-name>com.oracle.ojdbc16.*</wls:package-name>
        <wls:package-name>antlr.*</wls:package-name>
        <wls:package-name>javax.persistence.*</wls:package-name>
        <wls:package-name>org.apache.commons.*</wls:package-name>
        <wls:package-name>org.springframework.*</wls:package-name>
        <wls:package-name>org.hibernate.*</wls:package-name>
        <wls:package-name>org.apache.xerces.*</wls:package-name>
    </wls:prefer-application-packages>
    <!-- <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes> -->
</wls:container-descriptor>

What in the world do I have to do to use my own version of Spring?


I had the same problem. The solution was to create weblogic-application.xml into the META-INF folder of EAR project. Here is the code.

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application>
    <prefer-application-packages>
        <package-name>org.apache.*</package-name>
        <package-name>org.springframework.*</package-name>
    </prefer-application-packages>
</weblogic-application>

Maybe your problem is that you're using weblogic.xml into WAR project instead of weblogic-application.xml into EAR project.

Hope it helps.


OPTION1: Deploy your Spring 3.x app to a wls server in a domain that does not have JRF installed. That works for me.

OPTION2: use prefer-web-inf-classes in weblogic.xml and deploy as a war. This worked for me with wls 10.3.6, JRF domain, Spring 3.2.2. I couldn't get prefer-application-packages to work, but prefer-web-inf-classes did.

NOTES: With a domain that does have JRF installed, I've tried both the war/weblogic.xml/prefer-application-packages and ear/weblogic-application.xml/prefer-application-packages approaches and neither seems effective. I have a test jsp that outputs org.springframework.core.SpringVersion.getVersion() and it persists in reporting 2.5.6.SEC01 despite my efforts (this is the version of Spring bundled in the oracle_common/modules folder).

Deploy the same app in a non-JRF domain though, and org.springframework.core.SpringVersion.getVersion() will report whatever version of spring you bundled with your app.


If you are using Spring Framework, you'll most likely deploy your Spring beans in a WAR and not an EAR, even in case of a Spring Integration project. Up to 12c (incl. 12.2.1) without any specific configuration you'll be stuck at Spring framework 3.0.5 and Spring Integration 2.2.6 at best. Any attempt to use a higher Spring Version will likely yield at deployment:

weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.springframework.core.MethodParameter.getNestedParameterType()Ljava/lang/Class;

because the Oracle-JRF-embedded Spring Framework is picked by the class loader.

In a multi-server Domain, not deploying JRF to a given server instance will not solve the issue but a whole Domain without JRF will do.

The trick instead is to use the prefer-web-inf-classes parameter in a WEB-INF/weblogic.xml deployment descriptor, as follows:

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.8/weblogic-web-app.xsd">
    <wls:container-descriptor>
        <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
    </wls:container-descriptor>
</wls:weblogic-web-app>

and you can enjoy the benefits of Spring Framework 4.2 in a WebLogic Domain with JRF instrumentation. Do not forget, of course, to include Spring core 4.2 and related dependencies into the WAR file assembly (i.e. check the built .war to contain WEB-INF/lib/spring*.jar).