I have a java spring web application running on a local widlfly. Until now it was always the case that I called the webapp via the URL "localhost:8080/myapp". Now I have set my context root in the jboss-web.xml to "/". My assumption would be that I can now call the website via localhost:8080/. But this redirects me to the Widlfly welcome content. I can only call my webapp via "localhost:8080//". Can I set the context root so that I reach the webapp via "localhost:8080"?
Thanks for your help.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web version="10.0"
xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_10_0.xsd">
<context-root>/</context-root>
</jboss-web>
You need to disable the default welcome app
Related
Excuse me, I'm new to this. I have developed an application with maven, and when I run the application in my wildfly it opens the following path: "127.0.0.1:8080/myapp-1.0.0" and everything runs perfect, but I simply want that:
x.x.x.x/ point to: x.x.x.x:8080/myapp-x.x.x
I do not know if it is a configuration in standalone.xml as it redirects or something more complicated.
If you only have a single web application, the simplest way is to have jboss-web.xml file in your web application. Put a file like:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web version="10.0"
xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_10_0.xsd">
<context-root>/</context-root>
</jboss-web>
in your WEB-INF directory. This will make your application run at the / context. Note that this isn't redirection - it's permanently there. Additionally, if you have many webapps running on your Wildfly server they will all need a unique context root.
I've seen this link and this one but I can't find the sun-web.xml anymore. I am going through the java ee 7 tutorial, specifically the hello1 application. I don't understand how the application knows that /hello1 is the context root, I mean, I don't see it specified anywhere in the web.xml file under /WEB-INF/web.xml. How does glassfish know, and how can we change it to, perhaps, /abc for example.
By default, context root is the same as package name.
If you use wildfly or jboss, you can add jboss-web.xml to webapp/WEB-INF/ to change context root, content like:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.jboss.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<context-root>yourownroot</context-root>
</jboss-web>
I have a Java web application using Wicket 6, Spring 3.2 and WildFly 8.2.0. Right now i'm setting the context root of my web application in the jboss-web.xml file like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
<jboss-web>
<context-root>/myCustomContextRoot</context-root>
</jboss-web>
The jboss-web.xml file is compiled into the war. Now some clients want to change this context root to an empty context root. So i hace to recompile a version of my app per different context root. Is there a way to set the context root of my application from outside .war, programatically from a .properties file, or any other way for example in standalone.xml of WildFly 8.2.0?
Set the runtime name when deploying your web application. Suppose your WAR is called myapp-1.0.0-SNAPSHOT.war. Using a runtime name of foo.war, the context root will be /foo.
Using a runtime name of ROOT.war, the context root will be /.
The runtime name can be set when deploying via the Web Console or via the CLI.
Thanks for your Answer Harald Wellmann. It answers the question and pointed me into the right direction!
Some things I had to find out on my own and which may help others:
the exact syntax in jboss-cli to specify a runtime-name is:
deploy path_to_war_file --runtime-name=wantedName.war
This leads to a context-root of /wantedName/ for the webapp.
The runtime-name does not have any effect on the context-root, if the war file contains a jboss-web.xml in WEB-INF which in turn contains a context-root tag.
That is, if you want to control the context-root of your web-app in WildFly at deployment time, you must not specify any context-root in jboss-web.xml.
It is ok to have a jboss-web.xml without a context-root tag if you want to take advantage of the runtime-name to control the context-root.
I tested this on WildFly 9.0.1 and 9.0.2:
Hope this helps!
I have a RichFaces WAR file that deploys itself to http://mytestserver:8080/mywarapp/index.jsp. I deploy it on the Wildfly Application Server.
Now I would like to access the WAR file not through this long http-address, but through the main server address: http://mytestserver/
How would I have to do that?
You should change context path of your application.
To do this you need to create file jboss-web.xml and place it in WEB-INF directory. jboss-web.xml should contain:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/</context-root>
</jboss-web>
If you want to change port of your application from 8080 to 80 you can do this in few ways.
1) [not recommended] change port in your standalone/domain.xml from 8080 to 80 and run wildfly as a root/administrator
2) run nginx/apache or any other webserver and create there proxy redirect eg. in nginx you need to add to your configuration file something like this proxy_pass http://mytestserver:8080/; (if you didn't add jboss-web.xml you need append here mywarapp to this URL ) and your application will be available via URL http://mytestserver/
What could be the reason for the error: Error 404: SRVE0190E: File not found: /SimpleServletPath
I am deploying in websphere liberty profile server.
I can't reach my admin console login page
I can reach my welcome page on my websphere liberty profile server but can't do so after creating a servlet. That's when the above 404 error comes up.
There are similar posts online that advice to change com.ibm.ws.webcontainer.invokefilterscompatibility=true . I can't find how to set this parameter because I can't hit the websphere admin console login.
I installed websphere through eclipse marketplace.
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
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_3_0.xsd">
<display-name>ServletExplore</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app
By default, your app's context root will default to the name of the application. You can change it (including setting it to /) by looking at the server on the Servers tab and editing its configuration. You can make changes in the GUI or directly in the server.xml.
If your app is called my app, I suspect localhost:9080/myapp/SimpleServletPath is where your servlet is currently living.
You are probably using annotation #WebServlet in your servlet, but you have web.xml file. Remove web.xml file from your project and run again.