13

I'm having a trouble deploying a Spring boot application in webLogic 12C.

10.4.4 403 Forbidden The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.

I was wondering if someone can help with that.

Carlos
  • 804
  • 1
  • 7
  • 11
  • That's not really very much information. Did it come from your application, or from the server? If it's the application did you try deploying in another container? Probably you are going to need to show the code. – Dave Syer Jul 19 '14 at 07:02
  • Hi Dave thanks for your answer, I deploy de application in tomcat and works fine, but when I try to make a deploy in WEBLOGIC I recieve this message, I was using this guide [link](http://spring.io/blog/2014/03/07/deploying-spring-boot-applications) but it doesn't work. sorry for the english it's not my main lenguaje. – Carlos Jul 21 '14 at 15:23
  • It's really not clear where the 403 came from. Some Los might help, but really I doubt we are going to make any progress without your code. Do you think you could make a minimal webapp that has this problem and post it on github. – Dave Syer Jul 21 '14 at 16:53
  • Dave, I made a little "Hello World" this is the [link](https://github.com/purrox/Spring-example) and I have the same result 10.4.4 403 Forbidden in WebLogic and works fine in Tomcat. I hope you can help with that. – Carlos Jul 21 '14 at 17:51
  • Thanks that's useful. First question: why don't you use the latest Boot (1.1.4.RELEASE or 1.1.5.BUILD-SNAPSHOT as of today)? Second question: does the Weblogic target container support servlet 3.0? – Dave Syer Jul 21 '14 at 17:57
  • It's a good question, I don't know why am I using an older version and as far as I understand Weblogic 12c supports servlet 3.0 – Carlos Jul 21 '14 at 19:41
  • @DaveSyer sorry for bother you, but you don't have any clue about it? – Carlos Jul 22 '14 at 17:20
  • Sorry, I'm still a bit hazy on the steps to reproduce. Who is getting a 403 from where? – Dave Syer Jul 23 '14 at 12:30
  • Dave the 403 is getting when I try to access the url generated for weblogic [link](http://cdn.imghack.se/images/2bdf99230195284b66949cc4af7e1c38.png) – Carlos Jul 23 '14 at 15:50
  • Any logging on the server? What if you add DEBUG level for everything? Is Spring even getting to process the request. – Dave Syer Jul 23 '14 at 22:34

6 Answers6

36

I reviewed your code and saw an issue in this class of your code: https://github.com/purrox/Spring-example/blob/master/src/main/java/hello/Application.java

You're doing it correctly (as defined in the SpringBoot docs) but it seems there's a bug with Weblogic12C (or maybe an interpretation of the standard). It seems like Weblogic12C Searches for a class that implements WebApplicationInitializer DIRECTLY. Notice how your code extends SpringBootServletInitializer (which implements WebApplicationInitializer). Weblogic12C doesn't like it that way it seems. So, the simplest way is to make your Application class implement WebApplicationInitializer. So, change this line:

public class Application extends SpringBootServletInitializer {  

to this:

public class Application extends SpringBootServletInitializer implements WebApplicationInitializer {  

Note: once you fix the above, you'll run into another Weblogic12C deploy issue: "java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath". To fix that other issue, create a new file src/main/webapp/WEB-INF/weblogic.xml and put this content in it:

    <?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_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
        <wls:weblogic-version>12.1.1</wls:weblogic-version>
        <wls:context-root>helloApp</wls:context-root>
        <wls:container-descriptor>
            <wls:prefer-application-packages>
                <wls:package-name>org.slf4j.*</wls:package-name>
            </wls:prefer-application-packages>
        </wls:container-descriptor>
    </wls:weblogic-web-app>
Pierre
  • 2,335
  • 22
  • 40
  • 1
    I have seen that we need to specify a JNDI name for the war file before deploying in weblogic. Using that JNDI name we mention the datasource. Can you tell me how to do that. I am very new to spring, spring boot. please bare with me if the question is silly. – JEET ADHIKARI Jun 26 '17 at 06:25
4

If you are going to use multipart file request, you may still find issues in deploying the war.

The root of the problem is that OrderedCharacterEncodingFilter is running after HiddenHttpMethodFilter. HiddenHttpMethodFilter triggers processing of the request body as it calls getParameter on the request. OrderedCharacterEncodingFilter then runs and sets the request's encoding. Setting the request's encoding after its body has been processed is bad and, on WebLogic, causes the request to lose track of all its multipart data.

A workaround is to disable the character encoding filter in application.properties:

spring.http.encoding.enabled: false
Naresh Hawk
  • 149
  • 3
  • 5
3

You need to add "implements WebApplicationInitializer" to your hello.Application.

This is redundant as it extends SpringBootServletInitializer, which itself implements WebApplicationInitializer, however, as @Pierre points out, weblogic requires a class to directly implement it.

dan carter
  • 4,158
  • 1
  • 33
  • 34
2

I hit this issue last time. After applying all proposals from this post I was still getting error 403. In my case the problem was in the web.xml file. I was using version 2.5 instead of 3.0 without configuring it to load an ApplicationContext via a DispatcherServlet.

From the post: What exactly is the web-app version? What does it affect?.

Versioning refers to XML schema version that syntax of your web.xml file must obey. More important, it also indicates the version of Servlet specification that your application implements.

And from Spring documentation http://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html:

Older Servlet containers don’t have support for the ServletContextInitializer bootstrap process used in Servlet 3.0. You can still use Spring and Spring Boot in these containers but you are going to need to add a web.xml to your application and configure it to load an ApplicationContext via a DispatcherServlet.

Finally I've changed the version of web.xml file to 3.0 and it starts working.

Community
  • 1
  • 1
kpater87
  • 1,190
  • 12
  • 31
0

I had the same issue while deploying SpringBoot 2.3.5.RELEASE app to Oracle WebLogic Server 12.2.1.4.0 version. In my case just implementing SpringBootServletInitializer resolved it, no need to implement WebApplicationInitializer

@SpringBootApplication
@RestController
public class Application extends SpringBootServletInitializer {


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

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

}
akarahman
  • 235
  • 2
  • 15
0

Use this project for reference to deploy spring boot application in weblogic 12.1.3 server. (mainly files like pom.xml, weblogic.xml, etc

https://github.com/baranirajarathinam/wls1213

Barani r
  • 2,119
  • 1
  • 25
  • 24