[ 
https://issues.apache.org/jira/browse/TOMEE-4418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17889648#comment-17889648
 ] 

Wolfgang Knauf commented on TOMEE-4418:
---------------------------------------

I tried it, and it did not work :(. Probably because 
"org.apache.tomee:openejb-client" also bundles the "wrong" jakartaee-api 
package. Here is a snippet from "mvn dependency:tree" - the last line already 
contains my change:
{quote}{{INFO] +- 
org.apache.tomee:arquillian-tomee-remote:jar:10.0.0-M4-SNAPSHOT:test}}
{{...}}
{{[INFO] |  +- org.apache.tomee:openejb-client:jar:10.0.0-M4-SNAPSHOT:test}}
{{[INFO] |  |  +- org.apache.tomee:jakartaee-api:jar:10.0-M2:test}}
{{...}}
{{[INFO] |  +- 
org.apache.tomee:arquillian-tomee-common:jar:10.0.0-M4-SNAPSHOT:test}}
{{[INFO] |  |  +- org.apache.tomee:jakartaee-api:jar:tomcat:10.0-M2:test}}
{{...}}
{quote}
 

But I think I found a more simple solution: define the dependency 
"org.apache.tomcat:tomcat-servlet-api" before 
"org.apache.tomee:arquillian-tomee-remote":

 
{quote}{{        <dependency>}}
{{          <groupId>org.apache.tomcat</groupId>}}
{{          <artifactId>tomcat-servlet-api</artifactId>}}
{{          <scope>provided</scope>}}
{{          <version>10.1.25</version>}}
{{        </dependency>}}
{{        <dependency>}}
{{          <groupId>org.apache.tomee</groupId>}}
{{          <artifactId>arquillian-tomee-remote</artifactId>}}
{{          <version>10.0.0-M2</version>}}
{{          <scope>test</scope>}}
{{        </dependency>}}
{quote}
Now the ServletException is picked from the "correct" jar file.

> "arquillian-tomee-remote": SerialVersionUID conflict with ServletException
> --------------------------------------------------------------------------
>
>                 Key: TOMEE-4418
>                 URL: https://issues.apache.org/jira/browse/TOMEE-4418
>             Project: TomEE
>          Issue Type: Bug
>          Components: TomEE Arquillian Adapters
>    Affects Versions: 9.1.3, 10.0.0-M2
>            Reporter: Wolfgang Knauf
>            Priority: Minor
>
> When updating a project to JakartaEE and TomEE 9, I noticed this problem: the 
> project has one unit test that triggers a ServletException on the server 
> side, which is caught, serialized and deserialized on the client side.
> The client side is a unit test driven by "arquillian-tomee-remote".
> Unfortunately, the underlying Tomcat library 
> ([https://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat-servlet-api/10.0.27/tomcat-servlet-api-10.0.27.jar)]
>  contains a ServletException with a SerialVersionID of "1", which is not the 
> same as the version in the JakartaEE reference implementation.
> Now the problem: my test project has those dependencies:
>  
> {quote}{{<dependency>}}
> {{  <groupId>org.apache.tomee</groupId>}}
> {{  <artifactId>arquillian-tomee-remote</artifactId>}}
> {{  <version>9.1.3</version>}}
> {{  <scope>test</scope>}}
> {{</dependency>}}
> {{<dependency>}}
> {{  <groupId>org.apache.tomcat</groupId>}}
> {{  <artifactId>tomcat-servlet-api</artifactId>}}
> {{  <scope>provided</scope>}}
> {{  <version>10.0.27</version>}}
> {{</dependency>}}
> {quote}
>  
> With the previous version, this worked. But with the new arquillian adapter, 
> it pulls in 
> [https://repo.maven.apache.org/maven2/org/apache/tomee/jakartaee-api/9.1.1/jakartaee-api-9.1.1.jar]
>  , which also contains a ServletException, but with a different 
> SerialVersionUID.
> Thus, the test fails:
> {{class java.io.InvalidClassException: jakarta.servlet.ServletException; 
> local class incompatible: stream classdesc serialVersionUID = 1, local class 
> serialVersionUID = 4221302886851315160}}
>  
> My workaround: exclude "org.apache.tomee:jakartaee-api" from the arquillian 
> adapter, then add it back after declaring the Tomcat servlet api (the one 
> with the "1" SerialVersionUID). It seems the ServletException is now loaded 
> from the first jar, and my test works.
> {quote}{{<dependency>}}
> {{  <groupId>org.apache.tomee</groupId>}}
> {{  <artifactId>arquillian-tomee-remote</artifactId>}}
> {{  <version>9.1.3</version>}}
> {{  <scope>test</scope>}}
> {{  <exclusions>}}
> {{    <exclusion>}}
> {{      <groupId>org.apache.tomee</groupId>}}
> {{      <artifactId>jakartaee-api</artifactId>}}
> {{    </exclusion>}}
> {{  </exclusions>}}
> {{</dependency>}}
> {{<dependency>}}
> {{  <groupId>org.apache.tomcat</groupId>}}
> {{  <artifactId>tomcat-servlet-api</artifactId>}}
> {{  <scope>provided</scope>}}
> {{  <version>10.0.27</version>}}
> {{</dependency>}}
> {{<dependency>}}
> {{  <groupId>org.apache.tomee</groupId>}}
> {{  <artifactId>jakartaee-api</artifactId>}}
> {{  <scope>provided</scope>}}
> {{  <version>9.1.1</version>}}
> {{</dependency>}}
> {quote}
>  
> I have no idea whether this is anything that you could change. It would work 
> if the arquillian adapter would pull the tomcat servlet api first. Or the 
> Tomcat guys could fix the SerialVersionUID ;).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to