部署的war文件无法在tomcat管理器中启动

时间:2014-11-14 08:30:35

标签: java eclipse spring tomcat broadleaf-commerce

我正在使用tomcat v6.0。我从经理页面部署了admin.war。当我检查webapps目录时,我可以看到它已被解压缩..但是我无法从tomcat管理器启动该站点。 这是我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID">

<display-name>mycompany-admin</display-name>

<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>blAdmin.root</param-value>
</context-param>

<context-param>
    <param-name>patchConfigLocation</param-name>
    <param-value>
        classpath:/bl-open-admin-contentClient-applicationContext.xml
        classpath:/bl-open-admin-contentCreator-applicationContext.xml
        classpath:/bl-admin-applicationContext.xml
        classpath:/bl-cms-contentClient-applicationContext.xml
        classpath:/bl-cms-contentCreator-applicationContext.xml
        classpath:/applicationContext.xml
        classpath:/applicationContext-email.xml
        /WEB-INF/applicationContext-datasource.xml
        /WEB-INF/applicationContext-admin-security.xml
        /WEB-INF/applicationContext-admin-filter.xml
        /WEB-INF/applicationContext-admin.xml
    </param-value>
</context-param>

<context-param>
    <param-name>shutdownHookMethod</param-name>
    <param-value>forceFlush</param-value>
</context-param>

<listener>
    <listener-class>
         org.springframework.web.context.request.RequestContextListener
    </listener-class>
</listener>

<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- enable configured logging -->
<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<listener>
    <listener-class>org.broadleafcommerce.common.web.extensibility.MergeContextLoaderListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>

<!-- Initialize spring mvc -->
<servlet>
    <servlet-name>admin</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:/applicationContext-servlet-open-admin.xml
            classpath:/applicationContext-servlet-admin.xml
            classpath:/applicationContext-servlet-cms-contentClient.xml
            classpath:/applicationContext-servlet-cms-contentCreator.xml
            /WEB-INF/applicationContext-servlet-admin.xml
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- specify the url pattern that will engage spring mvc -->
<servlet-mapping>
    <servlet-name>admin</servlet-name>
    <url-pattern>/admin</url-pattern>
</servlet-mapping>

<env-entry>
    <env-entry-name>appName</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>admin2</env-entry-value>
</env-entry>

3 个答案:

答案 0 :(得分:0)

Driver :-  com.mysql.jdbc.Driver
Url    :-  jdbc:mysql://192.168.0.232:3306/entrance

答案 1 :(得分:0)

首先将JDBC驱动程序的jar复制到$ CATALINA_HOME / lib。

然后在tomcat server.xml文件中添加如下内容

<Resource name="jdbc/YourDB"
  global="jdbc/YourDB"
  auth="Container"
  type="javax.sql.DataSource"
  driverClassName="com.mysql.jdbc.Driver"
  url="jdbc:mysql://localhost:3306/YourUser"
  username="Yourusername"
  password="Yourpassword"
  maxActive="100"
  maxIdle="20"
  minIdle="5"
  maxWait="10000"/>

然后在服务器context.xml文件中添加以下内容

<ResourceLink name="jdbc/YourLocalDB"
            global="jdbc/YourDB"
            auth="Container"
            type="javax.sql.DataSource" />

这里有详细的教程https://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example

答案 2 :(得分:0)

你的问题是,bro​​adleaf在网站和管理员的context.xml中有一些属性,并包含在战争中。您必须根据连接详细信息更改这些属性。

这是大提示

14, 2014 11:35:38 AM org.apache.naming.NamingContext lookup WARNING: Unexpected exception resolving reference java.sql.SQLException: ${database.driver}

请注意${database.driver},如果您在项目中进行搜索,则会发现/src/main/webapp/META-INF/context.xml

这篇文章可能会对您有所帮助,How to run broadleaf on Tomcat instead of jettyserver..?