2014-11-04 90 views
0

我想在Tomcat中使用以下server.conf運行兩個BaseX實例。我遇到了一個奇怪的問題:它們都在各自的端口上可用,但是webapp本身是相同的WAR;即webapps/WAR中只有的鏈接出現在從webapps2加載的WAR中。我不確定我的下一步應該是什麼 - 我會問BaseX郵件列表,但他們沒有在那裏使用很多的Tomcat。Tomcat多服務 - 啓動問題

這裏是我的server.conf中

<Service name="Catalina"> 
    <Connector port="8080" 
      protocol="HTTP/1.1" 
      connectionTimeout="20000" 
      redirectPort="8443"/> 
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/> 
    <Engine name="Catalina" defaultHost="localhost"> 
    <Realm className="org.apache.catalina.realm.LockOutRealm"> 
     <Realm className="org.apache.catalina.realm.UserDatabaseRealm" 
       resourceName="UserDatabase"/> 
    </Realm> 
    <Host name="localhost" 
      appBase="webapps" 
      unpackWARs="true" 
      autoDeploy="true"> 
     <Valve className="org.apache.catalina.valves.AccessLogValve" 
       directory="logs" 
       prefix="localhost_access_log." 
       suffix=".txt" 
       pattern="%h %l %u %t &#34;%r&#34; %s %b"/> 
    </Host> 
    </Engine> 
</Service> 
<Service name="Catalina2"> 
    <Connector port="18080" 
      protocol="HTTP/1.1" 
      connectionTimeout="20000" 
      redirectPort="18443"/> 
    <Connector port="18009" protocol="AJP/1.3" redirectPort="18443"/> 
    <Engine name="Catalina2" defaultHost="localhost"> 
    <Host name="localhost" 
      appBase="webapps2" 
      unpackWARS="true" 
      autoDeploy="true"> 
     <Valve className="org.apache.catalina.valves.AccessLogValve" 
       directory="logs2" 
       prefix="localhost_Cat2_access_log." 
       suffix=".txt" 
       pattern="%h %l %u %t &amp;quot;%r&amp;quot; %s %b"/> 
    </Host> 
    </Engine> 
</Service> 

當我啓動Tomcat,一切都在這兩個服務的負荷還好,除了第二BaseX應用。當Tomcat開始加載時,我收到以下錯誤:

INFO: Starting service Catalina2 
Nov 03, 2014 7:59:58 PM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53 
Nov 03, 2014 7:59:58 PM org.apache.catalina.startup.HostConfig deployWAR 
INFO: Deploying web application archive /usr/home/cob/src/apache-tomcat-  7.0.53/webapps2/bX79.war 
Nov 03, 2014 7:59:58 PM org.apache.catalina.core.StandardContext loadOnStartup 
SEVERE: Servlet /bX79 threw load() exception 
    java.net.BindException: Address already in use 
    at java.net.PlainSocketImpl.socketBind(Native Method) 
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) 
    at java.net.ServerSocket.bind(ServerSocket.java:376) 
    at java.net.ServerSocket.bind(ServerSocket.java:330) 
    at org.basex.BaseXServer.<init>(BaseXServer.java:110) 
    at org.basex.http.HTTPContext.init(HTTPContext.java:379) 
    at org.basex.http.BaseXServlet.init(BaseXServlet.java:34) 
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284) 
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197) 
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087) 
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) 
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) 
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632) 
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073) 
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:745) 

Nov 03, 2014 7:59:58 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory /usr/home/cob/src/apache-tomcat-7.0.53/webapps2/examples 
Nov 03, 2014 7:59:59 PM org.apache.catalina.core.ApplicationContext log 
INFO: ContextListener: contextInitialized() 
Nov 03, 2014 7:59:59 PM org.apache.catalina.core.ApplicationContext log 
INFO: SessionListener: contextInitialized() 
Nov 03, 2014 7:59:59 PM org.apache.catalina.core.ApplicationContext log 
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', '[email protected]') 
Nov 03, 2014 7:59:59 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory /usr/home/cob/src/apache-tomcat-7.0.53/webapps2/docs 
Nov 03, 2014 7:59:59 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory /usr/home/cob/src/apache-tomcat-7.0.53/webapps2/ROOT 
Nov 03, 2014 7:59:59 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory /usr/home/cob/src/apache-tomcat-7.0.53/webapps2/manager 
Nov 03, 2014 7:59:59 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory /usr/home/cob/src/apache-tomcat-7.0.53/webapps2/host-manager 
Nov 03, 2014 7:59:59 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["http-bio-18080"] 
Nov 03, 2014 7:59:59 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["ajp-bio-18009"] 
Nov 03, 2014 7:59:59 PM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 8304 ms 

我不太確定端口是否會導致問題。 netstat和其他使用中的端口不會返回任何有用的內容。

回答

1

作爲一個Basex郵件列表的傢伙,我對Tomcat沒有太多的瞭解......但是,你得到的錯誤信息對我來說是相當知名的。看到你的.basex(或者你定義你的BaseX選項的地方)是很有用的。我猜你會修改兩個實例的服務器端口以指向不同的端口。

但是,您沒有修改Event port,因此服務器無法正確啓動。嘗試修改它以使用其他端口。