[ 
https://issues.apache.org/jira/browse/ARTEMIS-3546?focusedWorklogId=683289&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-683289
 ]

ASF GitHub Bot logged work on ARTEMIS-3546:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Nov/21 13:11
            Start Date: 18/Nov/21 13:11
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on pull request #3846:
URL: https://github.com/apache/activemq-artemis/pull/3846#issuecomment-972852060


   I tried poking at it and came up with some changes that pass the PR 
build+tests.
   
   It is failing because the -osgi modules have an entry in their manifest 
saying they should import the org.glashfish.json package, which the build (in 
disabled module, now enabled) and karaf tests module cant then resolve. I dont 
really understand that since nothing seems to reference that package to cause 
it to be imported, and it doesnt look like the deps which were shaded and 
removed actually provided it anyway, so its unclear to me why that behaviour 
arises or would now differ.
   
   I just blindly changed it so that particular package is listed as optional, 
meaning it will only fail if something needing it is actually used and its not 
present at the time. Things seem happy with that along with some other cleanup 
to remove imports/deps that it seems the shading should be removing need of. 
With all these the build works and the karaf client integration tests pass. Not 
sure about the broker module, its not clear its tested, but since nothing 
obviously uses the package and the real change is all in artemis-common it 
seems like it should be much the same.
   
   I added the changes on a branch in my fork 
https://github.com/gemmellr/activemq-artemis/tree/json-fixup-playing-ARTEMIS-3546,
 or you can find the current delta diff below.
   
   <details><summary>Delta diff from prior changes (click to 
expand)</summary><p>
   
   ```
   diff --git a/artemis-commons/pom.xml b/artemis-commons/pom.xml
   index 1b0fe2442f..f40497c79c 100644
   --- a/artemis-commons/pom.xml
   +++ b/artemis-commons/pom.xml
   @@ -39,11 +39,15 @@
             <groupId>org.apache.johnzon</groupId>
             <artifactId>johnzon-core</artifactId>
             <version>${johnzon.version}</version>
   +         <scope>compile</scope>
   +         <optional>true</optional>
          </dependency>
          <dependency>
             <groupId>jakarta.json</groupId>
             <artifactId>jakarta.json-api</artifactId>
             <version>${jakarta.json-api.version}</version>
   +         <scope>compile</scope>
   +         <optional>true</optional>
             <!-- License: EPL 2.0 -->
          </dependency>
          <!-- ^^ these dependencies are shaded on this JAR -->
   @@ -69,7 +73,6 @@
          <dependency>
              <groupId>com.google.errorprone</groupId>
              <artifactId>error_prone_core</artifactId>
   -         <scope>provided</scope>
          </dependency>
          <dependency>
              <groupId>org.wildfly.common</groupId>
   @@ -127,7 +130,6 @@
             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
   -            <version>3.2.4</version>
                <executions>
                   <execution>
                      <phase>package</phase>
   diff --git a/artemis-core-client-osgi/pom.xml 
b/artemis-core-client-osgi/pom.xml
   index b84ba94f7b..1fcfd777a4 100644
   --- a/artemis-core-client-osgi/pom.xml
   +++ b/artemis-core-client-osgi/pom.xml
   @@ -98,8 +98,8 @@
                   <instructions>
                      
<Embed-Dependency>*;scope=compile|runtime;groupId=org.apache.activemq</Embed-Dependency>
                      <Import-Package>
   +                     org.glassfish.json*;resolution:=optional,
                         io.netty.buffer;io.netty.*;version="[4.1,5)",
   -                     org.apache.johnzon.core,
                         *
                      </Import-Package>
                      
<_exportcontents>org.apache.activemq.artemis.*;-noimport:=true</_exportcontents>
   diff --git a/artemis-features/src/main/resources/features.xml 
b/artemis-features/src/main/resources/features.xml
   index 5de867530f..d5894b1fc3 100644
   --- a/artemis-features/src/main/resources/features.xml
   +++ b/artemis-features/src/main/resources/features.xml
   @@ -53,9 +53,6 @@
    
                <bundle 
dependency="true">mvn:org.jboss.logging/jboss-logging/${jboss.logging.version}</bundle>
                <bundle 
dependency="true">mvn:org.jgroups/jgroups/${jgroups.version}</bundle>
   -
   -            <bundle 
dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.json-api-1.1/${servicemix.json-1.1.spec.version}</bundle>
   -            
<bundle>mvn:org.apache.johnzon/johnzon-core/${johnzon.version}</bundle>
        </feature>
    
        <feature name="artemis-core" version="${pom.version}" 
description="ActiveMQ Artemis broker libraries">
   diff --git a/artemis-jms-client-osgi/pom.xml 
b/artemis-jms-client-osgi/pom.xml
   index 6a43150ecb..e95708fb3e 100644
   --- a/artemis-jms-client-osgi/pom.xml
   +++ b/artemis-jms-client-osgi/pom.xml
   @@ -107,6 +107,7 @@
                   <instructions>
                      
<Embed-Dependency>*;scope=compile|runtime;groupId=org.apache.activemq</Embed-Dependency>
                      <Import-Package>
   +                     org.glassfish.json*;resolution:=optional,
                         io.netty.buffer;io.netty.*;version="[4.1,5)",
                         *
                      </Import-Package>
   diff --git a/artemis-server-osgi/pom.xml b/artemis-server-osgi/pom.xml
   index b6dd8e49c8..8a60d7548f 100644
   --- a/artemis-server-osgi/pom.xml
   +++ b/artemis-server-osgi/pom.xml
   @@ -147,6 +147,7 @@
                      
<Embed-Dependency>*;scope=compile|runtime;groupId=org.apache.activemq</Embed-Dependency>
                      <Import-Package>
                         org.postgresql*;resolution:=optional,
   +                     org.glassfish.json*;resolution:=optional,
                         io.netty.buffer;io.netty.*;version="[4.1,5)",
                         *
                      </Import-Package>
   diff --git a/pom.xml b/pom.xml
   index 1ee3834ace..8a539d738c 100644
   --- a/pom.xml
   +++ b/pom.xml
   @@ -64,7 +64,7 @@
          <module>integration/activemq-spring-integration</module>
          <module>artemis-distribution</module>
          <module>tests</module>
   -      <!-- <module>artemis-features</module> -->
   +      <module>artemis-features</module>
          <module>artemis-quorum-api</module>
          <module>artemis-quorum-ri</module>
       </modules>
   @@ -105,6 +105,7 @@
          <errorprone.version>2.9.0</errorprone.version>
          
<maven.enforcer.plugin.version>3.0.0-M3</maven.enforcer.plugin.version>
          <maven.bundle.plugin.version>5.1.2</maven.bundle.plugin.version>
   +      <maven.shade.plugin.version>3.2.4</maven.shade.plugin.version>
          
<maven.checkstyle.plugin.version>3.1.1</maven.checkstyle.plugin.version>
          <sevntu.checks.version>1.39.0</sevntu.checks.version>
          <checkstyle.version>8.43</checkstyle.version>
   @@ -1428,7 +1429,7 @@
                <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-shade-plugin</artifactId>
   -               <version>3.2.0</version>
   +               <version>${maven.shade.plugin.version}</version>
                </plugin>
                <plugin>
                   <groupId>org.eclipse.jetty</groupId>
   ```
   </p></details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 683289)
    Time Spent: 4h 40m  (was: 4.5h)

