部署到Tomcat 7确定但无法访问应用程序

时间:2013-07-01 11:03:41

标签: java maven tomcat jenkins tomcat7

我使用Jenkins进行了CI部署的Java Wicket应用程序 - > Tomcat 7在服务器上。在我尝试通过浏览器访问应用程序(通过管理器应用程序中已部署应用程序的列表)之前,一切似乎都很好。然后我收到404错误。在日志中,我可以从tomcat7-stdout-.log中看到应用程序启动正常 - 我设置的spring bean正在从我的代码中输出init调试语句,所以它看起来准备好没有错误。

我的开发机器是32位win7。服务器是64位Win Server 2008 R2

认为它可能是Jenkins构建war文件的方式,或32/64位版本之间的不兼容性,我在本地安装了Tomcat 7,所以它都在同一台机器上,当我从部署时得到相同的结果经理申请。

  • 当我关闭tomcat并尝试访问localhost:8080时,没有任何内容显示,因此没有其他应用程序竞争我可以看到的端口
  • 在里面创建一个带有<Context path="/system4" />的META-INF / context.xml也不会影响部署(即它仍然说它位于战争名称指定的路径上)。
  • 我按照说明here删除了一些错误listenerStart问题,但创建的日志文件为空
  • 通过mvn jetty在本地运行:运行启动应用程序没有问题。然后,我可以在localhost:8080
  • 上成功导航到该应用程序
  • 日志文件中没有错误。以下是(本地)部署中每个文件的总输出。

localhost..log:

Jul 01, 2013 11:47:58 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 01, 2013 11:47:58 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 01, 2013 11:47:58 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@46128d')

localhost_access_log.log:

127.0.0.1 - tomcatgui [01/Jul/2013:11:48:11 +0100] "GET /manager/html/list?org.apache.catalina.filters.CSRF_NONCE=DBBBE417970CCAAB039E98C236CB177A HTTP/1.1" 200 15822
127.0.0.1 - tomcatgui [01/Jul/2013:11:48:11 +0100] "GET /manager/images/asf-logo.gif HTTP/1.1" 304 -
127.0.0.1 - tomcatgui [01/Jul/2013:11:48:11 +0100] "GET /manager/images/tomcat.gif HTTP/1.1" 304 -
127.0.0.1 - tomcatgui [01/Jul/2013:11:48:16 +0100] "GET /manager/html/list?org.apache.catalina.filters.CSRF_NONCE=634AA4131BBA0B7368023C32CD653FC8 HTTP/1.1" 200 15822
127.0.0.1 - tomcatgui [01/Jul/2013:11:48:34 +0100] "POST /manager/html/upload?org.apache.catalina.filters.CSRF_NONCE=AA80212A2557D18475CB621F165BD24E HTTP/1.1" 200 17716

host-manager..log(空)

catalina..log:

Jul 01, 2013 11:47:57 AM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.27 using APR version 1.4.6.
Jul 01, 2013 11:47:57 AM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Jul 01, 2013 11:47:58 AM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1d 5 Feb 2013)
Jul 01, 2013 11:47:58 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Jul 01, 2013 11:47:58 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1152 ms
Jul 01, 2013 11:47:58 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 01, 2013 11:47:58 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.41
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\docs
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\examples
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\host-manager
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\manager
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\ROOT
Jul 01, 2013 11:47:58 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Jul 01, 2013 11:47:58 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 440 ms
Jul 01, 2013 11:48:25 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive C:\apache-tomcat-7.0.41\webapps\system4-ui-0.0.1-SNAPSHOT.war

servlet-examples..log(链接中建议的那个)(空 - 日志记录级别设置为ALL)

manager..log:

Jul 01, 2013 11:48:11 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Associated with Deployer 'Catalina:type=Deployer,host=localhost'
Jul 01, 2013 11:48:11 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: init: Global resources are available
Jul 01, 2013 11:48:11 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Jul 01, 2013 11:48:16 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
Jul 01, 2013 11:48:34 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'

tomcat窗口的输出:

