小编典典

如何在Tomcat而不是jettyserver上运行Broadleaf?

tomcat

我按照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>

阅读 306

收藏
2020-06-16

共1个答案

小编典典

谢谢大家。!我更改了mysql的默认端口号和配置。它在端口8080上运行,这是apache
tomcat的默认端口。所以我将mysql端口号更改为3306。现在程序运行平稳!

2020-06-16