1

I've got a Spring Boot application running fine locally via the built in tomcat server but I'm having issues deploying it as a war file in Weblogic 12.2. I've followed the "85.1 Create a deployable war file" section of the Spring Boot reference guide to build the war file, created a new Weblogic managed server to host it and followed the deployment install steps on Weblogic but get the below exception when clicking start "servicing all requests" on the deployment. Any suggestions?

Dependencies section of build.gradle:

dependencies {
    compile fileTree(dir: 'lib', include: '*.jar')
    compile(
        'org.springframework.boot:spring-boot-starter-web:1.5.8.RELEASE',
        'org.springframework.boot:spring-boot-devtools',
        'org.springframework.boot:spring-boot-starter-jdbc',
        'org.springframework.boot:spring-boot-starter-data-jpa',
        'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.2',
        'org.springframework.boot:spring-boot-starter-security',
        'javax.servlet:javax.servlet-api:3.1.0'
    )
    testCompile(
        'org.springframework.security:spring-security-test',
        'org.springframework.boot:spring-boot-starter-test'
    )
    providedRuntime (
        'org.springframework.boot:spring-boot-starter-tomcat'
    )
}

Exception received from Weblogic when clicking start "servicing all requests":

Caused By: java.lang.NoSuchMethodError: org.springframework.web.context.support.StandardServletEnvironment.initPropertySources(Ljavax/servlet/ServletContext;Ljavax/servlet/ServletConfig;)V
        at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
        at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87)
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:162)
        at weblogic.servlet.internal.WebAppServletContext.initContainerInitializer(WebAppServletContext.java:1420)
        at weblogic.servlet.internal.WebAppServletContext.initContainerInitializers(WebAppServletContext.java:1359)
        Loads more weblogic errors here.

My application entry point appears to be okay:

@SpringBootApplication
public class Application extends SpringBootServletInitializer implements WebApplicationInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
2
  • Spring boot embedded with a tomcat servlet container. Why would you want to deploy spring-boot app on weblogic? Commented Dec 19, 2017 at 10:57
  • Is there any way to remove that? Unless I've misunderstood the docs say adding the above "providedRuntime" dependency excludes it? We just use Weblogic as our app server. Commented Dec 19, 2017 at 11:06

1 Answer 1

4

Add a weblogic deployment descriptor as said in spring-docs. Create a file named weblogic.xml and add this code to the xml.

<?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/ejb-jar_3_0.xsd
        http://xmlns.oracle.com/weblogic/weblogic-web-app
        http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
    <wls:container-descriptor>
        <wls:prefer-application-packages>
            <wls:package-name>org.slf4j</wls:package-name>
            <wls:package-name>org.springframework.*</wls:package-name>
        </wls:prefer-application-packages>
    </wls:container-descriptor>
</wls:weblogic-web-app>

Now put the weblogic.xml file into WEB-INF folder so that full path will be WEB-INF/weblogic.xml.

Update: Add a empty dispatcher-servlet.xml to WEB-INF/ folder.

dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>

And your build.gradle add dependency

org.springframework.boot:spring-boot-starter-web

Also remove

providedRuntime (
    'org.springframework.boot:spring-boot-starter-tomcat'
)
Sign up to request clarification or add additional context in comments.

4 Comments

Done and confirmed by checking the war file contents but still the same error. I'm not sure if it's weblogic trying to substitute it's own jars over the spring ones?
I didn't think so. Could you please remove your providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' from build.gradle ?
Then problem could be somewhere else. :(
Looks like the Weblogic install needed patching to the latest version. Not had this issue since.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.