问题
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
来源:https://stackoverflow.com/questions/33083368/how-to-deploy-spring-boot-application-on-glassfish-4-1-1