我正在尝试使用 cargo api 启动 tomcat。从日志看一切都很好,但是当我点击 url(http://localhost:8079/) 时,tomcat 管理页面没有出现。
更新:我尝试从 eclipse 启动 tomcat。日志说的完全相同,但我看不到管理控制台。所以这肯定不是货物的问题。当我从 eclipse 启动服务器时,我得到一个 404 。
代码是这样的
LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory().createConfiguration(
"tomcat6x", ContainerType.INSTALLED, ConfigurationType.STANDALONE);
InstalledLocalContainer container =
(InstalledLocalContainer) new DefaultContainerFactory().createContainer(
"tomcat6x", ContainerType.INSTALLED, configuration);
//container.setHome(installer.getHome());
//container.setHome("C:\\Users\\Kriss\\AppData\\Local\\Temp\\cargo\\installs\\apache-tomcat-7.0.25\\apache-tomcat-7.0.25");
container.setHome("C:\\TOSCA\\apache-tomcat-7.0.25-windows-x86\\apache-tomcat-7.0.25\\");
container.setOutput("C:\\TOSCA\\output.log");
//getting cargo related logging
container.setLogger(fileLogger);
//changing the log settings of the container
// configuration.setProperty(GeneralPropertySet.LOGGING, LoggingLevel.HIGH.getLevel());
configuration.setProperty("cargo.servlet.port", "8079");
logger.info(container.getOutput());
container.setAppend(false);
logger.info("gethome value is" + container.getHome());
// (3) Statically deploy some WAR (optional)
// configuration.addDeployable(new WAR("cargo.war"));
// (4) Start the container
container.start();
logger.info("Container is started");
Thread.sleep(26000);
container.stop();
logger.info("Container is stopped");
日志看起来不错(至少对我来说:P)
Apr 10, 2012 4:27:54 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [C:\Users\Kriss\AppData\Local\Temp\cargo\conf\common\classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 10, 2012 4:27:54 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [C:\Users\Kriss\AppData\Local\Temp\cargo\conf\common\lib], exists: [false], isDirectory: [false], canRead: [false]
Apr 10, 2012 4:27:54 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [C:\Users\Kriss\AppData\Local\Temp\cargo\conf\shared\classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 10, 2012 4:27:54 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [C:\Users\Kriss\AppData\Local\Temp\cargo\conf\shared\lib], exists: [false], isDirectory: [false], canRead: [false]
Apr 10, 2012 4:27:55 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter\Driver;C:\Program Files\Java\jdk1.7.0_01\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;.
Apr 10, 2012 4:27:55 PM org.apache.catalina.startup.SetAllPropertiesRule begin
WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'emptySessionPath' to 'true' did not find a matching property.
Apr 10, 2012 4:27:55 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8079"]
Apr 10, 2012 4:27:55 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Apr 10, 2012 4:27:55 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 674 ms
Apr 10, 2012 4:27:55 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 10, 2012 4:27:55 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
Apr 10, 2012 4:27:55 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\Users\Kriss\AppData\Local\Temp\cargo\conf\conf\Catalina\localhost\manager.xml
Apr 10, 2012 4:27:56 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive C:\Users\Kriss\AppData\Local\Temp\cargo\conf\webapps\cargocpc.war
Apr 10, 2012 4:27:56 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Users\Kriss\AppData\Local\Temp\cargo\conf\webapps\host-manager
Apr 10, 2012 4:27:56 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8079"]
Apr 10, 2012 4:27:56 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Apr 10, 2012 4:27:56 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 610 ms
Minor detail: when i tried to start, bootstrap was missing some classes which were part of tomcat-juli.jar. so i unjarred that and put the classes inside bootstrap.jar. I just thought i should mention that as a side comment though i dont think it is causing some problem..
Also here is the log when i start tomcat using command prompt:
Apr 09, 2012 1:55:36 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.22.
Apr 09, 2012 1:55:36 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [false], sendfile [true], accept filters [false], r
andom [true].
Apr 09, 2012 1:55:37 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Apr 09, 2012 1:55:37 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Apr 09, 2012 1:55:37 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1944 ms
Apr 09, 2012 1:55:37 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 09, 2012 1:55:37 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
Apr 09, 2012 1:55:37 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\docs
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\examples
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\host-manager
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\manager
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\ROOT
Apr 09, 2012 1:55:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Apr 09, 2012 1:55:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 927 ms