webapp deployed twice and quartz job running twice - java

I'm running a quartz job in my web application which is deployed in tomcat. But the problem is the job is executed twice.
After some internet research I've found that adding a new Host with autoDeploy in tomcat's server.xml may cause twice deployment. Which I guess is causing my quartz scheduler executed twice.
I tried with autoDeploy = "false". But the problem continues.
Here is the host config in my server.xml:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="false">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="demo.example.com" appBase="webapps/demo" unpackWARs="true" autoDeploy="false">
<Context path="/" docBase="." reloadable="true" />
</Host>
Edit (FYI):
my cron expression: 0 50 12 * * ? which is scheduled to run everyday at 12:50 pm.
Is this configuration will deploy my application twice? What can I do to avoid that? Thanks is advance.

If your observation is indeed correct then there could be multiple problems here -
In addition to custom location that you specified in server.xml, your app might be present in tomcat/webapps folder as well.
You might be using hot deployment from within some IDE and saving a file within IDE might be reloading the context, thus having quartz reinitialized again, which might be giving your wrong impression.
You indeed have some code problem.
It hard to say what's going on w/o looking at the code snippet but this should be fairly simple problem.

Related

Tomcat and vHost fails on specific subdirectory

i try to set my domain as vhost.
My config looks like this:
<Host name="example.de" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Alias>www.example.de</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="example_access" suffix=".log"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="" docBase="/opt/tomcat/webapps/app1" debug="0" reloadable="true" />
</Host>
This config works with every subdir in the webapps-directory, except for the directory I want. If I try to open the Domain, there is an empty browsertab. (Error 404) But if I call it like www.example.de/app1, the app still works and everything ist fine :/
I don't have any idea :/
PS: It's a clean setup of Tomcat, just extracted and edited the server.xml for the vHost-settings
Remember to deploy every application you'd like to appear in a virtual host, including the ROOT application. If you don't have a ROOT application, there is no "default" application that Tomcat can fall-back to, and your clients will get 404 responses when requesting /.

Unable to store cookies in war deployed from Tomcat7

