Java – HTTP ERROR: 503 Reason: Service Unavailable powered by jetty

broadleaf-commercejavamaven-jetty-pluginmysql

I am trying to develop a web application using java. I am following broadleaf commerce's tutorials
[http://www.broadleafcommerce.com/docs/core/current/getting-started].

At the beginning I am able to run my demo site. But after following the documentation for switching to MySql[http://www.broadleafcommerce.com/docs/core/current/tutorials/getting-started-tutorials/switch-to-mysql-tutorial],I was not able to run the site.

I got the following error in the browser

HTTP ERROR: 503

Problem accessing /. Reason:

Service Unavailable

Powered by Jetty://

Progress at Eclipse console:

[artifact:mvn] [ERROR] 14:59:03 ContextLoader - Context initialization failed
[artifact:mvn] org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection
[artifact:mvn] 2014-11-18 14:59:03.673:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
[artifact:mvn] 2014-11-18 14:59:03.939:INFO:oejus.SslContextFactory:Enabled Protocols [SSLv2Hello, SSLv3, TLSv1] of [SSLv2Hello, SSLv3, TLSv1]

....
...

[artifact:mvn] [INFO] Started Jetty Server
[artifact:mvn] 2014-11-18 14:59:03.950:INFO:oejs.AbstractConnector:Started SslSelectChannelConnector@0.0.0.0:8443
[artifact:mvn] [ WARN] 14:59:08 SqlExceptionHelper - SQL Error: 0, SQLState: null
[artifact:mvn] [ERROR] 14:59:08 SqlExceptionHelper - Cannot create PoolableConnectionFactory (Communications link failure
[artifact:mvn] The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
[artifact:mvn] [ERROR] 14:59:08 JobRunShell - Job DEFAULT.rebuildIndexJobDetail threw an unhandled Exception: 
[artifact:mvn] org.springframework.scheduling.quartz.JobMethodInvocationFailedException:       Invocation of method 'rebuildIndex' on target class [class   org.broadleafcommerce.core.search.service.solr.SolrSearchServiceImpl] failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection

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">
<servlet>
    <servlet-name>heatclinic</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            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>heatclinic</servlet-name>
    <url-pattern>/</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
    <servlet-name>RESTApiServlet</servlet-name>
    <url-pattern>/api/v1/*</url-pattern>
  </servlet-mapping>
 </web-app>

Best Solution

Looks like it could not connect to MySQL. Double-check your MySQL connection settings and that the MySQL service is actually started.

Related Question