2

I try to build and run jhipster registry, but I get an error :

mvn package -Pprod

I get following errors in test :

Tests in error: 
  SwaggerBasePathRewritingFilterTest.<init>:20 »  Unresolved compilation problem...
  SwaggerBasePathRewritingFilterTest.<init>:20 »  Unresolved compilation problem...
  SwaggerBasePathRewritingFilterTest.<init>:20 »  Unresolved compilation problem...
  SwaggerBasePathRewritingFilterTest.<init>:20 »  Unresolved compilation problem...
  AccountResourceTest.setup:33 » NoClassDefFound HttpServletRequest
  AccountResourceTest.setup:33 » NoClassDefFound HttpServletRequest
  AccountResourceTest.setup:33 » NoClassDefFound HttpServletRequest
  AccountResourceTest.setup:33 » NoClassDefFound HttpServletRequest
  UserJWTControllerTest.setup:39 » NoClassDefFound HttpServletResponse
  UserJWTControllerTest.setup:39 » NoClassDefFound HttpServletResponse
  UserJWTControllerTest.setup:39 » NoClassDefFound HttpServletResponse
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest

If I skip tests, build is ok, but I got same error when I launch :

./mvnw -Pdev

2018-02-16 17:52:22.011  WARN 5354 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'undertowEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webConfigurer' defined in file [/home/denis/ngworkspace/jhipster-registry/target/classes/io/github/jhipster/registry/config/WebConfigurer.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.github.jhipster.registry.config.WebConfigurer$$EnhancerBySpringCGLIB$$a8d0938a]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
        The import io.undertow.UndertowOptions cannot be resolved
        ServletContext cannot be resolved to a type
        ServletException cannot be resolved to a type
        DispatcherType cannot be resolved to a type
        DispatcherType cannot be resolved to a variable
        DispatcherType cannot be resolved to a variable
        DispatcherType cannot be resolved to a variable
        The type io.undertow.Undertow$Builder cannot be resolved. It is indirectly referenced from required .class files
        This lambda expression refers to the missing type Undertow$Builder
        UndertowOptions cannot be resolved to a variable
        ServletContext cannot be resolved to a type
        DispatcherType cannot be resolved to a type
        FilterRegistration cannot be resolved to a type
        ServletContext cannot be resolved to a type
        DispatcherType cannot be resolved to a type
        FilterRegistration cannot be resolved to a type
        ServletRegistration cannot be resolved to a type

2018-02-16 17:52:22.032 ERROR 5354 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'undertowEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webConfigurer' defined in file [/home/denis/ngworkspace/jhipster-registry/target/classes/io/github/jhipster/registry/config/WebConfigurer.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.github.jhipster.registry.config.WebConfigurer$$EnhancerBySpringCGLIB$$a8d0938a]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
        The import io.undertow.UndertowOptions cannot be resolved
        ServletContext cannot be resolved to a type
        ServletException cannot be resolved to a type
...

Strangely, when I execute

mvn clean package -Pprod

build is ok, but it does not launch (same error).

I use registry in version 3.2.4, cloned from github, on Linux.

How build registry without error ? Do I forget something ?

Thanks, Denis

Atatorus
  • 513
  • 4
  • 16

3 Answers3

12

I found the solution. I added these dependencies in pom.xml :

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-undertow</artifactId>
        <scope>provided</scope>
    </dependency>

and all work. These dependencies were nevertheless obtained transitively, and I don't known why I have to add explicitly. Anybody has the response ?

Denis

Atatorus
  • 513
  • 4
  • 16
  • 2
    I think problem with maven plugin in eclipse because I run same project in intellij idea working fine but when I import same project in eclipse it whowing error import io.undertow.UndertowOptions. – Az.MaYo Jan 03 '19 at 13:54
5

If you were running with Eclipse: in Eclipse select Project Properties->Maven->Active Maven Profiles (comma separated), and make it dev That triggers a maven update of the project and everything compiles No need to put dependencies in the pom

Yuri Gridin
  • 469
  • 5
  • 6
  • This helped me to fix the problem on IntelliJ as well. My project was compiling fine, today it showed the javax.servlet.* missing error. In the Maven tab, I've just clicked the refresh button (Reimport All Maven Projects). Now project compiles again. Thanks! – funder7 Apr 20 '20 at 15:10
-1

This works

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
    <scope>provided</scope>
</dependency>
M--
  • 25,431
  • 8
  • 61
  • 93
Arséne
  • 95
  • 4