2017-09-29 5 views
0

Contexte:Comment puis-je ajouter org.json (json) à mon application pour qu'elle se déploie avec succès sur JBoss Fuse?

Je veux utiliser org.json.JSONArray et org.json.JSONObject, mais je suis pas clair sur la façon dont je peux ajouter le support dans mon conteneur JBoss fusible.

Problème:

laissant tomber simplement le pot (à savoir "JSON-20170516.jar") dans le dossier fusible JBoss "déployer" ne semble suffire.
- En fait, il semble causer des problèmes avec d'autres faisceaux ...

-à-dire,

<dependency> 
     <groupId>org.json</groupId> 
     <artifactId>json</artifactId> 
     <version>20170516</version> 
     <type>jar</type> 
    </dependency> 

Question

Est-il possible d'apporter un soutien à cette api dans JBoss Fusible - et, si oui, comment cela peut-il être réalisé?

pom.xml ressemble à ceci:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>aaa.bbb.ccc</groupId> 
    <artifactId>myTestProj</artifactId> 
    <version>1</version> 
    <packaging>bundle</packaging> 
    <name>myTestProj</name> 
    <description>myTestProj</description> 

    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <skipTests>true</skipTests> 
    <mq.version>8.0.0.7</mq.version> 
    </properties> 

    <dependencies> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.7.25</version> 
     <scope>provided</scope>    
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.25</version> 
     <scope>provided</scope>    
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-core</artifactId> 
     <version>2.17.0</version> 
     <scope>provided</scope> 
    </dependency>   
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-restlet</artifactId> 
     <version>2.17.0</version> 
     <scope>provided</scope>      
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-cdi</artifactId> 
     <version>2.17.0</version> 
     <scope>provided</scope>      
    </dependency> 

    <!-- testing "netty4-http" -->  
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-netty4-http</artifactId> 
     <version>2.17.0</version> 
     <scope>provided</scope>      
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-jackson</artifactId> 
     <version>2.17.0</version> 
     <scope>provided</scope>    
    </dependency>   
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-http4</artifactId> 
     <version>2.17.0</version> 
     <scope>provided</scope> 
    </dependency>       
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-cxf</artifactId> 
     <version>2.17.0</version> 
     <scope>provided</scope>    
    </dependency> 
    <dependency> 
     <groupId>com.ibm.mq</groupId> 
     <artifactId>allclient</artifactId> 
     <version>${mq.version}</version> 
     <scope>provided</scope>    
    </dependency> 
    <dependency> 
     <groupId>com.ibm.mq</groupId> 
     <artifactId>jms</artifactId> 
     <version>${mq.version}</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-jsonpath</artifactId> 
     <version>2.17.0</version> 
     <scope>provided</scope> 
    </dependency> 

    <!-- version to use, as per: https://mvnrepository.com/artifact/org.apache.camel/camel-jackson/2.17.0.redhat-630283 --> 
    <dependency> 
     <groupId>com.fasterxml.jackson.core</groupId> 
     <artifactId>jackson-databind</artifactId> 
     <version>2.6.3</version> 
    </dependency> 


    <dependency> 
     <groupId>org.json</groupId> 
     <artifactId>json</artifactId> 
     <version>20170516</version> 
     <type>jar</type> 
    </dependency> 

    </dependencies> 

    <build> 
    <finalName>${project.artifactId}-${project.version}</finalName> 

    <resources> 
     <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
     </resource> 
    </resources> 

    <plugins> 

     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.1</version> 
     <configuration> 
      <source>1.8</source> 
      <target>1.8</target> 
      <showDeprecation>true</showDeprecation> 
     </configuration> 
     </plugin> 

     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>jaxb2-maven-plugin</artifactId> 
     <version>2.3</version> 
     <executions> 
      <execution> 
      <id>xjc</id> 
      <goals> 
       <goal>xjc</goal> 
      </goals> 
      </execution> 
     </executions>   
     <configuration> 
      <sources> 
      <source>src/main/resources/xsd/my.xsd</source> 
      </sources> 
      <packageName>aaa.bbb.ccc.generated</packageName>      
      <verbose default-value="false">${xjc.verbose}</verbose> 
     </configuration>     
     </plugin>    

     <plugin> 
     <groupId>org.apache.felix</groupId> 
     <artifactId>maven-bundle-plugin</artifactId> 
     <version>3.3.0</version> 
     <extensions>true</extensions> 
     <configuration> 
      <instructions> 
      <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName> 
      <Export-Package>aaa.bbb.ccc*</Export-Package> 
      <Import-Package>*</Import-Package>                  
      </instructions> 
     </configuration> 
     </plugin>    
    </plugins> 
    </build> 
