0

I'm working in Java web project running on a jetty web server. I have class A that inherit from B, at runtime I've found that the class A is not loading the methods of the class B. Class A:

public class A extends B{
...
}

And B:

public class B extends Serializable{

public void sampleMethod(){}
...
}

After adding some logging using Java reflection, when trying to find the superclass of A like so:

Class.forName("A").getSuperClass();

The previous line of code returns that the class Object is the superclass of A. I'm using JDK 8 and Jetty 9.

Also I'm using Jersey:

<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet</artifactId>
</dependency>

<dependency>
    <groupId>org.glassfish.jersey.inject</groupId>
    <artifactId>jersey-hk2</artifactId>
</dependency>

<dependency>
    <groupId>org.glassfish.hk2</groupId>
    <artifactId>guice-bridge</artifactId>
</dependency>

<dependency>
    <groupId>org.glassfish.jersey.ext</groupId>
    <artifactId>jersey-bean-validation</artifactId>
</dependency>

<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
</dependency>

With this running configuration:

this.packages("com.orange.erable.notif.ws.external.resources");
this.register(CheckStatusResource.class);
//
// register custom jackson mapper
this.register(JacksonObjectMapperProvider.class);
// register roles allowed feature
this.register(RolesAllowedDynamicFeature.class);
// register auth filter
this.register(ContainerAuthExtFilter.class);
this.register(VersionFilterServlet.class);
this.register(SenderIdAuthFilter.class);
this.register(ModelValidationExceptionMapper.class);
this.register(DataValidationExceptionMapper.class);
this.register(DataNotificationExceptionMapper.class);
this.register(ValidationExceptionMapper.class);
this.register(JsonParseExceptionMapper.class, 1);
this.register(JsonProcessingExceptionMapper.class, 1);
this.register(JsonMappingExceptionMapper.class, 1);
this.register(QueryParamExceptionMapper.class, 1);
this.register(WebApplicationExceptionMapper.class);
this.register(GlobalExceptionMapper.class);
this.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
this.register(DateParamConverterProvider.class);
this.register(PaginationBoundaryParamConverterProvider.class);
this.register(MappableExceptionMapper.class, 1);
this.register(MappableExceptionWrapperInterceptor.class);
this.register(JsonCustomExceptionMapper.class);

this.register(MultiPartFeature.class);

This issue is linked also to this problem.

EDIT: I'm using Jetty 9.22, I have tried to run the project on different machines with the same Jetty version, the described behaviour is just discovered in some of them.

Community
  • 1
  • 1
Ismail
  • 2,322
  • 1
  • 12
  • 26
  • Make sure you are using a recent version of Jetty 9.x (such as 9.4.24.v20191120), as some versions of Jetty 9 had a server class resolve bug. – Joakim Erdfelt Nov 26 '19 at 17:06
  • @joakim Erdfelt, there is some edits for more explanation. Is there some work to do to prevent this version bugs you just talked about? – Ismail Nov 26 '19 at 17:26
  • 9.2.x is EOL (End of Life) and is unsupported - https://www.eclipse.org/jetty/documentation/current/what-jetty-version.html – Joakim Erdfelt Nov 26 '19 at 17:40

1 Answers1

1

I'm using Jetty 9.22, I have tried to run the project on different machines with the same Jetty version, the described behaviour is just discovered in some of them.

That's a tell tale sign of multiple copies of the same class in multiple locations.

Since you are using maven, consider running one of the duplicate class detection plugins to find out what you have going on.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • We have found a duplicate of the class A that doesn't inherit from B. The problem is solved thx a lot. – Ismail Nov 27 '19 at 18:05