grails.app.context being ignored deploying to Tomcat - apache

I have an Apache server proxying all traffic from mainhost.com/subdirectory to someec2instance/subdirectory. When I start Apache and hit someec2instance.com, I get the ROOT war page. That works fine. If I deploy my app as ROOT.war, everything works fine form someec2instance.com.
However, when I access mainhost.com/subdirectory, all the asset urls and link_to urls are wrong and point to mainhost.com instead of mainhost.com/subdirectory.
I've set grails.app.context and confirmed via application.properties that the correct grails.env is being set.
Why isn't grails.app.context being respected when I deploy as ROOT.war? I would expect the site to be accessible on someec2instance.com/context, but it's like it ignore grails.app.context entirely.

The reason is doesn't work is that those settings are for running locally, not when deployed as a WAR file. When you use the tomcat or jetty plugin in run-app we configure the container to make it look like it's running an "exploded" war (similar to when a WAR gets unpacked to the file system by various servers). Since the container is running in embedded mode, it's easy to configure it programmatically as needed.
But when you deploy a WAR file there's nowhere near as much configurability. In run-app the build logic of Grails starts the server, configures it, and deploys the app, but a WAR file deployed to a "real" server is managed by the server and not the other way around.

Related

JSP file is served as plain/text, when TOMCAT is behind an APACHE server

I'm running in a strange problem. I have a project based on MAVEN. When I run the project directly from my computer for testing it, using mvn tomcat7:run, my website display is correct. When I upload it to my distant Tomcat server, that is accessed through the JK Apache Tomcat connector, the JSP page is served as a text file. In response headers, I can see Content-Type:text/plainwhich is almost strange, and I'm suspecting the Apache server is adding it because of some erroneous configuration.
Any idea where to look, to fix this problem ?

Netbeans project 404 + apache localhost XAMPP

I've created a web project in Netbeans. When I run it, it starts a glassfish server, and everything works fine (I don't understand why or how, but it works).
I also have XAMPP installed on my mac. I copied my netbeans project folder to my user sites folder, and ran my apache server with XAMPP.
I can access the sites index, but whenever I try to use a servlet, I get a 404, object not found.
Does this have something to do with glassfish web xml file? Servlet Mapping? Is there a new apache web xml file that I must create for it to work on apache server?
I can paste code if you need it.
Thanks!!!
Apache Server is for php based application and for running java based web project you have to install apache tomcat or glassfish as you have done previously where the servlet container is available.

Why does my work file work locally, but not on my webhosting server?

I developed a website and got a Tomcat account on Dailyrazor. My website runs fine when I start Tomcat from the command line and stick my war file in Apache's webapps folder. I access it by http://localhost:8080/dkashtanartportfolio/.
Now should it be as easy as dropping the war in my webapps folder on my DailyRazor Tomcat server? I expect to be able to access my website via http://www.<domain-name>.com/<war-file-name>/, which should look like http://www.dkartportfolio.com/dkashtanartportfolio/
I get a 404 error and I do not know why? Can anybody help?
Some of the DailyRazor accounts don't allow automatic deploy. So after uploading war you need to restart Tomcat. I use shell to execute tomcat_manage stop, followed by tomcat_manage start.
You may also be able to request restart by opening a help ticket.
For some reason, my accounts expect war's to be in public_html and not webapps. I have an old account so they may have changed the way new accounts work.
You need to look carefully into tomcat/conf/server.xml and make sure that you've specified correct path to app folder. Also you need to keep in mind that if you have shared tomcat you need to unpack your war file before requesting tomcat restart - it won't unpack automatically.

not able to deploy war file in jelastic cloud

I developed a web application using java and mongodb. I used glassfish server.
I tried to deploy it on jelastic cloud service
I uploaded my war file. But when I run it after deploying the war file it shows a 404 error. Why? The project works fine on my machine.
There are at least few potential causes:
your app needs some resources which are not started by default (such as DerbyDB). In this case you can check GlassFish log file - server_instance.log for more details.
you are trying to get resources from wrong context, make sure you are trying to get it via correct context name

serve a GWT application from the app server root

I have a GWT application, which I deploy as a WAR file to a Jetty 8 server.
I want it to be accessible via
http://<myserver>/
instead of
http://<myserver>:8080/MyApp/MyApp.html
I understand I can configure Jetty to run on port 80 instead of 8080 or have an apache instance running on port 80 and forwarding requests to Jetty running on 8080 (don't see a benefit of the latter, though).
but how can I deploy the GWT app to be accessible at the server ROOT?
so far I see I can create myapp.xml in Jetty/contexts folder and put
<Set name="contextPath">/</Set>
there. I can also rename MyApp.html to index.html. but I'm not sure this is the "recommended" approach
I think you pretty much answered your own question:
The application server (e.g. Jetty) is responsible for the context path, so you must set it somehow in the application server. This is different for each server, e.g. in Tomcat one possibility to achieve this is renaming the war file to ROOT.war. (I don't know all the possible ways how to do this in Jetty off-hand.)
Note: The file that is served when going directly to the context URL can be determined in your web.xml, using
<welcome-file-list>
<welcome-file>MyApp.html</welcome-file>
</welcome-file-list>
So you don't have to rename it to index.html.
ok, accepting my own answer:
create myapp.xml in Jetty/contexts folder
thank you, Chris!