Coder Social home page Coder Social logo

spring-boot-on-weblogic's Introduction

Spring Boot On Weblogic

A Spring Boot 2.x REST App which runs on Weblogic 12c or Weblogic 14c

Running Spring Boot Application on Weblogic 14c and Weblogic 12c

If you are here, then that means you are already familiar with benefits of Spring Boot and you want to leverage these benefits in your next Application which will be deployed on Weblogic Server.

So without wasting much let’s get started with how to do that.

First thing we will do is that, when we run the spring initializer we will select the default packaging mode as WAR. I have used spring website because I am using IntelliJ Community Edition. You can use STS or intelliJ Ultimate Edition for the same.

Once the skeleton project is created you will see a servlet initializer config class created for you.

This class extends the SpringBootServletInitializer class and overrides the configure method. All the codes are auto generated for you and digging into the details of this class is indeed a concern for another topic.

Now we will have to add two xml files inside folder: main -> webapp -> WEB-INF. Spring creates resources folder for you but you will have to manually add webapp folder adjacent to resources and WEB-INF goes inside webapp folder.

Let’s create our two xml files inside WEB-INF folder:

  1. weblogic.xml
  2. disparcherServlet-servlet.xml

We will just add the root bean tag in the dispatcher servlet xml file and will leave it empty.

<?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>

The main part is the weblogic.xml. We will define the context root path here and the most important part prefer-application-packages tag:

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
                  http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd">

    <context-root>/narif/poc/echo</context-root>

    <session-descriptor>
        <cookies-enabled>false</cookies-enabled>
    </session-descriptor>

    <container-descriptor>
        <prefer-application-packages>
            <package-name>org.slf4j</package-name>
            <package-name>com.fasterxml</package-name>
            <package-name>org.springframework</package-name>
            <package-name>org.apache.logging</package-name>
            <package-name>org.apache</package-name>
        </prefer-application-packages>
    </container-descriptor>
</weblogic-web-app>

These are the bare minimum stuffs you will need to deploy a spring boot war on weblogic. After completing the above steps you can do a dry run.

So run mvn package and deploy the war file on weblogic.

Build phase:

Deployment phase:

Now let’s create a very simple ping service which will respond with “pong”.

package narif.poc.wlseries.echorestapi;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EchoRestService {

    @GetMapping("ping")
    public String ping(){
        return "pong";
    }
}

Again build and ship to wls and try this url in postman.

• NOTE: • I have used Spring Boot 2.2.6 • I have tested on Weblogic 12c and Weblogic 14c.

spring-boot-on-weblogic's People

Contributors

najeebarif avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

spring-boot-on-weblogic's Issues

Weblogic server issue (code not getting deployed.)

Hello Najeeb,

I have tried to run your code on WebLogic 12c in eclipse neon and jdk1.8. But i am unable deploy the same in weblogic server and facing the below error,
<Unable to set the activation state to true for the application "auto_generated_ear".
weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.springframework.web.jsf.DelegatingPhaseListenerMulticaster

And also tried your code in eclipse photon with WebLogic 14c and jdk1.8, then before we run on server itself getting error as "Project facets is not supported with 4.0".

Requesting to kindly let us know where the gap is.

Regards,
Abdullah.

Not able to deploy it as it is in weblogic 12.1.3.0 server

Just following error is displayed in the weblogic console:

<Mar 22, 2024 12:07:21 PM IST> <AppMerge failed to merge your application. If you are running AppMerge on the command-line, merge again with the -verbose option for more details. See the error message(s) below.>

I understand that this is related to issue with dependencies in the war deployed. Please let me know if you know any fix for this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.