immutant

http://immutant.org Note: dev discussion happens in #immutant on FreeNode IRC.
2016-03-14T17:25:51.000002Z

Any tips on creating a WAR from BOOT that will work in wildfly 8.2? Going from the original deps in my POM that creates a working WAR, adding in hoplon front end deps,etc. When deploying it fails on NoClassDefFoundError: org/jboss/modules/Module. I never need this before. I add the dep to build.boot. The new WAR fails, says weld.weldclassintrospector is missing. Any Ides?

2016-03-14T18:15:50.000003Z

@symbit: how are you creating the war? are you using http://github.com/immutant/boot-immutant?

2016-03-14T18:16:51.000005Z

first I heard of it.

2016-03-14T18:17:33.000006Z

Am using the war boot task.

2016-03-14T18:17:45.000007Z

hmm, looks like we don't mention it in the WildFly guide, only lein-immutant: http://immutant.org/documentation/2.1.3/apidoc/guide-wildfly.html#h5392

2016-03-14T18:18:12.000008Z

Immutant-based wars need a little extra sauce in them so Immutant can tie in to WildFly internals

2016-03-14T18:18:31.000011Z

that's what's tripping you up

2016-03-14T18:19:03.000012Z

NPE, or NCFE?

2016-03-14T18:19:04.000013Z

yes

2016-03-14T18:19:09.000014Z

NCDFE, that is

2016-03-14T18:20:08.000015Z

Caused by: java.lang.NullPointerException at org.projectodd.wunderboss.as.CoreServiceActivator.activate(CoreServiceActivator.java:33) at org.jboss.as.server.deployment.service.ServiceActivatorProcessor.deploy(ServiceActivatorProcessor.java:70) [wildfly-server-8 .2.0.Final.jar:8.2.0.Final] at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]

2016-03-14T18:21:23.000016Z

either no module of the identifier is null. I haven't used/need this before when using mvn package and the clojure-maven-plugin

2016-03-14T18:21:46.000017Z

have you built immutant wars with mvn package that worked?

2016-03-14T18:21:54.000019Z

Yes

2016-03-14T18:22:29.000020Z

interesting. are you inserting a jboss-deployment-structure.xml in that war? otherwise, you should see the NCDFE

2016-03-14T18:24:00.000021Z

the NPE likely means the module isn't found, which is probably happening because you are now bundling jboss-modules in the war, so there are two copies of the classes

2016-03-14T18:24:02.000022Z

Yes, that file was created by lein-immutant when using lein.

2016-03-14T18:24:27.000023Z

That and the app.properties hook is also hardcoded.

2016-03-14T18:24:41.000024Z

and your app sees the "local" copy, instead of the one provided by the container, and the local copy can't find the correct module

2016-03-14T18:25:05.000025Z

right, so, any war created by boot needs those same files

2016-03-14T18:25:10.000026Z

which is what boot-immutant will give you

2016-03-14T18:25:27.000027Z

I see.

2016-03-14T18:25:52.000028Z

Is there an example you could share?

2016-03-14T18:26:05.000029Z

of using boot-immutant? sure, one sec

2016-03-14T18:26:10.000030Z

yes

2016-03-14T18:27:34.000031Z

hmm, I don't have an example beyond https://github.com/immutant/boot-immutant/blob/master/test-app/build.boot

2016-03-14T18:28:26.000033Z

the boot.immutant/immutant-war task works similarly to lein immutant war, and the options are doc'ed at: https://github.com/immutant/boot-immutant/blob/master/resources/deployment-guide.md

2016-03-14T18:28:34.000035Z

if you need more, I can work up a sample project

2016-03-14T18:29:00.000036Z

or, better, add a build.boot to our feature-demo

2016-03-14T18:29:57.000037Z

I'm not sure I follow the example

2016-03-14T18:30:51.000038Z

I'd expect a deftask like create-war that calls you boot-war task or something like that.

