I am having some good success with BWF.
I am looking for an example or verification if possible to do this:
- hollowed bootable image
- had a jboss/wf module slipped stream 'into' it
- can take CLI commands during image bake or assembly step
For now, CLI commands whith changes persisted in the server configuration can only be executed during Bootable JAR packaging.
You can run CLI commands against a running Bootable JAR, any
change will be lost at shutdown time.
- remain as a hollowed bootable so I can iterate over my target deploy w/o reassembly each build.
Is this possible?
TIA,
Fred
--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/CAGO%3D3NYDvVs7YnpFA%2BxwjFe_kfryJuHhoNww8KXcTuAzR55dRQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/1a2beddf-2e69-a8c6-6d21-a31233e804e3%40redhat.com.
Wow thanks for the help. Let me add a bit of color to my use case that I left out.
- Yeah, I'd love docker for this -- my organization isn't there yet..sigh, baby steps, baby steps...
- So we have lots of MDBs that are being broken out into singleton worker BWF instances. They are all the same structurally: listen to an external AMQ 5x broker via RAR, and then process. Some post messages back to AMQ via an RAR admin object; some don't. Most use an oracle DB. The only thing different about each MDB is the processing they do -- i.e. the MDB.ear.
- FWIW: most of my config in CLI are props driven; BWF images are started with properties via --properties=somefile.properties.
- We are a gradle shop and, for these projects, we only use maven for assembling the BWF image; ear/war/etc are built by gradle. The dev-mode thing may or may not work for my case; may try to see how that could work; but it does miss a point: that if I had a BWF image with the RAR in place, and properties driven config in said BWF image; then MDB development becomes: make an EAR, make an props file, use a curated BWF artifact (and not rebuild that over and again).
I was browsing the samples here: https://github.com/wildfly-extras/wildfly-jar-maven-plugin/tree/3.0.0.Final/examples and was hoping for an example that installed a custom module archive during assembly, but can still be hollow. I actually don't' see an example of installing a custom module (hollow or not) -- I could have missed it.
We don't have such example, but we have some that can help you. You can look at https://github.com/wildfly-extras/wildfly-jar-maven-plugin/tree/master/examples/https that copies a keystore (look at the extra-content dir).
Create a directory for your module inside the extra-content dir: eg: extra-content/modules/org/foo/bar/main Add module.xml and artifact to it. Reference this extra-content dir ad done there: https://github.com/wildfly-extras/wildfly-jar-maven-plugin/blob/master/examples/https/pom.xml#L50
Hope that helps.
JF
On 3/1/21 4:21 PM, Fred Welland wrote:
Finally got around to trying this. Using normal WF22, I proto-typed the module and that seemed to work. NOTE: I used jboss-cli to create the resource-adapter, using 'module' rather than 'archive'.
I took that directory and used the extra-content dir stuff and manipulated my directories while building the bootable so that the bootable.jar:wildfly.zip has a folder that is the same as what I used for WF22. (NOTE: the resulting module folder in zip is wildfly.zip:/modules/system/layers/base/org/apache/amq-rar inside that folder is 'main' containing module.xml and jar artifacts, etc).
Tweaked my CLI for bootable to define resource-adpate using module rather than archive (same syntax as used for WF22) and built a bootable. Essentially, I changed
/subsystem=resource-adapters/resource-adapter=AMQBroker:add(archve=activemq-rar.rar)to/subsystem=resource-adapters/resource-adapter=AMQBroker:add(module=org.apache.amq-rar )
The rest of my BWF cli was the same as the working version (using RAR that is just deployed via 'deploy') .
The bootable built, seemingly OK. It "runs"; BUT on bootup -- the RA complains about fail to load module (in my case 'org.apache.amq-rar'). Of course, the rest of BWF image spews failures based on missing RA, etc etc etc.
If you could share your startup output, could be a missing dependency? You could check that target/bootable-jar/wildfly/bin/standalone.sh starts properly (and that this installation contains the rar module)?
WooHoo! You fixed it!
Your comment made me go back and look at the error more closely. After a few tries, I fixed it. But my fix does raise a question or two.
For starters, the problem was the module was loading but it had a declared dependency that couldn't be found or loaded. Said dependency was 'javax.management.j2ee.api'
Adding "<layer>management</layer> " didn't affect this and then I recall seeing deps in the module.xml I had 'authored'. "Authored" here means I stole it off some post off of the interwebbies and, I am ashamed to admit it, but do not fully know everything the sample module.xml does.
All I did was comment out the <module /> from the <dependencies /> section of module.xml. Rebuild the bootable; and that problem went away.....
...and basically it works! I am now running my app via:
java -jar bootable.jar --deployment=myMdb.ear --properties myproperties.props
Much better!
Now onto some questions (maybe not totally BWF, modules are new-ish to me, but this is a WF list...) :
- I unraveled my RAR to make the module. Is there a way to reference the rar file as a resource-root w/o unraveling and using <resource-root path="..."/> and pointing to all bits from the rar file. OR ...
- ....is there a cli "module add" switch or something that can take the rar as a 'resource-archive' and then also take --name and --dependencies (and other needed things), so I don't have to curate a modules directory?
You can do: module add --name=org.apache.amq --dependencies=javax.management.j2ee.api,<all other dependencies> --resources=<rar file>
A new module will be created in <wildfly home>/modules
directory.
- How does one 'know' what a RAR's dependencies are? (so I know what to correctly put in the module.xml's <dependencies /> section?
- What layer would have provided 'javax.management.j2ee.api' any way?
If wildfly was defining a jsr77 layer, this is the one that would bring it I guess. Its module.xml has a required dependency on it.
You can explicitly add a package when building a bootable JAR:
<feature-pack>
<location>wildfly@maven(org.jboss.universe:community-universe)#23.0.0.Beta1</location>
<included-packages>
<package>javax.management.j2ee.api</package>
</included-packages>
</feature-pack>
5. feels strange to me as the MDB detection is the same and APIs are injected in the deployment. If you could reproduce or provide areproducer I would love to 'fix' that.Emmanuel