Deployment of webapp in wildfly using Context Descriptors - wildfly

I searched using "How to set Context Path in Wildfly", but got no success. Can anyone help me on how to do it..?
I've used the following code to set the Context Path in tomcat where I can access my application directly using localhost:8080/myApp
myApp.xml contains as follows and placed at $CATALINA_BASE\conf\[enginename]\[hostname]\myApp.xml
<Context path="myApp" docBase="G:\workspace\j2ee\myProject\myWebApp\WebContent" />
similar or equivalent type of configuration want to use in Wildfly server.

In your standalone.xml configuration you want to add a deployment like this:
<deployments>
<deployment name="myProject" runtime-name="myProject.war">
<fs-archive path="G:/workspace/j2ee/myProject/myWebApp/WebContent"/>
</deployment>
</deployments>
Then within WebContent/WEB-INF create a file called jboss-web.xml with a configuration similar to:
<?xml version="1.0"?>
<jboss-web>
<context-root>/my-context-path</context-root>
</jboss-web>
If this doesn't work you may need to rename WebContent directory to WebContent.war, even if it is exploded it may want .war in the name.

Related

Set deployment order in Wildfly 10

I have 1 ear and some sar to deploy, I need to deploy sar1 before sar2, I tried to include jboss-all.xml inside Meta-INF in my sar2, but without results.
<?xml version="1.0" encoding="UTF-8"?>
<jboss xmlns="urn:jboss:1.0">
<jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
<dependency name="sar1.sar" />
</jboss-deployment-dependencies>
</jboss>
How can I set the deployment order?
Thanks in advance
I have not tried it but the RedHat EAP docs indicate that there are several possibilities listed here: https://access.redhat.com/solutions/18317
From the article:
Filename based ordering
Default order of deployment
deployer
-deployer.xml
sar
-service.xml
rar
-ds.xml
har
jar
war
wsr
ear
zip
bsh
last
The DeploymentSorter can be changed by changing the configuration in $JBOSS_HOME/server/$PROFILE/conf/jboss-service.xml
Assuming it works for WildFly also, you might just try renaming them to get the depoyment sorter to pick them up for filename based ordering?

WildFly 8.2 unable to configure for external property file

I am using the wildly 8.2 final , facing the configuration with external property file. My requirement is like this i am using jboss 5 earlier for locally . we were placed property file in this location jboss-5.0.0.GA\server\default\conf and using in application ear (spring property file configuration), but in wild fly we are unable to configuring i tried modules also, i.e we used the property file with out package
Specify location in standalone.bat file inside bin folder as shown below
set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME% - DpropertyName.config.dir=Path_to_config
Adding a module and putting your property files inside the module is the way to go.
Ensure the following:
That your module directory is created correctly, such as $JBOSS_HOME/modules/com/company/package/main.
That you have a valid module.xml file in the directory. It should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.company.package">
<resources>
<resource-root path="."/>
</resources>
</module>
Your property file(s) is in the directory.

Setting context-root path in Jboss

I want to deploy an application outside the "deploy" folder of JBoss in JBoss 6.0.0
my folder names must be specified in URL syntax. For example, to specify that C:/rev/deploy be used for deployment,inside deploy folder I placed my war file i.e,ORNC.war so I edited my profile.xml as
<property name="applicationURIs">
<list elementClass="java.net.URI">
<value>${jboss.server.home.url}deploy</value>
<!-- Add your own deploy folder -->
<value>file:///C:/rev/deploy</value>
</list>
</property>
After this I restarted my server. Now I am trying accessing: http://localhost:8000/rev/deploy/ORNC,
I am getting an error resource not available. How can I acess it? Please help me
Finally I got the answer my question ,Actually we need to create a jboss-web.xml file with below coding
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/rev/deploy/ORNC</context-root>
</jboss-web>
After that I placed this xml file in my WEB-INF folder of my WAR file.Now I can access my war file through http://localhost:8080/rev/deploy/ORNC
By referring this I get an solution for my question
JBoss 7: how to change a WAR context root
Thanks for Mr.simkam and Stackoverflow.

Context pointing to external directory in Jetty 9

I want to deploy a .war file to Jetty by setting up a context that points to my external .war (outside webapps folder). I know how to do this in Tomcat, but I can't figure out how to do this for Jetty 9.
In Tomcat I placed an .xml file to configure my context in $CATALINA_HOME/conf/Catalina/localhost :
<?xml version='1.0' encoding='utf-8'?>
<!-- Context fragment for deploying ServletExample.war -->
<Context path="/CurrencyServlet" docBase="/Users/macbook/Desktop/School/Java/Temp/CurrencyServlet.war" debug="0" privileged="true"/>
Can anyone provide a simple example for Jetty 9?
Have a look at the provided $jetty_home/webapps/test.xml file. In jetty9 you can configure your webapps, etc. by placing a ContextProvider config file in $jetty_home/webapps.
Have a look at the docs: http://www.eclipse.org/jetty/documentation/current/configuring-contexts.html
This is how you configure the path to your webapp:
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test</Set>

How do I change the context path of my Enterprise Project

So my enterprise project name TestProject, which contain TestProject-ejb and TestProject-war, so when I run the project the url is like this locahost:8080/TestProject-war. How can I change this url to localhost:8080/testproject. I use netbean 6.9, I try to right click on TestProject-war folder in netbean, and specify the context-path there under Run, but it still load locahost:8080/TestProject-war
You need to check that the context-root element for the web module in the application.xml file that's in the META-INF directory of your EAR has been correctly changed.
An example would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"
id="Application_ID" version="6">
<display-name>TestProject</display-name>
<module>
<web>
<web-uri>TestProjectWeb.war</web-uri>
<context-root>testproject</context-root>
</web>
</module>
<module>
<ejb>TestProjectEJB.jar</ejb>
</module>
</application>
In this example the web module should be available under /testproject of the server you deploy to, so in your case http://localhost:8080/testproject.
(In case you would like to deploy to the root of your server, you can leave the context-root element empty: <context-root></context-root>.)
If you indeed see that your action in Netbeans has correctly changed this file, it may be a deployment problem like BalusC indicated. Check the location the EAR is deployed to and manually inspect whether the deployed version also has the correct value.
As Harry pointed out the default project template doesn't create an application.xml file, so you have to create it by hand at $ENTERPRISE_APP_PATH/src/conf (tested with NB 6.9.1)
Just ran into this question in the course of figuring out the same thing. Since the OP was asking about doing this in Netbeans, let me add to previous answers by describing specifically how to do this using the Netbeans IDE.
With Netbeans 8 (and possibly also with earlier versions) you can tell the IDE to create the application.xml file for you, as follows. Right-click the enterprise application project (in the OP's example this would be "TestProject"), select "New" then "Standard Deployment Descriptor...". This will create an "application.xml" file and put it in the appropriate place in your Netbeans project. Then you can easily edit this file to set the context-root element to be whatever you want.