Using Java EE with Spring Boot

Hello,

We have a Vaadin application that uses different features of Java EE (Interceptors, @Inject Instance<>, etc.) that we currently run in a TomEE application server. We’re trying to move this application to Spring Boot by doing as little change as possible.

As soon as I include the following dependency in the POM I get the following error when starting the Spring Boot app:

<dependency>
    <groupId>org.apache.openejb</groupId>
    <artifactId>tomee-embedded</artifactId>
    <version>1.7.4</version>
</dependency>
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.2.RELEASE)

Nov 16, 2016 12:07:29 PM org.springframework.boot.SpringApplication reportFailure
SEVERE: Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
    at edu.self.vsb.VaadinSbApplication.main(VaadinSbApplication.java:18)
Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
    at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner$Tomcat8TldSkipSetter.setSkipPattern(SkipPatternJarScanner.java:107)
    at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.setPatternToTomcat8SkipFilter(SkipPatternJarScanner.java:62)
    at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.<init>(SkipPatternJarScanner.java:57)
    at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.apply(SkipPatternJarScanner.java:88)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.prepareContext(TomcatEmbeddedServletContainerFactory.java:207)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:176)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
    ... 8 more

Is there a way to use Java EE with Spring Boot, or must I convert all Java EE code into Spring code?

Thanks a lot

You got a “java.lang.NoSuchMethodError” error,
I think it may be caused by incorrect jar file version.

Some code is calling a method of some class, but your app is using a jar file of the wrong version,
so it can find the class, but the method signature is different.

From your excetption stack info, I guess:
(1)the code who is calling is
org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner$Tomcat8TldSkipSetter.setSkipPattern(SkipPatternJarScanner.java:107)

(2)the class and method called by (1) is:
org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
and the signature should be setJarScanFilter(org.apache.tomcat.JarScanFilter filter)

So, please check the source code of (1), and check the jar version and source code of (2),
see if they are compatible

Same error happened here:
http://stackoverflow.com/questions/33157970/spring-boot-exception-java-lang-nosuchmethoderror-standardjarscanner-setjarsca

You can read the answer, see if it can help you

Ok, thanks for you help. I managed to find and exclude the dependency that was causing the problem, but then another one caused the same problem, and then another one, etc. Maybe I should use another implementation of Java EE but I guess there will always be some kind of conflict…

What tool are you using to manage the jar depedency?
Maven? Ivy? or Gradle?

I’m using Maven.