</project> 

dossier Deploy ressemble à ceci ... C: \ tools \ jboss-fusible 6.3.0.redhat- 187 \ deploy> dir Volume dans le lecteur C est OSDisk Le numéro de série du volume est D89B-75DE

Directory of C:\tools\jboss-fuse-6.3.0.redhat-187\deploy 

09/29/2017 11:58 AM <DIR>   . 
09/29/2017 11:58 AM <DIR>   .. 
09/29/2017 11:37 AM   20,073 myTestProj-1.jar 
06/29/2017 01:00 AM   159,649 com.ibm.mq.osgi.allclientprereqs_8.0.0.7.jar 
06/29/2017 01:00 AM   8,011,749 com.ibm.mq.osgi.allclient_8.0.0.7.jar 
06/29/2017 01:00 AM   4,088,715 com.ibm.mq.osgi.java_8.0.0.7.jar 
06/29/2017 01:00 AM   171,064 com.ibm.msg.client.osgi.commonservices.j2se_8.0.0.7.jar 
06/29/2017 01:00 AM   48,715 com.ibm.msg.client.osgi.jms.prereq_8.0.0.7.jar.DISABLE 
06/29/2017 01:00 AM   639,807 com.ibm.msg.client.osgi.jms_8.0.0.7.jar 
06/29/2017 01:00 AM   216,218 com.ibm.msg.client.osgi.nls_8.0.0.7.jar 
06/29/2017 01:00 AM   279,861 com.ibm.msg.client.osgi.wmq.nls_8.0.0.7.jar 
06/29/2017 01:00 AM   92,406 com.ibm.msg.client.osgi.wmq.prereq_8.0.0.7.jar 
06/29/2017 01:00 AM   7,963,226 com.ibm.msg.client.osgi.wmq_8.0.0.7.jar 
09/28/2017 12:11 PM   57,264 json-20170516.jar 
09/15/2016 04:19 AM    873 README 
      14 File(s)  21,771,379 bytes 
      2 Dir(s) 135,870,164,992 bytes free 

C:\tools\jboss-fuse-6.3.0.redhat-187\deploy> 