Jul 01, 2013 11:47:57 AM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.27 using APR version 1.4
.6.
Jul 01, 2013 11:47:57 AM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], ra
ndom [true].
Jul 01, 2013 11:47:58 AM org.apache.catalina.core.AprLifecycleListener initializ
eSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1d 5 Feb 2013)
Jul 01, 2013 11:47:58 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Jul 01, 2013 11:47:58 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1152 ms
Jul 01, 2013 11:47:58 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 01, 2013 11:47:58 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.41
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\docs
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\exampl
es
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\host-m
anager
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\manage
r
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.41\webapps\ROOT
Jul 01, 2013 11:47:58 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Jul 01, 2013 11:47:58 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Jul 01, 2013 11:47:58 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 440 ms
Jul 01, 2013 11:48:25 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive C:\apache-tomcat-7.0.41\webapps\system4-
ui-0.0.1-SNAPSHOT.war
Jul 01, 2013 11:48:31 AM org.apache.catalina.core.StandardContext listenerStart
FINE: Sending application start events
Jul 01, 2013 11:48:31 AM org.apache.catalina.core.StandardContext filterStart
FINE: Starting filters
Jul 01, 2013 11:48:31 AM org.apache.catalina.core.StandardContext filterStart
FINE:  Starting filter 'wicket.system4-ui'
INFO  - WebXmlFile                 - web.xml: url mapping found for filter with
name wicket.system4-ui: [/*]
INFO  - Application                - [wicket.system4-ui] init: Wicket core libra
ry initializer
INFO  - RequestListenerInterface   - registered listener interface [RequestListe
nerInterface name=IBehaviorListener, method=public abstract void org.apache.wick
et.behavior.IBehaviorListener.onRequest()]
INFO  - RequestListenerInterface   - registered listener interface [RequestListe
nerInterface name=IFormSubmitListener, method=public abstract void org.apache.wi
cket.markup.html.form.IFormSubmitListener.onFormSubmitted()]
INFO  - RequestListenerInterface   - registered listener interface [RequestListe
nerInterface name=ILinkListener, method=public abstract void org.apache.wicket.m
arkup.html.link.ILinkListener.onLinkClicked()]
INFO  - RequestListenerInterface   - registered listener interface [RequestListe
nerInterface name=IOnChangeListener, method=public abstract void org.apache.wick
et.markup.html.form.IOnChangeListener.onSelectionChanged()]
INFO  - RequestListenerInterface   - registered listener interface [RequestListe
nerInterface name=IRedirectListener, method=public abstract void org.apache.wick
et.IRedirectListener.onRedirect()]
INFO  - RequestListenerInterface   - registered listener interface [RequestListe
nerInterface name=IResourceListener, method=public abstract void org.apache.wick
et.IResourceListener.onResourceRequested()]
INFO  - Application                - [wicket.system4-ui] init: Wicket extensions
 initializer
INFO  - sPathXmlApplicationContext - Refreshing org.springframework.context.supp
ort.ClassPathXmlApplicationContext@19b35e1: startup date [Mon Jul 01 11:48:32 BS
T 2013]; root of context hierarchy
INFO  - XmlBeanDefinitionReader    - Loading XML bean definitions from class pat
h resource [META-INF/applicationContext-data.xml]
INFO  - sPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation fou
nd and supported for component scanning
INFO  - nnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation fo
und and supported for autowiring
INFO  - sPathXmlApplicationContext - Bean 'org.springframework.orm.jpa.vendor.Hi
bernateJpaVendorAdapter#5d2d9b' of type [class org.springframework.orm.jpa.vendo
r.HibernateJpaVendorAdapter] is not eligible for getting processed by all BeanPo
stProcessors (for example: not eligible for auto-proxying)
INFO  - sPathXmlApplicationContext - Bean 'org.springframework.instrument.classl
oading.InstrumentationLoadTimeWeaver#f003c0' of type [class org.springframework.
instrument.classloading.InstrumentationLoadTimeWeaver] is not eligible for getti
ng processed by all BeanPostProcessors (for example: not eligible for auto-proxy
ing)
INFO  - erEntityManagerFactoryBean - Building JPA container EntityManagerFactory
 for persistence unit 'com.sw.system4.core.persistence'
INFO  - Version                    - HCANN000001: Hibernate Commons Annotations
{4.0.1.Final}
INFO  - Version                    - HHH000412: Hibernate Core {4.2.0.Final}
INFO  - Environment                - HHH000206: hibernate.properties not found
INFO  - Environment                - HHH000021: Bytecode provider name : javassi
st
INFO  - Ejb3Configuration          - HHH000204: Processing PersistenceUnitInfo [

        name: com.sw.system4.core.persistence
        ...]
INFO  - agerConnectionProviderImpl - HHH000402: Using Hibernate built-in connect
ion pool (not for production use!)
INFO  - agerConnectionProviderImpl - HHH000115: Hibernate connection pool size:
20
INFO  - agerConnectionProviderImpl - HHH000006: Autocommit mode: true
INFO  - agerConnectionProviderImpl - HHH000401: using driver [com.mysql.jdbc.Dri
ver] at URL [jdbc:mysql://localhost:3306/system4_live]
INFO  - agerConnectionProviderImpl - HHH000046: Connection properties: {user=sys
tem4_user, password=****, autocommit=true, release_mode=auto}
INFO  - Dialect                    - HHH000400: Using dialect: org.hibernate.dia
lect.MySQL5Dialect
INFO  - ransactionFactoryInitiator - HHH000268: Transaction strategy: org.hibern
ate.engine.transaction.internal.jdbc.JdbcTransactionFactory
INFO  - ASTQueryTranslatorFactory  - HHH000397: Using ASTQueryTranslatorFactory
INFO  - SchemaUpdate               - HHH000228: Running hbm2ddl schema update
INFO  - SchemaUpdate               - HHH000102: Fetching database metadata
INFO  - SchemaUpdate               - HHH000396: Updating schema
INFO  - TableMetadata              - HHH000261: Table found: system4_live.user
INFO  - TableMetadata              - HHH000037: Columns: [id, enabled, username,
 preferences_id, lastlogin, lastname, firstname, password, changepasswordrequire
d]
INFO  - TableMetadata              - HHH000108: Foreign keys: [fk285feb559233ea]

INFO  - TableMetadata              - HHH000126: Indexes: [primary, fk285feb55923
3ea]
INFO  - TableMetadata              - HHH000261: Table found: system4_live.userpr
eferences
INFO  - TableMetadata              - HHH000037: Columns: [id]
INFO  - TableMetadata              - HHH000108: Foreign keys: []
INFO  - TableMetadata              - HHH000126: Indexes: [primary]
INFO  - SchemaUpdate               - HHH000232: Schema update complete
INFO  - sPathXmlApplicationContext - Bean 'entityManagerFactory' of type [class
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] is not eligi
ble for getting processed by all BeanPostProcessors (for example: not eligible f
or auto-proxying)
INFO  - DefaultListableBeanFactory - Pre-instantiating singletons in org.springf
ramework.beans.factory.support.DefaultListableBeanFactory@66d804: defining beans
 [entityManagerFactory,transactionManager,org.springframework.orm.jpa.support.Pe
rsistenceAnnotationBeanPostProcessor#0,org.springframework.aop.config.internalAu
toProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionA
ttributeSource#0,org.springframework.transaction.interceptor.TransactionIntercep
tor#0,org.springframework.transaction.config.internalTransactionAdvisor,persiste
nceExceptionTranslationPostProcessor,org.springframework.context.annotation.inte
rnalConfigurationAnnotationProcessor,org.springframework.context.annotation.inte
rnalAutowiredAnnotationProcessor,org.springframework.context.annotation.internal
RequiredAnnotationProcessor,org.springframework.context.annotation.internalCommo
nAnnotationProcessor,org.springframework.context.annotation.internalPersistenceA
nnotationProcessor,userJpaDAO,user-service,encryption-service,org.springframewor
k.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root
 of factory hierarchy
INFO  - MD5EncryptionStrategy      - EncryptionStrategy: Using MD5 for encryptio
n
INFO  - WebApplication             - [wicket.system4-ui] Started Wicket version
6.8.0 in DEVELOPMENT mode
********************************************************************
*** WARNING: Wicket is running in DEVELOPMENT mode.              ***
***                               ^^^^^^^^^^^                    ***
*** Do NOT deploy to your live server(s) without changing this.  ***
*** See Application#getConfigurationType() for more information. ***
********************************************************************

如果我在tomcat管理器应用程序中单击该应用程序的链接,我会得到:

type Status report

message /system4%2Dui%2D0.0.1%2DSNAPSHOT/

description The requested resource is not available.

,这出现在localhost-access..log中:

127.0.0.1 - - [01/Jul/2013:11:54:38 +0100] "GET /system4%2Dui%2D0.0.1%2DSNAPSHOT/ HTTP/1.1" 404 1015

请有人帮忙吗?

1 个答案:

答案 0 :(得分:8)

好的,这很奇怪。

这完全取决于WAR文件的名称,因此也就是网站的URL。我将war文件重命名为system4.war,并尝试部署它,我可以正常导航到URL。

我说这很奇怪,因为几个月前我在同一台服务器上运行了wicket quickstart项目,并且war文件命名非常相似(即wickettestproject-1.0-SNAPSHOT.war)并且这个工作正常,尽管重新部署后现在,这个项目已经不再适用了。

我不知道为什么,因为AFAIK点和短划线在网址中是可以的 - 也许这是一个tomcat怪癖或其他东西。

解决问题:

在用于生成WAR的pom.xml中,我在构建标记下包含了这一行:

<finalName>system4</finalName>

现在重新命名战争,它在system4.war下构建和部署,并通过<server>:<port>/system4

访问