Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Tomcat而不是jettyserver上运行broadleaf。。?_Java_Eclipse_Tomcat_Jdbc_Broadleaf Commerce - Fatal编程技术网

Java 如何在Tomcat而不是jettyserver上运行broadleaf。。?

Java 如何在Tomcat而不是jettyserver上运行broadleaf。。?,java,eclipse,tomcat,jdbc,broadleaf-commerce,Java,Eclipse,Tomcat,Jdbc,Broadleaf Commerce,我遵循了BroadLeaveCommerce文档中提供的所有说明。在对Mysql集成进行更改之前,我可以在jettyserver上运行该站点。但在我按照“入门”页面中给出的Mysql集成说明进行操作后,jettyserver也停止了工作……可能是什么问题呢 [] 因此,我尝试在Tomcat7.0服务器上运行该网站……但在运行catalina.sh时发现以下错误 Nov 18, 2014 12:27:29 PM org.apache.catalina.core.NamingContextListe

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

[]

因此,我尝试在Tomcat7.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的my 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>

WEB-INF/WEB.xml
还有我的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在
的正上方有一个无关的
元素。把它拿走,我敢打赌它一定能用。

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

如果您使用的是broadleaf 3.1.x GA或3.0.x GA,并且您希望使用mysql和外部tomcat 您需要将此依赖项添加到
/pom.xml
(基本pom)中:

您还需要为每个资源更改以下文件:

/site/src/main/webapp/META-INF/context.xml
/admin/src/main/webapp/META-INF/context.xml

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>
...
      username="${database.user}"
      password="${database.password}"
      driverClassName="${database.driver}"
      url="${database.url}"
...
你本来可以的

...
      username="root"
      password="your-password"
      driverClassName="com.mysql.jdbc.Driver"
      url="jdbc:mysql://localhost:3306"
...

这应该行。

:谢谢philip,我纠正了它,但这似乎不是错误。
...
      username="root"
      password="your-password"
      driverClassName="com.mysql.jdbc.Driver"
      url="jdbc:mysql://localhost:3306"
...