Search code examples
apachespring-bootapache-phoenixspring-boot-gradle-plugin

Is there a sample Apache Phoenix + Spring Boot + Gradle sample project?


Without the Phoenix core, spring boot starts tomcat correctly.

Problem: Add compile('org.apache.phoenix:phoenix-core:4.7.0-HBase-1.1') to the dependencies section of my build.gradle and Tomcat fails to start

dependencies {
    compile('org.apache.phoenix:phoenix-core:4.7.0-HBase-1.1')
    compile("org.springframework.data:spring-data-commons")
    compile("org.springframework.boot:spring-boot-starter-jdbc:1.3.2.RELEASE")
    compile('org.springframework.boot:spring-boot-starter-web:1.3.2.RELEASE')
    compile("org.springframework:spring-test:4.2.4.RELEASE")
}

with the following exception,

org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/phoenix]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:816)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/phoenix]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 6 more
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.addServlet(Ljava/lang/String;Ljavax/servlet/Servlet;)Ljavax/servlet/ServletRegistration$Dynamic;
    at org.springframework.boot.context.embedded.ServletRegistrationBean.onStartup(ServletRegistrationBean.java:190)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:225)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:85)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:209)
    at org.springframework.boot.contex2016-03-07 23:40:29.048  WARN 71400 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
ded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:55)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5513)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

Solution

  • The following line added to the dependencies helped resolve the issue.

    providedCompile "javax.servlet:javax.servlet-api:3.0.1"

    dependencies {
        providedCompile "javax.servlet:javax.servlet-api:3.0.1"
        compile('org.apache.phoenix:phoenix-core:4.7.0-HBase-1.1')
        compile("org.springframework.data:spring-data-commons")
        compile("org.springframework.boot:spring-boot-starter-jdbc:1.3.2.RELEASE")
        compile('org.springframework.boot:spring-boot-starter-web:1.3.2.RELEASE')
        compile("org.springframework:spring-test:4.2.4.RELEASE")
    }