what's the best way to use the jboss-client.ja

2020-04-29 16:27发布

问题:

I have a Wildfly 10 ear application (runs in the server container) which needs to be able to publish to a remote queue hosted on another wildfly server. To accomplish that I copied this jar from the wildfly\bin\client folder into the ear's lib folder. That worked fine.

But now, after official packaging, when i start Wildfly and the application, I get an error message... something about the manifest file of this jar.

What's the best way to set up the apllication so that this jar is found by the various class loaders?
it seems the jar could be copied to the ear\lib, but something needs to be done about the manifest file? what?
i assume Another option is to specify something in the standalone-full.xml that tells the wildfly class loader to include the wildfly/bin/client folder in its classpath. How do you that? And thirdly, i assume the file can just be copy-pasted into a folder that is already in wildfly classpath.
A forth option, i assume is to add something to my ear producing pom.xml which will add this jar to the ear/lib....

What's the best way to do this?

the errors i'm getting is:

  14:54:45,578 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."InSyncEar.ear".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."InSyncEar.ear".STRUCTURE: WFLYSRV0153: Failed to process phase STRUCTURE of deployment "InSyncEar.ear"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
 Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYSRV0161: Failed to get manifest for deployment "/C:/MyComp/Purch/deployments/InSyncEar.ear/lib/jboss-client.jar"
    at org.jboss.as.server.deployment.module.ManifestAttachmentProcessor.getManifest(ManifestAttachmentProcessor.java:78)
    at org.jboss.as.server.deployment.module.ManifestAttachmentProcessor.deploy(ManifestAttachmentProcessor.java:65)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
    ... 5 more
 Caused by: java.util.zip.ZipException: invalid literal/lengths set
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:122)
    at org.jboss.vfs.util.PaddedManifestStream.read(PaddedManifestStream.java:39)
    at java.io.InputStream.read(InputStream.java:170)
    at java.util.jar.Manifest$FastInputStream.fill(Manifest.java:441)
    at java.util.jar.Manifest$FastInputStream.readLine(Manifest.java:375)
    at java.util.jar.Manifest$FastInputStream.readLine(Manifest.java:409)
    at java.util.jar.Attributes.read(Attributes.java:376)
    at java.util.jar.Manifest.read(Manifest.java:199)
    at java.util.jar.Manifest.<init>(Manifest.java:69)
    at org.jboss.vfs.VFSUtils.readManifest(VFSUtils.java:243)
    at org.jboss.vfs.VFSUtils.getManifest(VFSUtils.java:227)
    at org.jboss.as.server.deployment.module.ManifestAttachmentProcessor.getManifest(ManifestAttachmentProcessor.java

回答1:

Once your JMS client is running within a WildFly application - you don't need for the the jboss-client.jar at all - WildFly modules by themselves contain all necessary dependencies for publishing to a remote queue on another WildFly instance.

In our projects the best way for remote EJB and JMS connections is the following config in the standalone-full.xml:

<subsystem xmlns="urn:jboss:domain:ee:4.0">
            <global-modules>
                <module name="org.jboss.remote-naming"/>
            </global-modules>
...

This allows to lookup for a remote JMS connection on another server through the jms/RemoteConnectionFactory there, e.g. see this example.

Additionally you need the ActiveMQ specific dependencies (e.g. ActiveMQJMSConnectionFactory) to publish to a remote queue.
We did it by adding the corresponding module as a dependency in the jboss-deployment-structure.xml:

<dependencies>
      <module name="org.apache.activemq.artemis" export="true"/>
</dependencies>

see Class Loading in WildFly for more details.

That's it.