Page 1 of 1

Cannot run BLC with standalone Tomcat 8

Posted: Sun Oct 18, 2015 7:15 pm
by attilio
Hello,

I was able to run BLC using embedded tomcat and HSQL successfully. Now I am trying to run BLC using standalone tomcat 8.0.27 with MySQL but I am getting this error in the browser if I do :

localhost:8080/ or localhost:8080/mycompany/

HTTP Status 404 - /
type Status report
message /
description The requested resource is not available.

I removed all the tomcat references from the pom.xml, created w/o any issues the war file, deployed the war file as ROOT and ran the Tomcat server successfully.

The ROOT exists in this folder: apache-tomcat-8.0.27/webapps/ROOT

web.xml

Code: Select all

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

    <display-name>mycompany</display-name>
   
    <resource-ref>
        <description>Web DB Connection</description>
        <res-ref-name>jdbc/web</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
   </resource-ref>
    <resource-ref>
        <description>Secure DB Connection</description>
        <res-ref-name>jdbc/secure</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
   </resource-ref>
    <resource-ref>
        <description>Storage DB Connection</description>
        <res-ref-name>jdbc/storage</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
   </resource-ref>
      
    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>site.root</param-value>
    </context-param>

    <context-param>
        <param-name>patchConfigLocation</param-name>
        <param-value>
            classpath:/bl-open-admin-contentClient-applicationContext.xml
            classpath:/bl-cms-contentClient-applicationContext.xml
            classpath*:/blc-config/site/bl-*-applicationContext.xml
            classpath:/applicationContext.xml
            classpath:/applicationContext-email.xml
            /WEB-INF/applicationContext-datasource.xml
            /WEB-INF/applicationContext-rest-api-security.xml
            /WEB-INF/applicationContext-security.xml
            /WEB-INF/applicationContext-filter.xml
            /WEB-INF/applicationContext-workflow.xml
            /WEB-INF/applicationContext.xml
        </param-value>
    </context-param>

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

    <absolute-ordering />
   
    <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.MergeContextLoader</listener-class>
    </listener>
   
    <listener>
        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
    </listener>
   
    <!-- Note: The applicationContext-servlet-cms-contentClient.xml file is used to load static assets
         from the Broadleaf CMS such as images. It will match on any URL that contains the static asset
         prefix URL in any depth of it. -->
    <servlet>
        <servlet-name>mycompany</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                classpath*:/blc-config/site/bl-*-applicationContext-servlet.xml
                classpath:/applicationContext-servlet-cms-contentClient.xml
                /WEB-INF/applicationContext-servlet.xml
            </param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
   
    <servlet-mapping>
        <servlet-name>mycompany</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
   
    <!-- The RESTApiServlet can be disabled, but doesn't have to be. It will throw an exception if
         it is accessed when no endpoints have been registered via Spring. Add /WEB-INF/applicationContext-rest-api.xml
         to the merge patchConfigLocation ABOVE applicationContext-security.xml to activate and begin using REST services.
         Alternately, this servlet and servlet mapping can be commented out entirely. -->
    <servlet>
       <servlet-name>RESTApiServlet</servlet-name>
       <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextClass</param-name>
            <param-value>
                org.springframework.web.context.support.AnnotationConfigWebApplicationContext
            </param-value>
        </init-param>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                com.mycompany.api.RestApiMvcConfiguration
            </param-value>
        </init-param>
        <init-param>
            <param-name>throwExceptionIfNoHandlerFound</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
   </servlet>

   <servlet-mapping>
       <servlet-name>RESTApiServlet</servlet-name>
       <url-pattern>/api/v1/*</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>mycompanySite</env-entry-value>
    </env-entry>
   
</web-app>


server.xml

Code: Select all

<?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 SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
  <!-- 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 auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
 
<Resource auth="Container" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" driverClassName="com.mysql.jdbc.Driver" maxTotal="20" maxIdle="10" maxWaitMillis="-1" name="jdbc/web" password="" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/broadleaf" connectionProperties="useUnicode=true;characterEncoding=utf8;" username="root"/>
<Resource auth="Container" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" driverClassName="com.mysql.jdbc.Driver" maxTotal="20" maxIdle="10" maxWaitMillis="-1" name="jdbc/secure" password="" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/broadleaf" connectionProperties="useUnicode=true;characterEncoding=utf8;" username="root"/>
<Resource auth="Container" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" driverClassName="com.mysql.jdbc.Driver" maxTotal="20" maxIdle="10" maxWaitMillis="-1" name="jdbc/storage" password="" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/broadleaf" connectionProperties="useUnicode=true;characterEncoding=utf8;" username="root"/> 
  </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">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
    -->
    <!-- 
    <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
    -->
   
   <Connector port="8080" protocol="HTTP/1.1"
              connectionTimeout="20000"
              redirectPort="8443"
              URIEncoding="UTF-8"/>   
   
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
         This connector uses the NIO 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.Http11NioProtocol"
               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"/>


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

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

      <!--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 appBase="webapps" autoDeploy="false" deployOnStartup="false" name="localhost" unpackWARs="true">

 
      <Context path="" docBase="/Users/mac/apache-tomcat-8.0.27/webapps/ROOT/" reloadable="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" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log" suffix=".txt"/>

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


context.xml

Code: Select all

<?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.
--><!-- The contents of this file will be loaded for each web application --><Context>

    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/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" />
    -->

<ResourceLink global="jdbc/web" name="jdbc/web" type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/secure" name="jdbc/secure" type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/storage" name="jdbc/storage" type="javax.sql.DataSource"/>
</Context>


This is the console log:

Code: Select all

objc[7316]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/8.0.27
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Sep 28 2015 08:17:25 UTC
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         8.0.27.0
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Mac OS X
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.10.5
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          x86_64
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_60-b27
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         /Users/mac/apache-tomcat-8.0.27
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         /Users/mac/apache-tomcat-8.0.27
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dmaven.multiModuleProjectDirectory=$M2_HOME
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Ddatabase.driver=com.mysql.jdbc.Driver
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Ddatabase.url=jdbc:mysql://localhost:3306/broadleaf
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Ddatabase.user=root
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Druntime.environment=development
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Xmx1024M
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -javaagent:/Users/mac/lib/spring-instrument-4.1.6.RELEASE.jar
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/Users/mac/apache-tomcat-8.0.27
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/Users/mac/apache-tomcat-8.0.27
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/Users/mac/apache-tomcat-8.0.27/wtpwebapps
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/Users/mac/apache-tomcat-8.0.27/endorsed
Oct 18, 2015 3:10:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Oct 18, 2015 3:10:48 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/mac/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Oct 18, 2015 3:10:49 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Oct 18, 2015 3:10:49 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Oct 18, 2015 3:10:49 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Oct 18, 2015 3:10:49 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Oct 18, 2015 3:10:49 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1093 ms
Oct 18, 2015 3:10:49 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 18, 2015 3:10:49 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.27
Oct 18, 2015 3:10:51 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Oct 18, 2015 3:10:51 PM org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'site.root' = [/Users/mac/apache-tomcat-8.0.27/webapps/ROOT/]
Oct 18, 2015 3:10:51 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [/Users/mac/apache-tomcat-8.0.27/webapps/ROOT/WEB-INF/log4j.xml]
Oct 18, 2015 3:10:51 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
[ WARN] 15:11:05 AbstractEhcacheRegionFactory - HHH020003: Could not find a specific ehcache configuration for cache named [blSandBoxElements]; using defaults.
[SUPPORT] 15:11:16 ModuleLifecycleLoggingBean - Menu - LOADING
Oct 18, 2015 3:11:17 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'RESTApiServlet'
Oct 18, 2015 3:11:19 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'mycompany'
Oct 18, 2015 3:11:20 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Oct 18, 2015 3:11:20 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Oct 18, 2015 3:11:20 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 31719 ms


The complete log can be found here: https://github.com/attilio1/Errors/blob/broadleaf/console_log.txt

Please help. Could you please tell me what I am doing wrong? I do not know what else could be missing to get the demo up and running w/ standalone Tomcat.

Thanks,

Attilio