I am working on a web project that requires Weblogic server and the only way I can view the site after deploying (on my Macbook Pro) is by specifying the application name as a prefix to the entire site. E.g.
http://localhost:7001/myapp-weblogic/
This breaks a ton of styling and JavaScript code that access resources with root URLs (e.g. /images/example.png)
While I can programmatically add "/my-app" to content in a .jsp, I can't do that in my .css files.
I tried setting the "Default WebApp Context Root:" in Weblogic > console > Environment > Servers > myserver > Protocols > HTTP - But that did not work.
This seems like it should be such a simple thing. In IIS I would simply add a line to my local hosts file and add the host name to my IIS container - taking me a grand total of about 42 seconds.
127.0.0.1 myapp.local -> Let's me view my site at http://myapp.local
Thank you in advance for any insight!
UPDATE!! I finally got things working. Some of this is very specific to my setup, but hopefully still helpful to others.
To get it working I needed to do 3 main things and one other related thing:
- Set the default application for the server in Weblogic
- On your local server, go to the console and log in
- Go to: Weblogic > console > Environment > Servers > myserver > Protocols > HTTP
- Set the "Default WebApp Context Root:" to "/" + your application (e.g. "/myapp")
- Set the context-root of the project in MyEclipse
- With your project open in MyEclipse, right-click on the project and select properties
- Expand "MyEclipse" and choose "Web" and set the Web Context-root to "/"
- Set the value of context-root in the project weblogic.xml file to "/"
- This file should be located in the WEB-INF folder of your project
- Save the file and build the app
- Redeploy your app - you may need to restart your server too
Setting my local path variable to "/"
So another thing I had to do was set a path variable i was referencing to "/". When you request the path (request.getContextPath(); ) it does not prepend the path with a "/" and if you try to use something like <c:url context="${ _path }"
if the the _path variable does not begin with a "/" it will throw an exception.
That last bit was something I encountered from working with someone else's code.
In application.xml specify the below setting
<web>
<web-uri>yourweb.war</web-uri>
<context-root>/</context-root>
</web>
Now you can make a call without context root as
http://localhost:7001/
I assume because you are using weblogic you deploy a java application.
The structure should be a 'war' file.
More info on the structure you can find here.
http://www.openscope.net/2010/01/25/war-deployment-file-structure/
The name of the context root (by default name of the war) might be as well overridden
https://forums.oracle.com/forums/thread.jspa?messageID=10366462
Hope it helps.
来源:https://stackoverflow.com/questions/15843594/how-can-i-use-weblogic-12-c-without-the-application-context-in-the-url