> ClassNotFoundException: javax.json.JsonValue when creating an 
> ActiveMQConnectionFactory using artemis-jakarta-client-all
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-3546
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3546
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: JMS
>    Affects Versions: 2.19.0
>            Reporter: Andy Wilkinson
>            Assignee: Clebert Suconic
>            Priority: Major
>             Fix For: 2.20.0
>
>          Time Spent: 4h 40m
>  Remaining Estimate: 0h
>
> As expected, {{artemis-jakarta-client-all}} contains the various 
> {{jakarta.json.\*}} classes from Jakarta EE 9. However, its bytecode still 
> references the {{javax.json.\*}} classes from EE 8. This results in a failure 
> at runtime when creating an {{ActiveMQConnectionFactory}}:
> {noformat}
> Exception in thread "main" java.lang.IllegalStateException: 
> java.lang.NoClassDefFoundError: javax/json/JsonValue
>       at 
> org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:225)
>       at 
> org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:218)
>       at example.Main.main(Main.java:8)
> Caused by: java.lang.NoClassDefFoundError: javax/json/JsonValue
>       at 
> org.apache.activemq.artemis.uri.schema.connector.TCPTransportConfigurationSchema.getTransportConfigurations(TCPTransportConfigurationSchema.java:68)
>       at 
> org.apache.activemq.artemis.uri.schema.serverLocator.TCPServerLocatorSchema.internalNewObject(TCPServerLocatorSchema.java:42)
>       at 
> org.apache.activemq.artemis.uri.schema.serverLocator.TCPServerLocatorSchema.internalNewObject(TCPServerLocatorSchema.java:33)
>       at 
> org.apache.activemq.artemis.utils.uri.URISchema.newObject(URISchema.java:86)
>       at 
> org.apache.activemq.artemis.utils.uri.URISchema.newObject(URISchema.java:30)
>       at 
> org.apache.activemq.artemis.utils.uri.URIFactory.newObject(URIFactory.java:59)
>       at 
> org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.newLocator(ServerLocatorImpl.java:333)
>       at 
> org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.setBrokerURL(ActiveMQConnectionFactory.java:243)
>       at 
> org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:223)
>       ... 2 more
> Caused by: java.lang.ClassNotFoundException: javax.json.JsonValue
>       at 
> java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
>       at 
> java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
>       at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
>       ... 11 more
> {noformat}
> With artemis-jakarta-client-all-2.19.0.jar on the classpath, the failure 
> above was produced by the following main class:
> {code:java}
> package example;
> import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
> public class Main {
>       
>     public static void main(String[] args) {
>         new ActiveMQConnectionFactory();
>     }
> }
> {code}
> The shaded Johnzon code also has references to {{javax.json.\*}} classes.
> A similar problem exists with {{artemis-jakarta-client}} when upgrading its 
> transitive dependencies to their Jakarta EE 9 versions.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to