2016-03-14T18:31:07.000039Z

I'll add that, one sec

2016-03-14T18:31:40.000040Z

that test-app was there for me to manually confirm behavior via boot immutant-war on the command-line

2016-03-14T18:32:18.000041Z

actually, I'll add a build.boot to the feature-demo now, that will be more useful/comprehensive I think

2016-03-14T18:33:39.000042Z

Thanks you! I see the guide and options nowt too..

2016-03-14T18:35:31.000044Z

I'm looking to integrate this task above..

2016-03-14T18:35:58.000045Z

see if replacing (war) with (boot.immutant/immutant-war) (after adding [boot-immutant "0.5.0" :scope "test"] as a dep) works

2016-03-14T18:36:30.000046Z

ok, just a sec.

2016-03-14T18:38:33.000047Z

note that boot-immutant calls the uber task for you, but really should expect the uberjar to be in the fileset

2016-03-14T18:38:43.000048Z

so you may see the uberjar created twice

2016-03-14T18:39:50.000050Z

I'm assuming I should remove/rename my statif files webapp/app.properties and WEB-INF/jboss-deployment-structure.xml andjboss-web.xml ?

2016-03-14T18:40:17.000051Z

correct, you won't need those

2016-03-14T18:40:44.000052Z

but /me wonders why it failed before if you had those in the war generated by (war)

2016-03-14T18:41:04.000053Z

maybe they weren't ending up in the correct place

2016-03-14T18:42:21.000054Z

is the war task built-in?

2016-03-14T18:42:40.000055Z

ah, so it is

2016-03-14T18:44:01.000056Z

added [boot-immutant "0.5.0" :scope "test"] to my deps. not requiring since it has the full path.., but getting ClassNotFoundException on boot.immutant

2016-03-14T18:46:30.000058Z

changed to require :as i that worked.

2016-03-14T18:47:09.000059Z

It looks like boot doesn't like full package.

2016-03-14T18:47:20.000060Z

I'm getting a FNFE with my test-app now, so it may be that I haven't kept up with boot itself

2016-03-14T18:47:26.000061Z

related to the uberjar

2016-03-14T18:47:28.000062Z

'[boot.immutant :as i]

2016-03-14T18:47:29.000063Z

(i/immutant-war)

2016-03-14T18:48:31.000064Z

They're on 2.5.2 One new thing is there is an explicit target task you need to use.

2016-03-14T18:48:37.000065Z

sorry 2.5.5

2016-03-14T18:49:54.000066Z

is it working for you at all?

2016-03-14T18:50:17.000067Z

I'm looking at what it would take to use the uberjar in the fileset instead of creating one

2016-03-14T18:59:03.000069Z

yeah, that's what I'm getting as well

2016-03-14T18:59:19.000070Z

let me see if I can fix it and cut you a new plugin release quickly

2016-03-14T19:00:28.000071Z

Ok. Thank you!! (I was supposed to release last Friday, so this is a huge help!!)

2016-03-14T19:15:47.000073Z

right, it currently calls uber no matter what, and expects the result to be in target/, unfortunately

2016-03-14T19:22:51.000074Z

oh ok. np. Sound like you're on it..

2016-03-14T20:09:13.000076Z

How's it going? Let me know if you need any help.

2016-03-14T20:14:57.000077Z

sorry, trying to juggle a couple of things. right now, I can't seem to find any jars in the fileset after calling uber

2016-03-14T20:15:09.000078Z

@symbit: ^

2016-03-14T20:16:14.000079Z

did you add the new target task?

2016-03-14T20:16:22.000080Z

new this release

2016-03-14T20:16:34.000081Z

ah, I probably need uber -> jar -> immutant-war

2016-03-14T20:16:44.000082Z

otherwise nothing is written.

2016-03-14T20:16:45.000083Z

I'm looking in the fileset for it currently

2016-03-14T20:20:26.000084Z