I am using/trying to deploy grails war app to the tomcat7 virtual host configured in server.xml. I have modified etc/hosts to redirect www.mytest.com to localhost (referred from ramkitech). There seems no problem in the code as it works in development(By this, I mean I run my code from grails run-app and access http://localhost:8080/app/). The problem is when I deploy it to independent tomcat7 and put it as ROOT.war in the webapps folder and run the tomcat service, I can access the war based app at http://www.mytest.com:8080/ and when I try to set cookies, they do not seem to be stored and hence, I can't access the cookies set. By the way, the war was generated by the grails dev war. What could be going wrong here?
Server.xml
<Host name="www.mytest.com" appBase="webapps"
unpackWARs="true" autoDeploy="true" >
<Alias>mytest.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
I referred this from http://www.ramkitech.com/2012/02/understanding-virtual-host-concept-in.html and I am using grails cookie plugin 1.4 and basically call savePreference() with ajax providing sample cookie from the the view.
def savePreference(Map cleanParams=[:]) {
cleanParams.each{key,val->
cookieService.setCookie(key, val)
}
return "OK"
}
and here is sample cookie key value pairs I store:
prod_type:A
prod_categoryId:2
prod_id:3

How to map tomcat 7 webapp to my domain

I know this has been touched upon in several ways already, but i'm still having issues - I have a webapp in:
/var/lib/tomcat7/webapps/abc.war
I have a domain at say, my.domain.com
I've added this to my conf/server.xml (which i believe is set correctly?)
Docbase points to the war folder?
<Host name="my.domain.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/abc" debug="0" privileged="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
My domain ip is in the /etc/hosts along w/ the local host ip:
127.0.0.1 localhost
123.123.123.33 HostName.my.domaing.com HostName
$ /etc/hostnames
HostName
With my current settings above i'm am not getting any results in seeing my webapp online. Any thoughts would be very grateful!
My domain already is mapped to my /var/www/html directory too. I can see my temp index.html file online. My tomcat webapp works fine through ip:8080/abc
I'm working on Ubuntu Server 14.04 - Apache2
This is my first time working w/ tomcat and it's a bit confusing.
Thank You!
Your /etc/hosts should contain an entry like this:
123.123.123.33 my.domain.com
or
123.123.123.33 HostName.my.domaing.com HostName my.domain.com
Otherwise you won't be able to resolve the name my.domain.com to connect to your Tomcat.
If you already configured your firewall earlier, to redirect ports you type
sudo firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080 --permanent
and reboot it.

How to map domain to web application deployed on Tomcat 7 in Ubuntu?

I have a Java based web application which is deployed on Ubuntu machine. I can access the web application at localhost:8080 and it is working as expected.
Now I have domain name for the web application and I want to access web application through the browser using the domain name(http://www.xyz.com).
I want to know the steps which are required to achieve it. Before posting this question, I search over the google.
I have already added the host details in the conf/server.xml.
<Host name="xyz.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Alias>www.xyz.com</Alias>
<Context path="" docBase="" debug="0" privileged="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
Also, I made changes in the /etc/hostname and added following
<IP Address> www.xyz.com xyz
What else do I need to do?

Setting property 'source' to 'org.eclipse.jst.jee.server:GestorContenidoWS' did not find a matching property. Try all the solutions

This is my first post here (but not the first time that I visit the page, I found a lot of solutions here), first of all, sorry for my english I will try to explain myself as best I can.
This question appears another time in this page, but I tried all the solutions that the people post and I still with this problem, well here we go.
I made a project on Eclipse(indigo) for launch like a WebService (I did it before with succes, is not my first time) and when I Run on Server(Tomcat7) all seems fine and the appears this Warning.
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:GestorContenidoWS' did not find a matching property.
Then appear in the Web perspective of Eclipse the page "HTTP 404". I'm telling this because I read in other post that this Warning is not a problem, but seems that it is for me (The project is also vinculated with a JPA Persistence).
.I found two solutions for make dissappear this Warning. First, go to Server Overview and select the option 'Publish module contexts to separate XML files' and then try to Run on server again, but didn't work.
The other option was, remove the project from the server from the Server View. Then run the project under the same server for recreated server.xml, but didn't work also.
Anybody can help me? Maybe the problem of this "HTTP 404 requested resource (/GestorContenidoWS/) is not available." is in another part or its because this Warning?"
The code of my server.xml (without comments) is this:
<?xml version="1.0" encoding="UTF-8"?>
--><Server port="8005" shutdown="SHUTDOWN">
<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
<Listener className="org.apache.catalina.core.JasperListener"/>
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<GlobalNamingResources>
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory"name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1"redirectPort="8443"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
<Engine defaultHost="localhost" name="Catalina">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"resourceName="UserDatabase"/>
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/>
<Context docBase="GestorContenidoWS" path="/GestorContenidoWS" reloadable="true" source="org.eclipse.jst.jee.server:GestorContenidoWS"/></Host>
</Engine>
</Service>
Thank you
First of all this is a warning and not an error. So there is no need to worry too much about it. Basically it means, that Tomcat does not know what to do with the source attribute from context.
This source attribute is set by Eclipse (or to be more specific the Eclipse Web Tools Platform) to the server.xml file of Tomcat to match the running application to a project in workspace.
Tomcat generates a warning for every unknown markup in the server.xml (i.e. the source attribute) and this is the source of the warning. You can safely ignore it.
This is a warning and can be safely ignored. Tomcat or the Web container does not understand what to do with the property set by Eclipse
set contex-root
<property name="context-root" value="path" />
and http://localhost:8080/path
show your index file
Find server.xml. For example "C:\Dev\apache-tomcat-8.5.23\conf\server.xml"
Find your application in server.xml
<Context docBase="C:\Dev\apache-tomcat-8.5.23\wtpwebapps\SpringRestExample" path="/spring" reloadable="true" source="org.eclipse.jst.jee.server:SpringRestExample"/></Host>
Expected url http://localhost:8080/SpringRestExample/rest/emp/9999
But (path="/spring") instead (path="/SpringRestExample")
Therefore current url http://localhost:8080/spring/rest/emp/9999

Categories