I have a simple webapp deployed within Apache Tomcat (7.0.x) which is bootstrapped using a ContextLoaderListener instead of a Servlet. I would like this webapp to NOT auto-start whenever the Tomcat server itself is started but instead only started/stopped manually via the Tomcat manager. The examples I see online show how this can easily be done with the following code for servlets within web.xml:
<servlet><load-on-startup>0</load-on-startup></servlet>
But no examples are available for when using a ContextLoaderListener. Is this possible at all? Or would I need to include a servlet in order to configure the webapp to NOT auto-start whenever the Tomcat server itself is started?
Thanks in advance,
PM.
You should read this recent discussion on the Tomcat users' list which I believe answers your exact question: http://markmail.org/message/5hp3dohwj3vncg4c
The bottom line is that you can start only the Manager webapp on startup, but there are some restrictions about what happens after a restart. The replies from Mark Thomas are the most useful.
I don't think you will be able to do this in web.xml. load-on-startup is used to tell the webapp to start a servlet when the webapp is started. A webapp often consists of multiple servlets.
If you want to make sure the webapp is not loaded at startup, and instead use Tomcat manager to start it, I suggest you set deployOnStartup="false" in the <Host> container, in settings.xml. See the Tomcat 7 documentation page for the details:
http://tomcat.apache.org/tomcat-7.0-doc/config/host.html
Related
I am trying to make a jetty web app to display content from a template.
The code I have is a java file with the class that holds the information, a pom file, and a template.tpl file.
When I run mvn jetty:run, it spins up a server on port 8080 and points to the root od my web app folder.
How do I make it so when I type /template.tpl i can run java to fill the template?
Thanks in advance
Have you configured a web.xml file yet? Here's a guide on how to do this.
Basically in your web.xml file, you configure the Servlets you write and map them to matching urls.
I am trying to embed ActiveMQ Server within Tomcat 8 server.
For that I was following two tutorials available online.
https://isomorphic.atlassian.net/wiki/display/Main/Real-Time+Messaging+with+Tomcat+and+ActiveMQ
and
http://www.tomcatexpert.com/blog/2010/12/20/integrating-activemq-tomcat-using-global-jndi
In first tutorial changes were made only in $TomcatHome/conf/context.xml. But in second tutorial it was recommended to modify context.xml, server.xml and activemq.xml.
I follows both the tutorial separately one by one, also tried to use these with "Tomcat 7". But looks like both are not working for me.
With these changes, tomcat server starts without any issue no error in log. But Embedded ActiveMQ BrokerService is not getting started with Tomcat. Nothing is there in startup log for BrokerService.
Means there is no effect of these configurations on Tomcat Serve, and startup log is same with or without these configuration.
Am I missing anything in configuration for Tomcat 7 or Tomcat 8?
Why new JNDI Resource TAGs in configuration files is not getting picked by Tomcat?
Guys please help me.
I suggest looking at starting up ActiveMQ using the Spring XML bean configuration. Generally, you'll need/want to do some configuration of the broker and having the full XML is a simple way to manage that. I suggest looking at creating a simple war file that starts up a Spring beans.xml file. That file should just be the same contents as the conf/activemq.xml configuration. You then add all the JNDI resources as needed to point to the embedded broker.
I'm moving old GWT app from one server to another. Both in Eclipse and on old Tomcat everything is working OK, but on new server GWT app gets loaded (so the server is working and serving files), but fails on RPC call returning 404.
My admin and I have looked at possible differences in context paths, Tomcat and Java versions, and tried to recreate config on the new server as close as possible but it seems that we're missing something so I'm looking for fresh ideas.
As mentioned on this link under common pitfalls, it indicates that web.xml is misconfigured, but this is ruled out as the same web.xml works OK on old server. My #RemoteServiceRelativePath is "app.rpc" and in web.xml this is mapped to:
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.rpc</url-pattern>
</servlet-mapping>
...and in dispatcher servlet this is mapped to a correct controller. I can also give server.xml or any other part of config if needed, but I'm looking for other things that could be incorrect.
Solved it, but by going nuclear and copying the exact same Tomcat and Java version with the same paths and all settings as on the old server. What I do know is that it was not a network problem, and that the request was received by Tomcat but never got to GWT or application code; so either Tomcat (5.5 in original configuration, 6.0 in the) or Spring (2.0.2) is the culprit. This is the old application that won't be updated and is due to be replaced and I hope it dies a quick and painless death.
I have guvnor deployed on tomcat 7. Now need to deploy a wrapper webservice around the BRMS. The webservice is a spring-ws and uses #Autowired kbase dependency injection. kbase is configured in spring-context XML as (not literal):
<drools:resource id="xxx" source="http://localhost:8080/guvnor/.../<package>/LATEST
Now the problem is tomcat first loads the webservice which fails to initialize as the guvnor URL is not up yet.
I can work around this by first starting only guvnor along with tomcat startup and then copy the WS war to the webapps folder. This works but is painful to do everytime.
What is the best approach?
I have seen this thread, but not sure if it will work in this context: Is there a way to enforce a deployment order in tomcat6?
Tried the following ways to address this:
Tomcat brings up both services on starup. The initialization of webservice fails but bring up the webservice manually through tomcate admin interface.
Use a script to do the same as above to bring up the webservice after a delay.
Change the drools package initialization to load through drools API instead of through config files along with a retry logic.
All of these work, but retaining the last option in the production code.
My question is about deployment to a Tomcat server instance which hosts multiple applications and hosts application contexts for Struts, Spring, and Hibernate. I would like to deploy changes to one application without restarting my Tomcat server.
As an example, many times in our firm we have to deploy new applications or versions of applications to our tomcat enviroment and the process could be:
Move class and jsp to the exploded folder then the context reload itself, or
Another scenario is when we have to deploy new features which require
modifications to xml contexts such as struts-config.xml or spring-application-context.xml.
Currently we have to restart the web-server to load new configuration. This would be OK if Tomcat did not have other live applications which we did not want to interrupt and restart. As an example, if I have an application which uses hibernate and struts, then I have to re-deploy it to a Tomcat server with many other applications running, and I deploy the new application and restart the server. This is not ideal.
So the question is when deploying changes to Tomcat, including context changes, do I have to restart? Is there a way to do a hot deploy for only this specific application and maybe re-start only its context without restarting the webserver?
Thanks a lot!!
Best regards
You can set the "autoDeploy" attribute to "true" in server.xml. You can read more detailed information here http://www.mulesoft.com/tomcat-deploy.
Hope this helps.