erreur connecté console ressemble à ceci (après l'ajout du pot de org.json dans le dossier Deploy)

2017-09-29 11:58:11,662 | INFO | edhat-187/deploy | BlueprintCamelContext   | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | Apache Camel 2.17.0.redhat-630187 (CamelContext: aaa.bbb.ccc.trans.routing) is shutting down 
2017-09-29 11:58:11,663 | INFO | edhat-187/deploy | BlueprintCamelContext   | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | Apache Camel 2.17.0.redhat-630187 (CamelContext: aaa.bbb.ccc.trans.routing) uptime 
2017-09-29 11:58:11,663 | INFO | edhat-187/deploy | BlueprintCamelContext   | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | Apache Camel 2.17.0.redhat-630187 (CamelContext: aaa.bbb.ccc.trans.routing) is shutdown in 0.001 seconds 
2017-09-29 11:58:11,664 | ERROR | edhat-187/deploy | BlueprintContainerImpl   | 23 - org.apache.aries.blueprint.core - 1.4.5 | Unable to start blueprint container for bundle aaa.bbb.ccc.myTestProj/1.0.0 
org.osgi.service.blueprint.container.ComponentDefinitionException: Error when instantiating bean wmqcf of class com.ibm.mq.jms.MQConnectionFactory 
    at org.apache.aries.blueprint.container.BeanRecipe.wrapAsCompDefEx(BeanRecipe.java:361)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BeanRecipe.getInstanceFromType(BeanRecipe.java:351)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:282)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:830)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:811)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[23:org.apache.aries.blueprint.core:1.4.5] 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_141] 
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:688)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:383)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:270)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:294)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:263)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:253)[23:org.apache.aries.blueprint.core:1.4.5] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[17:org.apache.aries.util:1.1.0] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[17:org.apache.aries.util:1.1.0] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[17:org.apache.aries.util:1.1.0] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[17:org.apache.aries.util:1.1.0] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[17:org.apache.aries.util:1.1.0] 
    at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1127)[org.apache.felix.framework-4.4.1.jar:] 
    at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)[org.apache.felix.framework-4.4.1.jar:] 
    at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)[org.apache.felix.framework-4.4.1.jar:] 
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4429)[org.apache.felix.framework-4.4.1.jar:] 
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2100)[org.apache.felix.framework-4.4.1.jar:] 
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)[org.apache.felix.framework-4.4.1.jar:] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[9:org.apache.felix.fileinstall:3.5.0] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[9:org.apache.felix.fileinstall:3.5.0] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1207)[9:org.apache.felix.fileinstall:3.5.0] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:504)[9:org.apache.felix.fileinstall:3.5.0] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[9:org.apache.felix.fileinstall:3.5.0] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[9:org.apache.felix.fileinstall:3.5.0] 
Caused by: java.lang.NoClassDefFoundError: com/ibm/msg/client/commonservices/j2se/CommonServicesImplementation 
    at com.ibm.msg.client.commonservices.j2se.J2SEComponent.getFactoryClass(J2SEComponent.java:121)[com.ibm.mq.jmqi.jar:8.0.0.7 - p800-007-170629] 
    at com.ibm.msg.client.commonservices.componentmanager.Component.getDetails(Component.java:250)[com.ibm.mq.jmqi.jar:8.0.0.7 - p800-007-170629] 
    at com.ibm.msg.client.commonservices.trace.Trace.getVersion(Trace.java:2108)[com.ibm.mq.jmqi.jar:8.0.0.7 - p800-007-170629] 
    at com.ibm.msg.client.commonservices.trace.Trace.createFFSTString(Trace.java:2053)[com.ibm.mq.jmqi.jar:8.0.0.7 - p800-007-170629] 
    at com.ibm.msg.client.commonservices.trace.Trace.ffstInternal(Trace.java:1938)[com.ibm.mq.jmqi.jar:8.0.0.7 - p800-007-170629] 
    at com.ibm.msg.client.commonservices.trace.Trace.ffst(Trace.java:1795)[com.ibm.mq.jmqi.jar:8.0.0.7 - p800-007-170629] 
    at com.ibm.msg.client.jms.JmsFactoryFactory.getInstance(JmsFactoryFactory.java:205)[com.ibm.mqjms.jar:8.0.0.7 - p800-007-170629] 
    at com.ibm.mq.jms.MQConnectionFactory.initialiseMQConnectionFactory(MQConnectionFactory.java:3210)[com.ibm.mqjms.jar:8.0.0.7 - p800-007-170629] 
    at com.ibm.mq.jms.MQConnectionFactory.<init>(MQConnectionFactory.java:252)[com.ibm.mqjms.jar:8.0.0.7 - p800-007-170629] 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_141] 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_141] 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_141] 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_141] 
    at org.apache.aries.blueprint.utils.ReflectionUtils.newInstance(ReflectionUtils.java:331) 
    at org.apache.aries.blueprint.container.BeanRecipe.newInstance(BeanRecipe.java:984) 
    at org.apache.aries.blueprint.container.BeanRecipe.getInstanceFromType(BeanRecipe.java:349) 
    ... 31 more 
Caused by: java.lang.ClassNotFoundException: Unable to load class 'com.ibm.msg.client.commonservices.j2se.CommonServicesImplementation' because the bundle wiring for com.ibm.msg.client.osgi.commonservices.j2se is no longer valid. 
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1521)[org.apache.felix.framework-4.4.1.jar:] 
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)[org.apache.felix.framework-4.4.1.jar:] 
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_141] 
    ... 47 more 