(comp (hoplon) (cljs :optimizations :advanced) (aot) (pom) (web) (i/immutant-war) (target))

2016-03-14T20:21:01.000085Z

does that work for you?

2016-03-14T20:21:30.000086Z

if so, that may be a workaround until I improve the plugin to not uber itself

2016-03-14T20:21:58.000087Z

Adding target actually writes to the target directory, otherwise it goes through all steps, but does write anything at all.

2016-03-14T20:22:18.000088Z

and that doesn't throw an exception for you?

2016-03-14T20:22:25.000089Z

doesn't write anything..

2016-03-14T20:22:31.000090Z

oh

2016-03-14T20:23:00.000091Z

ok, let me see if I can give you a hack that works for today as a SNAPSHOT, and try to fix it for real after

2016-03-14T20:23:14.000092Z

since you're against a deadline

2016-03-14T20:24:13.000093Z

let me try again.. I didn't check the target directory with all the exceptions..

2016-03-14T20:24:57.000094Z

if you get exceptions, it's likely you don't have a valid war, since the war task calls uber w/o calling target, then looks for the jar in target/ for the war

2016-03-14T20:26:15.000095Z

That makes sense.

2016-03-14T20:29:30.000096Z

The only thing written the target dir are the 3 config files. web.xml,jboss-web.xml and jboss-deplyment-structure.xml I think those are written by a different task.

2016-03-14T20:30:37.000097Z

If I replace (i/immutant-war) with (war) the target dir has a war file, yes.

2016-03-14T20:30:55.000098Z

those probably get put in the fileset by the immutant plugin before it tries to build the war

2016-03-14T20:31:18.000099Z

yup

2016-03-14T20:31:21.000100Z

I just pushed a snapshot - can you try "0.6.0-SNAPSHOT" and see if it works for you?

2016-03-14T20:31:47.000101Z

see if it works with the task chain you posted here last

2016-03-14T20:32:15.000102Z

this one, to be exact: https://clojurians.slack.com/archives/immutant/p1457986826000084

2016-03-14T20:32:58.000104Z

Thank you @tcrawley ! Running now...

2016-03-14T20:35:44.000105Z

if it runs without exception, but you have no war output in target/, remove the (target) call from the end of the chain, since I think it cleans by default

2016-03-14T20:36:04.000106Z

the immutant task breaks the rules and writes to target/ directly instead of to the fileset

2016-03-14T20:36:10.000107Z

that's one of the things I need to fix

2016-03-14T20:43:28.000109Z

it got farther. Wrote to the target dir, created a war in the wildfly dir. Then exception.

2016-03-14T20:43:38.000110Z

what's the exception?

2016-03-14T20:43:57.000111Z

editing..

2016-03-14T20:47:50.000113Z

what if you get rid of the final (target) call? do you still get an exception?

2016-03-14T20:48:00.000114Z

and does the generated war work for you in WildFly?

2016-03-14T20:48:47.000115Z

I tried the generated war. It's missing the application code.

2016-03-14T20:49:22.000116Z

FileNotFoundException: Could not locate my_project/service/core__init.class

2016-03-14T20:49:40.000117Z

trying without (target) task

2016-03-14T20:50:22.000118Z

