17

I've used the following code to set the Context Path in tomcat where I can access my application directly using localhost:8080 by overriding the tomcat's default path.

<Context path="" docBase="G:\bitbucket\projectpath\project\build\libs\project-1.0" workDir="G:\bitbucket\projectpath\project\build\libs\project-1.0\work"  debug="0" reloadable="false" autoDeploy="true" unpackWARs="true" crossContext="true"/>

Now I'm going to use wildfly-8.2.0 as runtime environment. I tried by directly pasting the .war file into G:\wildfly-8.2.0.Final\standalone\deployments and I can access my project in browser like localhost:8080/project-1.0.

I need to setup the same configuration to wildfly like I've done in tomcat to access my project in localhost:8080 by overriding the wildfly's default welcome page. I tried to do the same in wildfly but I'm stuck where to do that. There are lot of .xml files in wildfly folder (when comparing with tomcat's simple server.xml file) which I get confused on where to start with. I searched using "How to set Context Path in Wildfly", but got no success. Can anyone help me on how to do it..? If it's related to coding, then I can do lot of searches and atleast I can get some Ideas, but I'm stuck here at configuration. Thanks in Advance.

2 Answers 2

44

You can do this in the by adding a /WEB-INF/jboss-web.xml file in the application that you deploy:

<?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>/</context-root>
</jboss-web>
8
  • Got it working.. Thanks.. Btw I'm experiencing a wierd problem, I've started the wildfly using this command, ./standalone.sh -b xxx.xx.xx.xxx > $HOME/web.log 2>1 & and for stopping it, I used ./jboss-cli.sh --connect command=:shutdown .. Everything works fine, if I start the server, I can access the respective website, If I stop the server access the website, chrome tells me "No Response from Server".. But something wierd happened once I laid my hand on sqlserver.
    – The Coder
    Feb 12, 2015 at 11:38
  • I have created a db using dump in sqlserver, then after that whenever I deploy my .war file, it keeps coming as deploy failed, I tried a lot. Even after I use the shutdown command, I can access the site which gives me 404 not found message. I think one process is running in the bacground which is not stoppoing even after shutdon command. Do you know how can i resolve it?
    – The Coder
    Feb 12, 2015 at 11:38
  • When you start the process is it not a good way to use the stdout to redirect the log. It is better to remove the console appender from the logging configuration to avoid fillup the filesystem in $HOME/web.log. Just remove console handler from the root-logger. You can add it again without restarting on your server using boss-cli.
    – deleze
    Feb 17, 2015 at 0:54
  • 6
    If anybody is wondering: The current schemaLocation of the xml namespace is xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_7_2.xsd" Nov 23, 2016 at 8:20
  • you might also have to remove the welcome-content folder of your wildfly distribution if you want to use /. Sep 9, 2017 at 10:58
0

Change context-root directly in WebService class with annotation.

import org.jboss.ws.api.annotation.WebContext;

@Stateless
@WebService(portName = "SampleWSPort", serviceName = "SampleWS")
@SOAPBinding(style = Style.DOCUMENT)
@WebContext(contextRoot = "/SWS", urlPattern = "/SampleWS")
public class SampleWS implements SampleWSInterface {

org.jboss.ws.api.annotation.WebContext is in MAVEN artifact:

<dependency>
   <groupId>org.jboss.ws</groupId>
   <artifactId>jbossws-api</artifactId>
   <version>1.1.2.Final</version>
</dependency>
2
  • I think the dependency it's not correct, the library does not have @WebContect annotation. Dec 1, 2020 at 13:39
  • very nice solution that works with WildFly 12! Apr 28, 2021 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.