2017-09-29 11:58:11,667 | INFO | AMQ-1-thread-1 | MessageDatabase     | 219 - org.apache.activemq.activemq-osgi - 5.11.0.redhat-630187 | Recovering from the journal @2:16034966 
2017-09-29 11:58:11,675 | INFO | edhat-187/deploy | fileinstall      | 9 - org.apache.felix.fileinstall - 3.5.0 | Started bundle: file:/C:/tools/jboss-fuse-6.3.0.redhat-187/deploy/myTestProj-1.jar 
2017-09-29 11:58:11,676 | INFO | edhat-187/deploy | fileinstall      | 9 - org.apache.felix.fileinstall - 3.5.0 | Started bundle: file:/C:/tools/jboss-fuse-6.3.0.redhat-187/deploy/myTestProj-1.jar 
2017-09-29 11:58:11,680 | INFO | edhat-187/deploy | fileinstall      | 9 - org.apache.felix.fileinstall - 3.5.0 | Started bundle: file:/C:/tools/jboss-fuse-6.3.0.redhat-187/deploy/json-20170516.jar 
2017-09-29 11:58:11,689 | INFO | AMQ-1-thread-1 | MessageDatabase     | 219 - org.apache.activemq.activemq-osgi - 5.11.0.redhat-630187 | Recovery replayed 235 operations from the journal in 0.048 seconds. 
2017-09-29 11:58:11,699 | INFO | AMQ-1-thread-1 | PListStoreImpl     | 219 - org.apache.activemq.activemq-osgi - 5.11.0.redhat-630187 | PListStore:[C:\tools\jboss-fuse-6.3.0.redhat-187\data\amq\amq\tmp_storage] started 
2017-09-29 11:58:11,848 | INFO | AMQ-1-thread-1 | BrokerService     | 219 - org.apache.activemq.activemq-osgi - 5.11.0.redhat-630187 | Apache ActiveMQ 5.11.0.redhat-630187 (amq, ID:AAXA22A747-54051-1506700691718-0:1) is starting 
2017-09-29 11:58:11,933 | INFO | AMQ-1-thread-1 | TransportServerThreadSupport  | 219 - org.apache.activemq.activemq-osgi - 5.11.0.redhat-630187 | Listening for connections at: tcp://127.0.0.1:61616 
2017-09-29 11:58:11,934 | INFO | AMQ-1-thread-1 | TransportConnector    | 219 - org.apache.activemq.activemq-osgi - 5.11.0.redhat-630187 | Connector openwire started 
2017-09-29 11:58:11,934 | INFO | AMQ-1-thread-1 | BrokerService     | 219 - org.apache.activemq.activemq-osgi - 5.11.0.redhat-630187 | Apache ActiveMQ 5.11.0.redhat-630187 (amq, ID:AAXA22A747-54051-1506700691718-0:1) started 
2017-09-29 11:58:11,934 | INFO | AMQ-1-thread-1 | BrokerService     | 219 - org.apache.activemq.activemq-osgi - 5.11.0.redhat-630187 | For help or more information please see: http://activemq.apache.org 
2017-09-29 11:58:11,952 | INFO | AMQ-1-thread-1 | ActiveMQServiceFactory   | 231 - io.fabric8.mq.mq-fabric - 1.2.0.redhat-630187 | Broker amq has started. 

Environnement:

Java 8 jboss-fusible 6.3 .0.redhat-187

Répondre

0

Eh bien apparemment, il est possible d'installer des ressources 3ème partie en utilisant le « envelopper » fonction installer ...

-à-dire,

cela n'a pas fonctionné pour moi (probablement d'un problème de configuration Maven)

osgi:install wrap:mvn:org.json/json/20170516 

ce fait travail pour moi (signalé directement à l'emplacement du fichier)

osgi:install -s wrap:file:C:/tools/json-20170516.jar