Re: Tomcat with multiple domains
Thank you guys for your great help. It was indeed an error in the xml that I entered in the server.xml file. I put something like this: Server port=8005 shutdown=SHUTDOWN ... Service name=Catalina ... Engine name=Catalina defaultHost=localhost Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true Host name=www.my2nddomain.com appBase=/opt/apache-tomcat-7.0.32/my2nddomain unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host /Host /Engine /Service /Server Notice that I nested the virtual host definition within the host definition tags of the default host. So, therefore it did not work and I didn't see it. Okay now it works perfectly fine. Again, thanks for your fantastic support! 2012/11/30 Hassan Schroeder hassan.schroe...@gmail.com: On Fri, Nov 30, 2012 at 2:12 PM, Christopher Schultz ch...@christopherschultz.net wrote: OP never posted the whole XML, so we don't know that it's definitely not well-formed. Good point -- should have asked for the whole file before jumping to that conclusion. But it certainly looked sketchy :-) -- Hassan Schroeder hassan.schroe...@gmail.com http://about.me/hassanschroeder twitter: @hassan - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat with multiple domains
Hi! Thanks for your quick and detailed answers. Actually I think I did all the things you mentioned but it still does not work. So here are the changes I made: 1. I checked that the following entries are in the engine tag: Server port=8005 shutdown=SHUTDOWN ... Service name=Catalina ... Engine name=Catalina defaultHost=localhost Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true Host name=www.my2nddomain.com appBase=/opt/apache-tomcat-7.0.32/my2nddomain unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host /Engine /Service /Server 2. In the host file I altered the entries to 88.84.140.85www.my2nddomain.com 88.84.140.85www.my1rstdomain.com 3. I actually did not really understand what you meant by Also, since you are using the /etc/hosts file instead of the DNS system, the client (browser) also has those entries in its hosts file. And, as Konstantin pointed out, you don't put the port number in the /etc/hosts file. If you are using DNS for the clients, make sure that it has entries for both hosts, pointing to the same IP address. I'm not shure if I understand the meaning of DNS in this case correctly. Do you mean a DNS on my local machine or do you mean the DNS on a remote machine? I've got a pure domain hoster and I set an A record entry such that the domain is forwarded to my server / ip address 88.84.140.85. Both domains are actually pointing to this ip address since both are hosted by the same domain hoster. I do not explicitly use DNS on my local machine, at least I did not configure it. And how can the client (browser) have entries in a host file? The current status is that when calling www.my1rstdomain.com:8080 points to the webapp installed for www.my2nddomain.com:8080. 2012/11/27 Jeffrey Janner jeffrey.jan...@polydyne.com: -Original Message- From: Paul van Hoven [mailto:paul.van.ho...@googlemail.com] Sent: Tuesday, November 27, 2012 2:13 PM To: Tomcat Users List Subject: Re: Tomcat with multiple domains Thanks for the answer. I followed the tutorial you propose ( http://wiki.apache.org/tomcat/TomcatDevelopmentVirtualHosts ). But it is still not working. Here is my new configuration server.xml Host name=2nddomain.com appBase=/opt/apache-tomcat-7.0.32/2nddomain.com unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Alias2nddomain.com/Alias Aliaswww.2nddomain.com/Alias /Host The directory /opt/apache-tomcat-7.0.32/2nddomain.com contains a ROOT.war file. I edited the /etc/hosts file and added the following entries: 88.84.140.88 www.2nddomain.com:8080 88.84.140.88 www.1rstdomain.com:8080 Then I restarted the system and the tomcat server. Entering www.2nddomain.com:8080 sends me to 1rstdomain.com. I noticed that the file /opt/apache-tomcat-7.0.32/2nddomain.com/ROOT.war remains untouched by tomcat, at least nothing is extracted from the war file. So what else am I missing here? Make sure that the new Host/Host definition is nested inside the Engine/Engine tags. You also do not need the first Alias line. The name= parameter takes care of that mapping for you. In general, the nesting works this way: Server ... Service ... Connector ... / Connector ... / Engine ... Host name=host1.com ... Aliaswww.host1.com/Alias /Host Host name=www.host2.com ... Aliashost2.com/Alias /Host Host name=www.myhost.com ... / /Engine /Service /Server There are a myriad other tag sets that could be included in there and it's very important that they be nested properly to work properly. Also, since you are using the /etc/hosts file instead of the DNS system, the client (browser) also has those entries in its hosts file. And, as Konstantin pointed out, you don't put the port number in the /etc/hosts file. If you are using DNS for the clients, make sure that it has entries for both hosts, pointing to the same IP address. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat with multiple domains
Thanks for the answer. I followed the tutorial you propose ( http://wiki.apache.org/tomcat/TomcatDevelopmentVirtualHosts ). But it is still not working. Here is my new configuration server.xml Host name=2nddomain.com appBase=/opt/apache-tomcat-7.0.32/2nddomain.com unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Alias2nddomain.com/Alias Aliaswww.2nddomain.com/Alias /Host The directory /opt/apache-tomcat-7.0.32/2nddomain.com contains a ROOT.war file. I edited the /etc/hosts file and added the following entries: 88.84.140.88www.2nddomain.com:8080 88.84.140.88www.1rstdomain.com:8080 Then I restarted the system and the tomcat server. Entering www.2nddomain.com:8080 sends me to 1rstdomain.com. I noticed that the file /opt/apache-tomcat-7.0.32/2nddomain.com/ROOT.war remains untouched by tomcat, at least nothing is extracted from the war file. So what else am I missing here? 2012/11/22 Caldarale, Charles R chuck.caldar...@unisys.com: From: Paul van Hoven [mailto:paul.van.ho...@googlemail.com] Subject: Tomcat with multiple domains I found the following tutorial (very old) on the web: http://onjava.com/pub/a/onjava/2006/08/30/publishing-multiple-sites-using-single-tomcat.html Probably best to completely ignore anything that old. I payed attention to the offical Tomcat documentation in regard of this: http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html That's good to look at, as is this: http://wiki.apache.org/tomcat/HowTo#How_do_I_set_up_Tomcat_virtual_hosts_in_a_development_environment.3F The steps apply to production as well as development. In my $CATALINA_HOME (which is /opt/apache-tomcat-7.0.32) I created the folder my2ndDomain This is only speculation (too lazy to look at the code right now), but domain names are defined to be case-insensitive, and typically presented only in lower case. What happens if you change my2ndDomain to my2nddomain everywhere? Context path=my2ndDomain debug=0 reloadable=false/ The above is really, really bad. You shouldn't be putting Context elements in server.xml, and besides, the contents of that one are gibberish. What did you expect to achieve with it? - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Tomcat with multiple domains
Hi! I'm trying to setup virtual hosts for my single tomcat webserver. I've got the following setup: Apache Tomcat 7.0.32 running on a server with one IP address. I forward any requests coming in on port 80 to port 8080 and from 443 to 8443 with a firewall rule. I have 2 domains and I would like to run these two domains on the same Tomcat machine. Therefore I had a look at the virtual host concept. I found the following tutorial (very old) on the web: http://onjava.com/pub/a/onjava/2006/08/30/publishing-multiple-sites-using-single-tomcat.html and I payed attention to the offical Tomcat documentation in regard of this: http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html So I made the following: 1. In my $CATALINA_HOME (which is /opt/apache-tomcat-7.0.32) I created the folder my2ndDomain 2. Then I copied the war file I'd like to deploy into the folder and renamed it. Such that now I have the following file in my folder /opt/apache-tomcat-7.0.32/my2ndDomain/ROOT.war 3. Then I modified my /opt/apache-tomcat-7.0.32/conf/server.xml the following way: Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true Host name=wettprofi appBase=my2ndDomain unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Aliasmy2ndDomain.com/Alias Aliaswww.my2ndDomain.com/Alias Context path=my2ndDomain debug=0 reloadable=false/ /Host 4. I restarted my Tomcat but nothing happened, entering www.my2ndDomain.com was routed to the standard first domain running. I'm wondering what I am doing wrong here. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Multiple Domains on one Tomcat Server now MySQL not working
Hi Chuck, thanks for this detailed answer. I'm running tomcat 6 on an ubuntu server. I read the official documentation and modified the configuration of my tomcat. The complete current server.xml (without comments and after my latest modification) looks like this: server.xml: Server port=8005 shutdown=SHUTDOWN Listener className=org.apache.catalina.core.AprLifecycleListener SSLEngine=on / Listener className=org.apache.catalina.core.JasperListener / Listener className=org.apache.catalina.mbeans.ServerLifecycleListener / Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener / GlobalNamingResources Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / /GlobalNamingResources Service name=Catalina Connector port=8080 protocol=HTTP/1.1 connectionTimeout=2 redirectPort=8443 / Connector port=8009 protocol=AJP/1.3 redirectPort=8443 / Engine name=Catalina defaultHost=localhost Realm className=org.apache.catalina.realm.UserDatabaseRealm resourceName=UserDatabase/ Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host Host name=localhost.localdomain debug=0 appBase=webapps2 unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Aliaswww.clubpirat.de/Alias /Host /Engine /Service /Server I checked that in /etc/hosts the two domains localhost and localhost.localdomain are assigned to 127.0.0.1. Now, i have the following directory structure: CATALINA_HOME/webapps CATALINA_HOME/webapps2 CATALINA_HOME/conf/Catalina/localhost CATALINA_HOME/conf/Catalina/localhost.localdomain CATALINA_HOME/webapps2/ROOT/META-INF In CATALINA_HOME/conf/Catalina/localhost.localdomain i got the following files: ROOT.xml log4j_errors.log manager.xml And the latter ROOT.xml looks like this: ?xml version='1.0' encoding='utf-8'? Context displayName=localhost.localdomain workDir=work/Catalina/clubpirat.de/_ /Context I also copied my war file into the CATALINA_HOME/webapps2 directory and tomcat has deploied the file. Okay, i when enter the url www.clubpirat.de but i get an 404 error. The other url works fine, no problems. Caldarale, Charles R schrieb: From: Paul van Hoven [mailto:paul.van.ho...@googlemail.com] Subject: Multiple Domains on one Tomcat Server now MySQL not working I'm not shure if this problem really relates to Tomcat but it happened after altering the tomcat configuration. Care to give us a hint about version of Tomcat you're using? Configuration is different from level to level. Therefore i search on the internet how to manage multiple domains on Tomcat. Might be better to read the real documentation first: http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html http://tomcat.apache.org/tomcat-5.5-doc/virtual-hosting-howto.html I found this resource: http://www.westsoftware.net/java/domains-on-tomcat.jsp. It's unfortunate you found that, since it's chock full of errors. Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host Host name=mydomain.de debug=0 appBase=webapps/myapp2 The above is not good; the different appBase directories must be distinct, not one under another. unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Logger className=org.apache.catalina.logger.FileLogger directory=logs prefix=mydomain.de-log. suffix=.txt timestamp=true/ Logger elements have not been used in Tomcat for some years. Aliaswww.mydomain.de/Alias /Host /Engine /Service /Server and i added the follwing ROOT.xml file in the folder $CATALINA_HOME/conf/Catalina/mydomain.de ROOT.xml: ?xml version='1.0' encoding='utf-8'? Context displayName=mydomain.de docBase= path= workDir=work/Catalina/mydomain.de/_ /Context Both the docBase and path attributes have invalid values; luckily, neither one is allowed here, and they are hopefully being ignored. Actually it works fine, i can now differentiate between the two webapps by the domain. What two webapps? You have only shown us one Context element. But while the first webapp has no problems accessing the mysql database i do have problems with the second webapp for which i added the new configuration. What's the first webapp? What Resource
Re: Multiple Domains on one Tomcat Server now MySQL not working
Hi Hassan, yeah, acutually that was the problem, I just discovered it an instant before you answered me :). I made the appropriate changes and now it is working fine. Thanks for your answer anyway. Tom Hassan Schroeder schrieb: On Mon, Oct 12, 2009 at 11:40 PM, Paul van Hoven paul.van.ho...@googlemail.com wrote: Host name=localhost.localdomain ... Aliaswww.clubpirat.de/Alias I checked that in /etc/hosts the two domains localhost and localhost.localdomain are assigned to 127.0.0.1. Okay, i when enter the url www.clubpirat.de but i get an 404 error. And does www.clubpirat.de resolve to your local computer? Either through an entry in /etc/hosts or DNS? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Multiple Domains on one Tomcat Server now MySQL not working
I'm not shure if this problem really relates to Tomcat but it happened after altering the tomcat configuration. I've two different domains for two differnt webapps. Therefore i search on the internet how to manage multiple domains on Tomcat. I found this resource: http://www.westsoftware.net/java/domains-on-tomcat.jsp. I modified the corrensponding configuration file in the following way: Extract server.xml: ... Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host Host name=mydomain.de debug=0 appBase=webapps/myapp2 unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Logger className=org.apache.catalina.logger.FileLogger directory=logs prefix=mydomain.de-log. suffix=.txt timestamp=true/ Aliaswww.mydomain.de/Alias /Host /Engine /Service /Server and i added the follwing ROOT.xml file in the folder $CATALINA_HOME/conf/Catalina/mydomain.de ROOT.xml: ?xml version='1.0' encoding='utf-8'? Context displayName=mydomain.de docBase= path= workDir=work/Catalina/mydomain.de/_ /Context Actually it works fine, i can now differentiate between the two webapps by the domain. But while the first webapp has no problems accessing the mysql database i do have problems with the second webapp for which i added the new configuration. The problem that i have now: I don't know what is happening here. I already checked the log files in the CATALINA_HOME/logs folder but i could not find anything. I also checked that the mysql connection for the second webapp works when invoking it by www.regulardomain.de/myapp2. Has anybody an idea what could cause this problem? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: On my Webserver: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
Yeah, that was it. Thanks for the great help. I deleted gwt-user.jar and now it runs perfectly fine. Juha Laiho schrieb: Caldarale, Charles R wrote: From: Paul van Hoven [mailto:paul.van.ho...@googlemail.com] Subject: Re: On my Webserver: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet gwt-servlet.jar I have some recollection that the above jar is the trouble maker; take a look inside it. Almost, but not quite.. I took an interest in this after seeing your response, and found the following: http://lkamal.blogspot.com/2007/07/jar-not-loaded-servletclass-gwt-tomcat.html ... which explains that gwt-user.jar is the problem, for which gwt-servlet.jar is the correction. There's also a tutorial by the same author describing that gwt-user.jar should be used for building and gwt-servlet.jar for deployment: http://lkamal.blogspot.com/2008/09/java-gwt-servlets-web-app-tutorial.html - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
On my Webserver: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
I just rented a server for providing an internet service. Before, i developped the application on my local machine which is running mac os x leopard. I also installed tomcat for testing my application. After creating a war file i place the webapp in the CATALINA_HOME/webapps folder on my local machine. After starting tomcat i can access the webapp on http://localhost:8080/myapp. It runs fine and everything works as expected. I also include all the necessary jars in the WEB-INF/lib folder. Okay so far so good, now, i copied the war file (that actually runs fine on my local machine) to the server into the folder CATALINA_HOME/webapps, as it should be done. Then, i start tomcat 6.0.20. The webserver starts fine and accessing it by entering http://www.myaddress.com:8080 the tomcat welcome page is greeting. I switch into the manager and it tells me that my app is loaded. But when i click on the link to the deployed webapp i get an error 500 and the following exception is thrown: javax.servlet.ServletException: Error allocating a servlet instance org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) java.lang.Thread.run(Thread.java:636) root cause java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(ClassLoader.java:637) ... Actually i do not understand this. The environment variables are set as follows: /usr/local/apache-tomcat-6.0.20/bin# ./startup.sh Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.20 Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.20 Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.20/temp Using JRE_HOME: /usr/bin But i also set the variables explicitly in my .bashrc by export CATALINA_HOME=/usr/local/apache-tomcat-6.0.20 export CATALINA_BASE=/usr/local/apache-tomcat-6.0.20 I start tomcat with root privileges. Every other app like the ones in http://www.myaddress.com:8080/examples/servlets/ are working fine. What is causing this problem? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: On my Webserver: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
Thanks for the answer. Here's a list of all the jars that i include: activation.jar antlr-2.7.6.jar c3p0-0.9.1.2.jar commons-beanutils-1.8.0.jar commons-codec-1.3.jar commons-collections-3.2.1.jar commons-fileupload-1.2.1.jar commons-httpclient-3.1.jar commons-io-1.4.jar commons-lang-2.4.jar commons-logging-1.1.1.jar dom4j-1.6.1.jar ejb3-persistence.jar ezmorph-1.0.6.jar gwt-maps.jar gwt-reverse-geocoder-1.0.8.1.jar gwt-servlet.jar gwt-user.jar hibernate-annotations.jar hibernate-commons-annotations.jar hibernate-testing.jar hibernate3.jar javassist-3.4.GA.jar json-lib-2.2.3-jdk15.jar jstl.jar jta-1.1.jar log4j.jar mail.jar mysql-connector-java-5.0.5-bin.jar sanselan.jar slf4j-api-1.5.2.jar slf4j-log4j12.jar spring-webmvc.jar spring.jar standard.jar I'm not sure if they duplicate things from the servlet-api.jar. David Smith schrieb: What jars are in your webapp? Did you include any that might duplicate those distributed in the servlet-api.jar file? --David Paul van Hoven wrote: I just rented a server for providing an internet service. Before, i developped the application on my local machine which is running mac os x leopard. I also installed tomcat for testing my application. After creating a war file i place the webapp in the CATALINA_HOME/webapps folder on my local machine. After starting tomcat i can access the webapp on http://localhost:8080/myapp. It runs fine and everything works as expected. I also include all the necessary jars in the WEB-INF/lib folder. Okay so far so good, now, i copied the war file (that actually runs fine on my local machine) to the server into the folder CATALINA_HOME/webapps, as it should be done. Then, i start tomcat 6.0.20. The webserver starts fine and accessing it by entering http://www.myaddress.com:8080 the tomcat welcome page is greeting. I switch into the manager and it tells me that my app is loaded. But when i click on the link to the deployed webapp i get an error 500 and the following exception is thrown: javax.servlet.ServletException: Error allocating a servlet instance org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) java.lang.Thread.run(Thread.java:636) root cause java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(ClassLoader.java:637) ... Actually i do not understand this. The environment variables are set as follows: /usr/local/apache-tomcat-6.0.20/bin# ./startup.sh Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.20 Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.20 Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.20/temp Using JRE_HOME: /usr/bin But i also set the variables explicitly in my .bashrc by export CATALINA_HOME=/usr/local/apache-tomcat-6.0.20 export CATALINA_BASE=/usr/local/apache-tomcat-6.0.20 I start tomcat with root privileges. Every other app like the ones in http://www.myaddress.com:8080/examples/servlets/ are working fine. What is causing this problem? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org