java - 如何在 Tomcat 而不是 jettyserver 上运行 broadleaf ..?

标签 java eclipse tomcat jdbc broadleaf-commerce

我遵循了 broadleafcommerce 文档中提供的所有说明。在对 Mysql 集成进行更改之前,我可以在 jettyserver 上运行该站点。但是在我按照“入门”页面中给出的 Mysql 集成说明进行操作后,它也停止在 jettyserver 上工作......可能是什么问题......?

[ http://www.broadleafcommerce.com/docs/core/current/tutorials/getting-started-tutorials/switch-to-mysql-tutorial ]

因此我尝试在 tomcat 7.0 服务器上运行该网站...但是在运行 catalina.sh 时看到以下错误

Nov 18, 2014 12:27:29 PM org.apache.catalina.core.NamingContextListener addResource
WARNING: Failed to register in JMX: javax.naming.NamingException: ${database.driver}
Nov 18, 2014 12:27:29 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error getConfigured
Nov 18, 2014 12:27:29 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/mycompany] startup failed due to previous errors
Nov 18, 2014 12:27:29 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /Users/mac/apache-tomcat-7.0.57/webapps/mycompany.war has finished in 2,617 ms
Nov 18, 2014 12:27:29 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/mac/apache-tomcat-7.0.57/webapps/docs
Nov 18, 2014 12:27:29 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 29 column 6: The markup in the document following the root element must be well-formed.
org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
SEVERE: Occurred at line 29 column 6
Nov 18, 2014 12:27:30 PM org.apache.catalina.startup.ContextConfig configureStart
SEVERE: Marking this application unavailable due to previous error(s)
Nov 18, 2014 12:27:30 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error getConfigured
Nov 18, 2014 12:27:30 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors

这是我的 tomcat/config 的 context.xml:

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0


-->
<!-- The contents of this file will be loaded for each web application -->
<Context>

   <Resource auth="Container" 
       name="local_jdbc_db"  
       type="javax.sql.DataSource" 
       driverClassName="com.mysql.jdbc.Driver"  
       url="jdbc:mysql://localhost:3306/broadleaf" 
       username="root" 
       password="admin123"      /> 
   </Context>
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
     on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->

</Context>

和我的 server.xml

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->


    <Resource name="jdbc/broadleaf"
    auth="Container"
    type="javax.sql.DataSource"
    username="root"
    password="admin123"
    driverClassName="com.mysql.jdbc.Driver"
    description="Global Address Database"
    url="jdbc:mysql://localhost:3306/mycompany"
    maxActive="15"
    maxIdle="3"/>
 </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">


    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
    maxThreads="150" minSpareThreads="4"/>
    -->



    <Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
           port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
    -->
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
     This connector uses the BIO implementation that requires the JSSE
     style configuration. When using the APR/native implementation, the
     OpenSSL style configuration is required as described in the APR/native
     documentation -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
           maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />




    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
      /docs/cluster-howto.html  (simple how to)
      /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
       via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
         resources under the key "UserDatabase".  Any edits
         that are performed against this UserDatabase are immediately
         available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
           resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>

最佳答案

您的 context.xml 有一个无关的 </Context>元素正上方 <WatchedResource> .删除它,我敢打赌它会起作用。

关于java - 如何在 Tomcat 而不是 jettyserver 上运行 broadleaf ..?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26989211/

相关文章:

ios - 使用 tabris iOS 客户端更改服务器 URL?

javascript - 无法修复我的 angularjs 应用程序路径中的主题标签

java - 当请求来自网络服务器而不是网络浏览器时,HTTPSession 的创建如何工作?

java - 如何计算目录和子目录中的大量文件(例如根C ://or D://)

java - 无法使用 jvisualvm 分析 JBoss 5

Java 统计单词 IndexOf

java - java.io.FileNotFoundException:app/libs/perfectjpattern-core-1.0.0.jar(无此文件或目录)

java - Alfresco 插件元数据编写器指南

maven - 在 Jenkins 中将 war 部署到 Tomcat 容器中

java - 显示导入包的名称,但被划掉