immutant

http://immutant.org Note: dev discussion happens in #immutant on FreeNode IRC.
abtv 2016-02-29T09:04:10.000217Z

Hi. Does anyone know how to run some.war file under immutant as well as usual handler?

abtv 2016-02-29T09:05:06.000218Z

I need to run external servlet under the same web server as the main application

abtv 2016-02-29T09:11:40.000219Z

there is the following in docstring (immutant.web/run):

abtv 2016-02-29T09:20:01.000221Z

I'm not sure about the following: handler can be a Ring handler function, a Servlet, or an Undertow HttpHandler.. How to pass some.war file name to immutant?

abtv 2016-02-29T09:55:45.000222Z

I suppose I have to create an instance of my HttpServlet class and I wonder if I can just set path to my *.war file.

2016-02-29T13:27:06.000223Z

@abtv: if you must use the war file, you're going to need an app server like wildfly

abtv 2016-02-29T13:29:47.000224Z

@jcrossley3: I have the main app which is deployed as jar file. I call immutant.web/run function with my handler. Is it possible to make jar file with all batteries included? I have an alternative to run my.war file under any web server separately. The only reason why I wanted to deploy it in the same jar file is simplicity of deployment.

abtv 2016-02-29T13:30:31.000225Z

As I understand I can use either wildfly or any other web server like jetty, right?

abtv 2016-02-29T13:31:05.000226Z

I can also run it from folder (extracted war file)

abtv 2016-02-29T13:31:20.000227Z

Can it help to run it under embedded web server?

2016-02-29T13:32:28.000228Z

you can use anything that can deploy a war file. typically, that's some external process that monitors a directory for war files to deploy. but that's not immutant, which is just a library, a collection of jar files.

2016-02-29T13:33:27.000229Z

you can create an uberjar, but that's just a big fat jar. no web.xml or anything, just a main class.

2016-02-29T13:35:03.000230Z

@abtv: why do you need a war file?

abtv 2016-02-29T13:37:10.000231Z

I have a big project (written in java) I need to integrate it with my main app. Usually the java project it is deployed under jetty. I run my main app as an usual jar file. I'm trying to investigate if it's possible to run the java project in the same way, without a separate web server like jetty @jcrossley3

abtv 2016-02-29T13:38:39.000236Z

docs ^ say that handler can be a Servlet instance (immutant.web/run fn)

2016-02-29T13:40:38.000238Z

yes, it can, but that Servlet is an instance of a Java class.

2016-02-29T13:41:17.000239Z

that's a surprisingly difficult thing to get from a war file :simple_smile:

2016-02-29T13:41:28.000240Z

that feature is mostly used to support Pedestal, btw

abtv 2016-02-29T13:42:32.000241Z

I see, but what if I extract war file to a folder? Could you give me a hint how to run my servlet?

abtv 2016-02-29T13:43:08.000242Z

I've found the following: http://lists.jboss.org/pipermail/undertow-dev/2015-February/001146.html , but haven't tested it yet

abtv 2016-02-29T13:43:14.000243Z

Is it the right way?

2016-02-29T13:44:23.000245Z

war file is just packaging. the behavior of your app is contained in the class/jar files within your war file. if those are available in your local maven repository, then your clojure project can depend on them, too.

abtv 2016-02-29T13:45:45.000246Z

I see. The java project is about 250 Megabytes with hundreds of jar files. I'm not sure it's worth putting all the files on class_path

2016-02-29T13:46:41.000247Z

i strongly doubt it is :simple_smile:

abtv 2016-02-29T13:47:13.000248Z

@jcrossley3: I see. And what do you think about the link: http://lists.jboss.org/pipermail/undertow-dev/2015-February/001146.html ?

abtv 2016-02-29T13:47:46.000249Z

I mean code

2016-02-29T13:48:33.000250Z

that article says exactly what i told you: if you need a war file, you need an app server like wildfly. undertow alone is not enough.

abtv 2016-02-29T13:49:17.000251Z

ah, you mean that it doesn't matter if I use war file or a folder with extracted war file content, right?

2016-02-29T13:49:44.000253Z

no

2016-02-29T13:50:08.000254Z

undertow provides an implementation of the Servlet interfaces

2016-02-29T13:50:19.000255Z

but it has no idea how to parse a web.xml

2016-02-29T13:50:24.000256Z

does that make sense?

abtv 2016-02-29T13:51:03.000257Z

I don't have prior experience with java and java deployments.

abtv 2016-02-29T13:51:21.000258Z

Is there something specific in web.xml?

2016-02-29T13:51:25.000259Z

well, then you, my friend, are screwed! 😄

abtv 2016-02-29T13:53:02.000260Z

As I understand I have to provide some settings to undertow (which is stored in web.xml), right?

2016-02-29T13:54:07.000261Z

imho, you are swimming upstream going that route.

2016-02-29T13:54:17.000262Z

how are you currently deploying your war file?

abtv 2016-02-29T13:54:32.000263Z

I use Jetty, just put war file in webapps folder

abtv 2016-02-29T13:55:15.000265Z

It looks simple enough, but I have to run 2 jar files (the main app and jetty)

2016-02-29T13:56:20.000268Z

do you actually build the war file prior to deploying it?

abtv 2016-02-29T13:57:28.000269Z

I did jar -cvf projectname.war *

abtv 2016-02-29T13:57:59.000271Z

But it doesn't matter, I can use a folder as well

abtv 2016-02-29T13:59:03.000273Z

btw, I use XWiki Enterprise project (I downloaded war file and have made some customizations) - it's my java project

2016-02-29T14:00:11.000275Z

well, i guess i'm asking who created that folder structure. were your customizations made to actual *.class files?

2016-02-29T14:00:29.000276Z

you're not describing a typical course of java development

abtv 2016-02-29T14:01:55.000277Z

I just added a couple of jar files to WEB-INF/lib folder

abtv 2016-02-29T14:02:10.000278Z

all the other things are untouched (I also changed several config files, but as I said I didn't change the folder structure)

2016-02-29T14:04:04.000282Z

well, if you're stuck with a war file, then you need an app server. jetty can operate in two modes: as an app server (to deploy war files) and as an embeddable web server. i'm not sure it's possible (or advisable) for it to do both in the same process.

2016-02-29T14:04:31.000283Z

but undertow is not an app server. just an embeddable web server and Servlet implementation.

abtv 2016-02-29T14:06:15.000284Z

I see, thanks a lot! You spare a lot of time for me :simple_smile:

2016-02-29T14:06:25.000285Z

good luck!