1

I have done below configurations and tried almost all solutions found but nothing helped. When i am deploying spring boot app in war package. no error got logged in weblogic log but the application throwing 404 error.

web.xml

<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:root-context.xml</param-value>
    </context-param>
    <context-param>  
    <param-name>spring.profiles.active</param-name>  
    <param-value>dev</param-value>  
    </context-param>  
    <context-param>  
    <param-name>spring.profiles.default</param-name>  
    <param-value>dev</param-value>  
</context-param>
<context-param>  
    <param-name>spring.liveBeansView.mbeanDomain</param-name>  
    <param-value>dev</param-value>  
</context-param>  

weblogic.xml

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:wls="http://www.bea.com/ns/weblogic/90"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">
    <wls:weblogic-version>12.1.2.0.0</wls:weblogic-version>
    <wls:context-root>/services/userModule/</wls:context-root>
    <wls:container-descriptor>
        <wls:prefer-application-packages>
            <wls:package-name>com.fasterxml</wls:package-name>
            <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>

application.properties

spring.profiles.default=default
spring.profiles.active=default
spring.liveBeansView.mbeanDomain=default

cms.config.monitor.dir=/server/location/application/artifacts
application.messages.file.name=application-messages
application.config.file.name=application-config

root-context.xml

it contains application specific configurations.

ApplicationBegin.java

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class}) 
public class ApplicationBegin extends SpringBootServletInitializer implements WebApplicationInitializer {

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

    public static void main(String[] args){
        SpringApplication.run(ApplicationBegin.class, args);

    }

Cannot exclude tomcat server from pom.xml as it is failing the compilation. is there a way to set tomcat as provided while using spring boot starter web? pom.xml

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>

                <!-- THIS WILL BE EXCLUDE ONLY FOR WEBLOGIC DEPLOYMENT -->
                <!--  <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>  -->
            </exclusions>
        </dependency>

The problem is the application runs fine with embedded tomcat but it is not working even not throwing any error when deploying on weblogic. Where should i look?

3 Answers 3

0

Can you try class loading as the parent last? So Spring boot will use it's own container libraries.

5
  • probably.. that would be a bit complicated since i will have to override.. is there any issue u see with my configuration or the issue is because not ridding of the embeded tomcat? thanks
    – Reese
    Oct 11, 2018 at 20:40
  • I did the same in WebSphere from Admin console. You can try similar to this (a bit old document) rgagnon.com/javadetails/java-0551.html
    – Debopam
    Oct 11, 2018 at 22:19
  • Hi Debopam.. tried the way you mentioned but not worked
    – Reese
    Oct 12, 2018 at 7:23
  • deployment is not throwing any error , it is being done sucessfully and then when i start the deployment through weblogic portal it also shows the successfull message but in the log no boot related log.. it ends with the message initialized the application context..
    – Reese
    Oct 12, 2018 at 7:34
  • What URL are you trying to hit ? Does it have the weblogic port on it or 8080 ? weblogic would normally be port 7001
    – mkane
    Oct 12, 2018 at 8:47
0

After trying the solutions i found from different people , it couldn't solve my issue and somehow i have solved it now. all the similar issues i have seen on this topic and the soultions, i finally understood no answer was actually a solution because in most of the cases the issue happens because of wrong configuration that weblogic dosen't understand. the worst part being it doesn't even throw error. In my case other than application.properties file and a root-context.xml, i explicitly specified web.xml file in /WEB-INF location and defined context-config location there. As soon as i removed the web.xml and refactored/filtered the project dependencies from top to bottom , it resolved the issue. and also then i realized many handy solutions on the web for this issue wouldn't even be required if your configuration is correct. for an example, configuring a jpavendor won't require if you use spring boot jpa starter correctly. so.. if you ever face this kind of deployment issue on weblogic , you may follow below steps -

  1. Only deploy a bareminimum part of application and make it workable on weblogic
  2. then add your critical dependencies / configurations and deploy them one by one on weblogic and check if it is working
  3. you should always run your boot application to other local server first for resolving major configuration issues ..tomcat is good.
0

I had the same problem, but I finally managed to solve it.

The problem was the version of web.xml descriptor. If you put the web.xml file in your project with <web-app version="2.5">, even though your Weblogic supports servlet 3.0, the spring controllers would throw 404.

That also explains the behavior of your app - what's why it started working when you removed the web.xml file.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.