ah, can you try adding (set-env! :resource-paths #{"src"}) as well? (using whatever path you have for the source there)

2016-03-14T20:52:22.000119Z

added

2016-03-14T20:52:24.000120Z

:resource-paths #{"src/main/clojure" "......." "......."} :source-paths #{"src/main/clojure"})

2016-03-14T20:52:33.000121Z

trying without (target)..

2016-03-14T20:57:57.000122Z

no exc on build!

2016-03-14T21:00:51.000123Z

found the code, started the immutant cache, but exc

2016-03-14T21:01:12.000124Z

clojure.lang.ArityException: Wrong number of args (0) passed to: not -modified/wrap-not-modified/fn--11837

2016-03-14T21:03:17.000125Z

does this app run outside of WildFly?

2016-03-14T21:03:29.000126Z

and can you gist the full trace?

2016-03-14T21:03:47.000127Z

i think I have to scope a few things out.

2016-03-14T21:04:11.000130Z

yes, I can run it with boot dev

2016-03-14T21:04:33.000131Z

if you're using boot-http, you're not using Immutant's web bits

2016-03-14T21:05:13.000132Z

For dev I'm using that..

2016-03-14T21:05:16.000133Z

and inside the container, you may be trying to start up http-kit instead of using the container's web server

2016-03-14T21:05:33.000134Z

are you calling immutant.web/run anywhere?

2016-03-14T21:06:02.000135Z

yes

2016-03-14T21:06:08.000136Z

(run handler)

2016-03-14T21:06:22.000137Z

is the line you linked to in the stack trace?

2016-03-14T21:06:56.000138Z

what does the (web) task do?

2016-03-14T21:06:58.000139Z

nope

2016-03-14T21:07:35.000140Z

It looks like boot-http is getting called. I should be able to add :scope "test"

2016-03-14T21:07:45.000141Z

ah, cool

2016-03-14T21:08:36.000142Z

Is there an app.properties hook that calls the clojure "main" functions?

2016-03-14T21:09:31.000143Z

When I created the 3 files 1 year ago with lein-immutant that was the hook to call into the client app.

2016-03-14T21:10:10.000144Z

there is an entry in app.properties that calls your init fn that you specify with :init-fn 'your.app/main

2016-03-14T21:10:19.000145Z

Does it make sense that the boot-http was called first?

2016-03-14T21:10:39.000146Z

so you'll need to pass that to the immutant-war task to have it called

2016-03-14T21:10:55.000147Z

yes, I have that..

2016-03-14T21:14:41.000148Z

building again with [pandeiro/boot-http "0.7.0" :scope "test"]

2016-03-14T21:15:09.000149Z

k - I don't know enough about boot-http to know why it would be called

2016-03-14T21:20:34.000150Z

:scope "test" didn't have any effect.

2016-03-14T21:21:24.000151Z

are you sure it is being called? can you share the stack trace you get in WildFly?

2016-03-14T21:23:43.000152Z

yes..

2016-03-14T21:28:14.000154Z

given that stack, it looks like something that is triggered in your init-fn. are you calling wrap-not-modified directly in your code?

2016-03-14T21:31:35.000155Z

nothing direct.

2016-03-14T21:31:57.000156Z

Also, I don't see my app in the stack trace.

2016-03-14T21:32:09.000157Z

wrap-params from ring

2016-03-14T21:32:15.000158Z

is there a further cause in the stack trace?

2016-03-14T21:32:26.000159Z

what version of immutant are you using?

2016-03-14T21:32:33.000160Z

ring.middleware.defaults/wrap-defaults

2016-03-14T21:32:41.000161Z

nope that was the whole trace.

2016-03-14T21:33:33.000162Z

2.1.2

2016-03-14T21:35:02.000163Z

https://github.com/immutant/immutant/blob/2.1.2/wildfly/src/immutant/wildfly.clj#L90 is the last non-clojure line in that stack, which is what makes me think it's an issue somewhere in your init-fn

2016-03-14T21:35:27.000165Z

it may be a version mismatch between the ring you bring in and the one immutant depends on, maybe

2016-03-14T21:41:44.000166Z

ugh, I just realized, my init-fn is pointing to the def handler and not the function where (run/handler is defined. Small difference between running dev in lein/jetty and prod in wildfly

2016-03-14T21:41:58.000167Z

let me try pointing to the other function..

2016-03-14T22:00:40.000168Z

@tcrawley: Yup that was the last piece of the puzzle. Thank you for all your time. Let me know if you need me to test anything..

2016-03-14T22:01:54.000169Z

good to hear! I'll try to fix up the boot-immutant task a bit more, and release a 0.6.0. I'll let you know when I have something ready to test there