I am having problems accessing the sampleBoot sample application after deploying it to Weblogic12C. It works great using the Tomcat server built into SpringBoot.
Install and test using the built-in SpringBoot Tomcat: everything is fine
Steps to play: get the Getting Started application code below: https://spring.io/guides/gs/spring-boot/
- git clone https://github.com/spring-guides/gs-spring-boot.git
- cd gs-spring-boot / complete / (we will use gr-spring-boot / complete dir so that you do not have to go to the "Getting Started" page above (all changes made to you are "complete").
- open the gs-spring-boot-complete / build.gradle file and add “apply plug-in: war” below the other “apply plug-in” entries
At this point, you can verify that everything is fine by running> tasks that run the application on the Tomcat embedded server. After starting tomcat go to localhost: 8080 / and you will see that you get "Hello from Spring Boot!"
Now let me install this on Weblogic 12C
- run "gradle war" (again, work with gs-spring-boot / complete /) now you will have a war file under gs-spring-boot \ complete \ build \ libs \ complete.war
- go to the weblogic12C console. I did not make any changes to my WL12C, so the console is located on localhost: 7001 / console NOTE. I downloaded the WL12C developer version a week ago from the Oracle site. I did not make any changes to it, as I downloaded it. The Dev version of the WL12C download requires that we point it to our already installed JDK. My WL12C uses the java version:
java version "1.7.0_45" Java (TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot (TM) Server VM (build 24.45-b08, mixed mode)
- when in the console expand the war file:
- Click Deploy
- click install
- get to you "gs- spring-boot \ complete \ build \ libs" dir
- select the switch next to complete.war and click next
- select "install as application" and click "Next"
- leave all options as [only DD, use default values, use the same availability] and click next
- click finish button
At this point, you will see that the application is deployed in the order: - click "deploy" again and make sure your "full" SpringBoot application is listed and ACTIVE - click "complete" and notice on this page: "Context Root: / complete". NOTE. The weblogic docs say that if there is no context root in weblogic.xml, then it uses the name of the war file (minus .war)
Now the problem: getting 403:
if you try to access the springBoot application on localhost: 7001 / complete, you will get 403 !!!
Error 403
Ok, let's make one final change (I'm fishing here, maybe weblogic really wants weblogic.xml):
- create directory: gs- spring-boot \ complete \ src \ main \ webapp \ WEB-INF \
- create this file: gs- spring-boot \ complete \ src \ main \ webapp \ WEB-INF \ weblogic.xml
modify weblogic.xml to contain:
<?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>testApp</wls:context-root> </wls:weblogic-web-app>
return to weblogic console (localhost: 7001 / console)
- go to "web applications" and check the box next to "complete", then click "delete"
- restart the weblogic12C server (just to be paranoid)
- run the gradle clean task again, then gradle war to create a new war file
- open the war file (using winzip or something else) and confirm that the war file now has WEB-INF / weblogic.xml
- go to the console to deploy a new war file (use the same steps as above)
- confirm that the application is now deployed and has contextRoot / testApp (as defined in weblogic.xml)
- go to localhost: 7001 / testApp /
403 still exists. So:
- weblogic knows about this application (returns 403). Because if he does not know about the application, he will return 404 (try it by going to localhost: 7001 / doesNotExist and you will get 404).
- but it looks like WL12C is not sending requests to spring. We used to define a bunch of things in web.xml, but now, with javaConfig and SpringBoot, all this should be done automatically ...
- Note: since SpringBoot uses JavaConfig (Servlet3), we cannot use anything lower than weblogic12C (which is the last)
Another thing I've tried: change RequestMapping
In the above code example, open the gs-spring-boot \ complete \ src \ main \ java \ hello \ HelloController.java file and replace:
@RequestMapping("/")
with this:
@RequestMapping("pierre.htm")
Now, if you are browsing (remember that weblogic.xml defines context-root as / testApp):
- localhost: 7001 / testApp / pierre.htm you will get 404
- localhost: 7001 / testApp / you will get 403
And if you try tomcat with "gradle bootrun", you can get it in the order: localhost: 8080 / pierre.htm (you get "hello from SpringBoot!").
So this gives the following clues:
- Weblogic knows about / testApp
- Weblogic has no idea what /testApp/pierre.htm is. As if it had never been configured as RequestMapping.
- there is some "Spring wiring" missing for its operation in weblogic ....
This is where I am stuck ... Can anyone think that JavaConfig "wires" are not enough for me to make it work in Weblogic? Any help is greatly appreciated. Thanks!!
Decision
If someone comes here to make it easier than reading all the comments below, here's how to get it working:
For this:
public class WebInitializer extends SpringBootServletInitializer implements WebApplicationInitializer {
create a new src / main / webapp / WEB-INF / weblogic.xml file and put this content into 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>
- gradle war
- deployment in weblogic12c
- it should work now :) Thanks a lot to both Dave Sire and Eugene!
Previous solution (stored here for posterity)
For this:
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); }
- copy the org.springframework.boot.context.web.ErrorPageFilter class to the hello package in the sample application.
create a new src / main / webapp / WEB-INF / weblogic.xml file and put this content into 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>
- gradle war
- deployment in weblogic12c
- it should work now :) Thanks a lot to both Dave Sire and Eugene!
NOTE. There are similar questions here: Deploy Spring Boot application in Weblogic ... but this other question is about deployment, and it's a bit vague (deployment itself works fine for me)