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.