4

Am trying to deploy a Spring Boot application on GlassFish 4.1.1, but unable to do so. I have seen and read many posts here about similar problem, but none of them seem to post a workaround that works for me. My pom looks like this

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>LetsFigureThis</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.7</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.1.7.RELEASE</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <warName>demo</warName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.glassfish.maven.plugin</groupId>
                <artifactId>maven-glassfish-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <glassfishDirectory>C:\dev\tools\servers\glassfish4\glassfish</glassfishDirectory>
                    <user>admin</user>
                    <!--<adminPassword>admin</adminPassword>-->
                    <passwordFile>C:\dev\tools\servers\glassfish4\glassfish\passwordFile.txt</passwordFile>
                    <domain>
                        <name>domain1</name>
                        <httpPort>8080</httpPort>
                        <adminPort>4848</adminPort>
                    </domain>
                    <components>
                        <component>
                            <name>demo</name>
                            <!--<force>true</force>-->
                            <artifact>target/demo.war</artifact>
                        </component>
                    </components>
                    <debug>true</debug>
                    <terse>false</terse>
                    <echo>true</echo>

                </configuration>
            </plugin>
        </plugins>

    </build>

</project>

I have excluded tomcat embed jar files since it conflicts with jars from GlassFish, I have also added Spring Batch since glassfish was complaining about those missing. When I deploy to glassfish with this configuration, my application gets deployed with but with the following log info

[2015-10-12T09:07:29.583-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849583] [levelValue: 1000] [[
  Class [ Lgroovy/text/markup/MarkupTemplateEngine; ] not found. Error while loading [ class org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration$GroovyMarkupConfiguration ]]]

[2015-10-12T09:07:29.591-0500] [glassfish 4.1] [INFO] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849591] [levelValue: 800] [[
  Exception java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy encountered while processing annotaton for element class org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration. Message is: sun.reflect.annotation.TypeNotPresentExceptionProxy. Ignoring annotations and proceeding.]]

[2015-10-12T09:07:29.594-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849594] [levelValue: 1000] [[
  Class [ com/samskivert/mustache/Mustache$Collector ] not found. Error while loading [ class org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration ]]]

[2015-10-12T09:07:29.597-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849597] [levelValue: 1000] [[
  Class [ org/apache/solr/client/solrj/SolrServer ] not found. Error while loading [ class org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration ]]]

[2015-10-12T09:07:29.602-0500] [glassfish 4.1] [INFO] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849602] [levelValue: 800] [[
  Exception java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy encountered while processing annotaton for element class org.springframework.boot.autoconfigure.velocity.VelocityAutoConfiguration. Message is: sun.reflect.annotation.TypeNotPresentExceptionProxy. Ignoring annotations and proceeding.]]

[2015-10-12T09:07:29.631-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849631] [levelValue: 1000] [[
  Class [ org/thymeleaf/resourceresolver/IResourceResolver ] not found. Error while loading [ class org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$DefaultTemplateResolverConfiguration ]]]

[2015-10-12T09:07:29.649-0500] [glassfish 4.1] [SEVERE] [] [global] [tid: _ThreadID=145 _ThreadName=admin-listener(10)] [timeMillis: 1444658849649] [levelValue: 1000] [[
  Class [ org/flywaydb/core/Flyway ] not found. Error while loading [ class org.springframework

.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration ]]]

From the log files I also see that the application is deployed properly, but when I look for my resource http://localhost:8080/demp/hello, I get a 404 error. When I deploy my app as Spring Boot application, I can get to my resource without any problems.

Note: Not a duplicate of

http://stackoverflow.com/questions/29431579/spring-boot-app-does-not-deploy-on-glassfish-4-1

because in my case there is no web.xml. Am deploying to Servlet 3.0 container and hence all the configuration are done using code, I don't have web.xml in my setup to apply the workaround mentioned in the post above
And also the post talks about deployment on GlassFish 4.1 but am on 4.1.1. The post carries a link java.net/jira/browse/GLASSFISH-21265 which mentions that this bug is fixed in 4.1.1

Any help would be greatly appreciated

Thanks Kay

PaulNUK
  • 4,774
  • 2
  • 30
  • 58
Karthik Balasubramanian
  • 1,127
  • 4
  • 13
  • 36
  • Looks like you are hacking at it... I suggest a read of the reference guide... http://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html which explains how to do just that. Although I would strongly suggest ditching glass fish and *build jar, not war* to quote Josh Long. – M. Deinum Oct 12 '15 at 14:20
  • Am using the target war from maven-war-plugin and then executing deploy target from org.glassfish.maven.plugin. I cant get away from Glassfish. Am not trying to hack anything, the document you referred to does not talk about GlassFish. This problem is very specific to Glassfish – Karthik Balasubramanian Oct 12 '15 at 14:39
  • 2
    http://stackoverflow.com/questions/29431579/spring-boot-app-does-not-deploy-on-glassfish-4-1 - My problem is very similar to this – Karthik Balasubramanian Oct 12 '15 at 14:39
  • @KarthikBalasubramanian your question's a duplicate of the one you've linked to above – Andy Wilkinson Oct 12 '15 at 14:41
  • It is not exactly a duplicate, because in my case there is no web.xml. Am deploying to Servlet 3.0 container and hence all the configuration are done using code, I don't have web.xml in my setup to apply the workaround mentioned in the post above – Karthik Balasubramanian Oct 12 '15 at 14:44
  • 1
    And also the post talks about deployment on GlassFish 4.1 but am on 4.1.1. The post carries a link https://java.net/jira/browse/GLASSFISH-21265 which mentions that this bug is fixed in 4.1.1 – Karthik Balasubramanian Oct 12 '15 at 14:47
  • I think that's a mistake on the Glassfish issue. You have the exact same problem described in the other question and on GLASSFISH-21265: `java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy` – Andy Wilkinson Oct 12 '15 at 17:14
  • You shouldn't be using the war plugin but the spring boot plugin, you still need the dependencies you cannot do without them. The document, better know as the Spring Boot Reference Guide, speaks about deployment to any container as it doesn't differ (or at least shouldn't) per container. A war is a war. – M. Deinum Oct 12 '15 at 18:38
  • 1
    @KarthikBalasubramanian I have the same issue..Did you get the fix for this? – Abx Jun 08 '16 at 17:33

0 Answers0