Modify Default context root in Websphere Liberty Error CWWKZ0013E - webserver

I am trying to run my application without having a default context root, i.e. I want localhost:8080 to redirect to my homepage rather than go to localhost:8080/myapp
For this in server.xml I put the following lines:
<httpDispatcher enableWelcomePage="false" />
<webApplication id="MYAPP" name="MYAPP" contextRoot="/" location="dropins/MYAPP.war" />
I get an error
[ERROR ] CWWKZ0013E: It is not possible to start two applications called MYAPP.
However if I put in the dropins folder myapp.war instead of MYAPP.war this error doesn't come and the app works. However in the apps/expanded directory I see both myapp.war & MYAPP.war expanded (even though MYAPP.war doesn't exist).
I followed the instructions in WLP :: Change default context root on http. Could some guide me where I might be going wrong?

Don't use <webApplication> with dropins/. Instead, move the WAR to the apps/ directory and use <webApplication ... location="MYAPP.war"/>.

Related

WildFly: jboss-cli's add module creates a wrong folder

I am taking my very first steps with WildFly application server. I want to create a database driver.
I had a look at https://www.adam-bien.com/roller/abien/entry/installing_oracle_jdbc_driver_on on how to do it manually. And now I want to do it by jboss-cli.sh. I read about these commands e. g. here and here.
So I am typing...
wildfly-26.0.0.Final/bin$ ./jboss-cli.sh -c
[standalone#localhost:9990 /] module add --name=com.oracle --resources=/home/user/Downloads/ojdbc8.jar --dependencies=javax.api,javax.transaction.api
The command is going to be executed without error.
I would expect it to
create the module-subfolders (step 2 in the linked tutorial by Adam Bien)
copy the JAR file to the newly created folder (step 3)
create the module.xml file (step 4)
maybe even to add the necessary <driver /> tag in the standalone.xml (do not know if that should be part of the add module command?) (step 5)
Basically it does a lot of that, but different than I expect.
It creates the subfolder in a wrong(?) location. It is not created in [WILDFLY_HOME]/modules/system/layers/base/com/oracle/main like it is decribed by Adam Bien but it is created [WILDFLY_HOME]/modules/com/oracle/main. The JAR file is correctly copied, the module.xml file is created but the folder seems to be wrong. And the standalone.xml is not altered at all.
If I start the web management console I do not see the driver next to the default H2 one.
So my question is what am I doing wrong with the command so that the folder is created in the correcy localtion? Or does this work as designed and the location is not that relevant and I am making other mistakes that it does not show in management console nor in standalone.xml?
By the way, I also tried to change the command module add --name=system.layers.base.com.oracle .... Now the folder was correct, but in the module.xml the name of the module was also system.layers.base.com.oracle.
I tested with WildFly 26.0.0 and WildFly-preview 26.0.0 under Ubuntu.
It should not be created in modules/system/lasers/base. That is for components provided by the container. Having the module off the root $JBOSS_HOME/modules directory is correct.

IBM Liberty issue

An architect is having issues bringing Liberty up. Currently, an individual is running a server on his local computer and they want to move it to a shared server. When he tries to deploy a simple “helloworld” it’s failing and he is receiving an error “Context Root Not Found”. He is not sure what to set in server.xml file to have wlp recognize the application. They have ODM 8.5 on the mainframe. He thinks it might help if he saw an example of an EAR or WAR file deployed. Any ideas or suggestions?
Either put your application in the dropins folder, it will be detected and started automatically, or put it in the apps folder and configure in server.xml like this:
<webApplication id="HelloApp" location="HelloApp.war" name="HelloApp"/>
by default context root is application file name without extension, but you can change it by adding contextRoot="mycontext" attribute.

Tomcat 6 Eclipse root deployment

I have a Java web application running on Tomcat6 built with Eclipse. It has always been run in a subdirectory:
/webapps/appDIR
As a result, the URL is:
www.application.com/appDIR
I now want it to just be deployed to the top level. I rename the directory to ROOT and extract the WAR. Set the permissions, and it doesn't work. It goes to an infinite redirect of the error page, and then the page dies.
I can rename the the directory to anything else and it works. For example I could call it test, in which case the URL becomes:
www.application.com/test
.....works fine. I just can't use "ROOT", which would allow the wwww.application.com URL to work.
I did some searching, and decided it was related to the context.xml file. It is currently sitting in the /WEB-INF directory (wrong?), and it only contains an end tag of "" (more wrong?). I moved that file to the /META-INF directory, and it didn't work. I figured that maybe it couldn't be empty and I added the contents of the following link to it:
http://www.wellho.net/resources/ex.php4?item=a654/6_context.xml
And still no go.
Any ideas? For a little more background, I'm now deploying it to Amazon's Beanstalk whereas before it was self hosted. Beanstalk defaults to deploying to ROOT, and I didn't see a reason to fight them on it, whereas Eclipse feels differently.
You mentioned: "Beanstalk defaults to deploying to ROOT, and I didn't see a reason to fight them on it".
If you care to fight -
A hack to be sure, but to get our app to deploy under a subdirectory, we did the following with a beanstalk config file (.ebextensions)
commands:
# This modified the default beanstalk deploy script so that our WAR file sits in appropriate subdirectory.
fixdeployscript:
command: sed -i 's/webapps\/ROOT/webapps\/MyAppName/g' /opt/elasticbeanstalk/hooks/appdeploy/enact/03deploy.sh

Configure the path (localhost) of the war application to be the root (Java EE)

I want to change the path when I run my war-application locally...
Right now, it is running on the default setting...
http://localhost:8080/myproject-war/
and I want it to be the root, something like:
http://myproject-war.local/
or
http://myproject:8080/
How can I do that???
Note: My app is a Java EE 6 Application with Glashfish using Netbeans 7.3
This post helped me out How do you deploy a WAR that's inside an EAR as the root (/) context in Glassfish?.
First, I added a Standard Deployment Descriptor (application.xml) to the Enterprise Application Project.
Then, change the path of the context root of your web application: <context-root>/myproject-war</context-root> to <context-root>/</context-root> or <context-root />
Finally, (optional) remove or rename the Glashfish index page (or redirect it to the welcome page). located in the Glashfish default folder such as C:\Program Files\glassfish-3.1.2.2\glassfish\domains\domain1\docroot
Now the page web application will be visible on: http://localhost:8080/
Maybe you are mixing up stuff here - one thing you can and should do is setting the context root of your application. This is done in the server's deployment descriptor - in your case in glassfish-web.xml:
<context-root>/myproject</context-root>
(See The Java EE 6 Tutorial for more details.)
What you're asking in your example URLs is changing the host name, which is not related to your application or application server, but to your machine and OS settings.
You may put something in the OS hosts file (/etc/hosts on Linux, C:\Windows\System32\drivers\etc on Windows), but I don't see the point to do this. Your application runs on some host (may it be localhostor some external server) and this is how your URL starts.
you can put entry in host file. which is located in "C:\WINDOWS\system32\drivers\etc".
127.0.0.1 your_project_name

crossdomain.xml location when Tomcat is running in Eclipse

I need to use a crossdomain.xml file to access my WebApp from a dev sandbox.
I gather from other SO posts that it should be accessible at http://localhost:8080/crossdomain.xml , hence in tomcat ROOT webapp.
Where the heck is that ROOT directory when running Tomcat in Eclipse?
Edit: Tomcat is using a Runtime Environment named "Apache Tomcat v6.0" which is using a "Tomcat installation directory" set to "D:\dev\apache-tomcat-6.0.33"
I tried to drop crossdomain.xml in "D:\dev\apache-tomcat-6.0.33\webapps\ROOT" but I still get a 404 trying to access http://localhost:8080/crossdomain.xml from a browser. In fact, anything in that ROOT directory is accessible.
Edit 2: In the server launch configuration, there is an "Arguments" tab listing the following -Dcatalina.base="D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1" -Dcatalina.home="D:\dev\apache-tomcat-6.0.33" -Dwtp.deploy="D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps" -Djava.endorsed.dirs="D:\dev\apache-tomcat-6.0.33\endorsed"
Hence, I pasted the crossdomain.xml into D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ROOT and ... it worked. Seriously.
Thanks in advance
As per edit #2
In server launch configuration, there is an "Arguments" tab listing the following VM Arguments
-Dcatalina.base="D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1" -Dcatalina.home="D:\dev\apache-tomcat-6.0.33" -Dwtp.deploy="D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps" -Djava.endorsed.dirs="D:\dev\apache-tomcat-6.0.33\endorsed"
Hence, I pasted the crossdomain.xml into D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ROOT