Fork me on GitHub
#immutant
<
2016-02-29
>
abtv09:02:10

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

abtv09:02:06

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

abtv09:02:40

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

abtv09:02:01

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?

abtv09:02:45

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.

jcrossley313:02:06

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

abtv13:02:47

@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.

abtv13:02:31

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

abtv13:02:05

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

abtv13:02:20

Can it help to run it under embedded web server?

jcrossley313:02:28

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.

jcrossley313:02:27

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

jcrossley313:02:03

@abtv: why do you need a war file?

abtv13:02:10

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

abtv13:02:39

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

jcrossley313:02:38

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

jcrossley313:02:17

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

jcrossley313:02:28

that feature is mostly used to support Pedestal, btw

abtv13:02:32

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

abtv13:02:14

Is it the right way?

jcrossley313:02:23

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.

abtv13:02:45

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

jcrossley313:02:41

i strongly doubt it is simple_smile

abtv13:02:46

I mean code

jcrossley313:02:33

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.

abtv13:02:17

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

jcrossley313:02:08

undertow provides an implementation of the Servlet interfaces

jcrossley313:02:19

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

jcrossley313:02:24

does that make sense?

abtv13:02:03

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

abtv13:02:21

Is there something specific in web.xml?

jcrossley313:02:25

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

abtv13:02:02

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

jcrossley313:02:07

imho, you are swimming upstream going that route.

jcrossley313:02:17

how are you currently deploying your war file?

abtv13:02:32

I use Jetty, just put war file in webapps folder

abtv13:02:15

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

jcrossley313:02:20

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

abtv13:02:28

I did jar -cvf projectname.war *

abtv13:02:59

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

abtv13:02:03

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

jcrossley314:02:11

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

jcrossley314:02:29

you're not describing a typical course of java development

abtv14:02:55

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

abtv14:02:10

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

jcrossley314:02:04

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.

jcrossley314:02:31

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

abtv14:02:15

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