My goal is to have port 80 and 81 listen and serve content from two distinct paths. I'm looking at replicating what I used to do with IIS and creating websites on specific ports.
I took the base configuration file and added the following lines inside the Server tag (server.xml):
<Service name="stable">
<Connector port="80" protocol="HTTP/1.1" />
<Context docBase="C:\websites\test\stable\" />
</Service>
<Service name="release">
<Connector port="81" protocol="HTTP/1.1" />
<Context docBase="C:\websites\test\release\" />
</Service>
I was going on a tip where I had to install a Service tag with Connector and Context tag for each port I wanted to run (inside the main Server tag).
I looked at my log and found the following:
16-Jan-2011 8:54:44 AM org.apache.catalina.connector.CoyoteAdapter service
SEVERE: An exception or error occurred in the container during the request processing
java.lang.NullPointerException
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
at java.lang.Thread.run(Thread.java:619)
I am aware about the Context working better in a the more localized context.xml file, but I don't mind restarting until I get this working. Or maybe it NEEDS to be there (not per APress Pro Apache TomCat6).
At this point, going to IP:80 doesn't bring up nothing, no file, no error, just a blank page. Even when I try to access index.html (that was copied in the proper docBase), I get a blank screen without any errors.
Edit #2
I figured I'd post my files in case someone had more time on their hands and wanted a go at them.
Here's my server.xml file: http://pastebin.com/DAunTPTg
Here's the error I'm getting at the moment: http://pastebin.com/mrrd0116
Edit #3
To make things simpler, I've tried to have port 80 respond properly.
As per my book:
The name of this virtual host, as configured with DNS. One of the hosts nested within an engine must have a name that matches the defaultHost attribute of that engine.
Why would I be indicating anything but localhost (localhost1 wouldn't work would it?)
This is where I am at now, still not working:
<Service name="Stable">
<Connector
port="80"
protocol="HTTP/1.1"
connectionTimeout="20000" />
<Engine name="Stable" defaultHost="localhost">
<Host
name="localhost"
appBase="webapps">
<Context docBase="C:\websites\test\stable" />
</Host>
</Engine>
</Service>
I'm also getting a new errors:
18-Jan-2011 8:37:12 PM org.apache.catalina.startup.Catalina start SEVERE: Catalina.start: LifecycleException: Error initializaing : java.lang.NullPointerException at org.apache.catalina.core.StandardContext.start(StandardContext.java:4380) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
and
18-Jan-2011 8:36:47 PM org.apache.catalina.mbeans.ServerLifecycleListener createMBeans SEVERE: createMBeans: Throwable java.lang.NullPointerException at org.apache.catalina.mbeans.MBeanUtils.createObjectName(MBeanUtils.java:1086) at org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:504) at org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:570) at org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:366) at org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:535) at org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:498) at org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:656) at org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:628) at org.apache.catalina.mbeans.ServerLifecycleListener.createMBeans(ServerLifecycleListener.java:278) at org.apache.catalina.mbeans.ServerLifecycleListener.lifecycleEvent(ServerLifecycleListener.java:129) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.StandardServer.start(StandardServer.java:703) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Edit #4
I added the folder structure /Stable/localhost under the conf folder. Also added both host-manager.xml and manager.xml.
Still doesn't work.
Edit #5
I think I got it, well, I'm serving html and cfml pages with some errors in the log files.
<Service name="Stable">
<Connector
port="80"
protocol="HTTP/1.1"
connectionTimeout="20000" />
<Engine name="Stable" defaultHost="localhost">
<Host
name="localhost"
appBase="C:\websites\test\stable\">
<Context docBase="C:\websites\test\stable\" path="" />
</Host>
</Engine>
</Service>
Errors:
18-Jan-2011 11:31:40 PM org.apache.catalina.core.StandardContext resourcesStart SEVERE: Error starting static Resources java.lang.IllegalArgumentException: Document base C:\websites\test\stable\manager does not exist or is not a readable directory»
I think you're on the right track, but you're just missing some of the child elements that are listed in the specification for the Service element.
I think you're just forgetting the Engine and Host elements, which are grandparent and parent respectively to the Context element.
For more information and a more detailed example, which defines two Service elements, one on port 8080 and one on port 9080, see this mailing list post:
http://www.mail-archive.com/users@tomcat.apache.org/msg44729.html
This is working for me: