Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root cause of ServletException. org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: #5728

Open
buggydog opened this issue Aug 23, 2024 · 1 comment

Comments

@buggydog
Copy link

In one our projects, we use the following packages: jersey-server (2.28) & poi-ooxml(5.2.5). Both these packages have commons-io as sub-dependencies.

While poi-ooxml uses 2.15 version of commons-io, jersey uses 2.11 version, irrespective if we upgrade the jersey to its latest release (https://github.com/eclipse-ee4j/jersey/blob/3.1.8/tools/jersey-release-notes-maven-plugin/pom.xml#L77).

When we run the project, we get the following error:

<[ACTIVE] ExecuteThread:

'1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <> <[severity-value: 8] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-101017> <[ServletContext@264727129 [app:abc

module:abc.war path:null spec-version: 3.1]] Root cause of ServletException. org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError:

org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream.builder()Lorg/apache/commons/io/output/UnsynchronizedByteArrayOutputStreamSBuilder

We have explicitly included commons-io 2.15.1 dependency in Pom.xml so that the project uses this version and ignores the others.

My first impression is that there's a dependency clash for commons-io. Since I am pretty new with Java & inexperienced with it, I would like to know if there's a way to solve this dependency clash.

pom.xml

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

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

<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.28</version> 
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.14.jdk17-redhat-00001</version>
</dependency>

<dependency>
<groupid> org.apache.commons </groupid>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>

<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1</version>
</dependency>

<dependency>
<groupId>org.jvnet.staxex</groupId>
<artifactId>stax-ex</artifactId>
<version>1.7.7</version>
</dependency>


<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>

<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>5.0.3</version> <!--3.1.0->
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<version>1.9.14.jdk17-redhat-00001</version>
</dependency>

<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.6</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.5</version> 
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>

<!dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json</artifactId>
<version>2.0-m05-1</version>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.14.jdk17-redhat-00001</version>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.14.jdk17-redhat-00001</version>
</dependency>

<dependency>
<groupId>clojure-interop</groupId>
<artifactId>javax.net</artifactId>
<version>1.0.0</version>
</dependency>

<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>2.1.3</version>
</dependency>

<dependency>
<groupId>org.ow2.asm</groupId> <artifactId>asm</artifactId>
<version>9.6</version>
</dependency>

<dependency>
<groupId>org.daisy.pipeline</groupId> <artifactId>common-stax</artifactId>
<version>1.0.0</version>
</dependency>

<dependency>
<groupId>org.daisy.pipeline</groupId>
<artifactId>common-stax</artifactId>
<version>1.0.0</version>
</dependency>

<dependency>
<groupId>org.daisy.pipeline</groupId>
<artifactId>common-utils</artifactId>
<<version>6.0.0</version>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.17.0</version>
</dependency>

<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>2.0</version>
</dependency>

<dependency>
<groupId>com.github.virtuald</groupId>
<artifactId>curvesapi</artifactId>
<version>1.08</version>
</dependency>

<dependency>
<groupId>org.daisy.pipeline</groupId> <artifactId>framework-core</artifactId>
<version>8.0.1</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.1-jre</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
</dependency>
</dependencies>
@senivam
Copy link
Contributor

senivam commented Aug 27, 2024

Both listed dependencies:

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

<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.28</version> 
</dependency>

do not use commons-io in any version. Or at least I do not see any references to the commons-io in the dependency tree of those modules.

the dependency

<!dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json</artifactId>
<version>2.0-m05-1</version>
</dependency>

is wrongly included (note the ! sign in the <!dependency> tag) which makes the whole pom invalid, so I presume in the real project it's included correctly. It is old and does not exist in most recent versions of Jersey.

You can check dependencies of a maven project using

mvn dependency:tree

however, if you want to exclude some 4th party dependencies from dependencies of your project, it's possible to apply:

<dependency>
   ....
   <exclusions>
       <exclusion>
           <groupId>....</groupId>
           <artifactId>...</artifactId>
       </exclusion>
  </exclusions>
</dependency>

modify accordingly to your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants