How to build a WAR file to deploy on Tomcat from a JHipster Spring Boot project?
15:40 03 Mar 2016

I created a project with JHipster, but made changes and added stuff to it. It runs ok when ran as a Spring Boot project from the IDE (Intellij), but when trying to build a WAR and deploy it on a Tomcat 7, it fails with the following stack trace:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/transaction/jta/JndiJtaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: No JTA UserTransaction available - specify either 'userTransaction' or 'userTransactionName' or 'transactionManager' or 'transactionManagerName'
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:543)
        ... 41 more
Caused by: java.lang.IllegalStateException: No JTA UserTransaction available - specify either 'userTransaction' or 'userTransactionName' or 'transactionManager' or 'transactionManagerName'
        at org.springframework.transaction.jta.JtaTransactionManager.checkUserTransactionAndTransactionManager(JtaTransactionManager.java:494)
        at org.springframework.transaction.jta.JtaTransactionManager.afterPropertiesSet(JtaTransactionManager.java:436)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
        ... 51 more

I also tried:

mvn -Pprod clean package

but that also fails with:

Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.35 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Windows 7 0.0.0)]: Connected on socket gsod2iXnNubgdt_gVHUZ with id 68003640
PhantomJS 1.9.8 (Windows 7 0.0.0) ERROR
  ReferenceError: Can't find variable: google
  at C:/Dev/workspaces/myProject/src/main/webapp/scripts/components/view/geoChart.directive.js:9
PhantomJS 1.9.8 (Windows 7 0.0.0) ERROR
  ReferenceError: Can't find variable: google
  at C:/Dev/workspaces/myProject/src/main/webapp/scripts/components/view/geoChart.directive.js:9

PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 0 of 0 ERROR (1.301 secs / 0 secs)

Warning: Task "karma:unit" failed. Use --force to continue.

Aborted due to warnings.

I have added the Google GeoChart, and that seems to cause an issue.

What I would like to get is a classic WAR that I can deploy on Tomcat, but I am obviously doing something wrong and I don't know what.

Thank you.

maven tomcat spring-boot jhipster