1

I am trying to deploy my jHipster app war on to Glassfish and keep getting the following error....

"The lifecycle method [initApplication] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void com.org.myapp.Application.initApplication() throws java.io.IOException] of type [METHOD]."

Reading over some posts, it looks like a glassfish issue. I also tried the suggestions from the post 'https://github.com/spring-projects/spring-boot/issues/1355' by 'dsyer'. It did not work. I am still having the issue.

Has anyone encountered this issue? How did you get over it? Really appreciate any help!

K.AJ
  • 1,292
  • 11
  • 17

1 Answers1

0

The error message tells you that you have annotated your initApplication() method with @PostConstruct which has a throws-declaration, which is not allowed. Remove the throws IOException from its signature, catch the IOException, rethrow a RuntimeException, and the error should disappear.

Jan Dörrenhaus
  • 6,581
  • 2
  • 34
  • 45
  • Hi Jan, Thank you for your advice. I tried that and it did clear the error in my Application class. However GF now barfs on the Spring classes. Here is what I get .. "The lifecycle method [startServer] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer.startServer() throws java.lang.Exception] of type [METHOD]. Please see server.log for more details.]]" And I cannot modify those Spring classes. Any advice? – K.AJ Nov 17 '15 at 22:35
  • 1
    That is probably why you found all those "glassfish issue" posts. Glassfish is VERY anal about what it will allow. Looks like the `org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer` class is not glassfish compatible. Try to make spring not load that class (and all others who offend). Sorry, but that is my limitation on glassfish OR spring knowledge :) – Jan Dörrenhaus Nov 17 '15 at 22:41
  • 1
    Jan, Thank you for your advice. Appreciate it! I will play with it. If I do find a solution, I will post it. – K.AJ Nov 17 '15 at 22:47
  • 1
    @askX You should exclude Spring Boot's DevTools from the artifact you're deploying to Glassfish as they serve no purpose in that environment. – Andy Wilkinson Nov 17 '15 at 23:24
  • @Andy, When I generate the jHipster project for production, it will be all excluded. I am just deploying to my local glassfish and ran into issues. I do agree with you, the dev tools will be excluded for production. – K.AJ Nov 17 '15 at 23:36