Java Module with web facets doesn't get Java classes in war

So I'm having the same problem I had with an earlier 7M release.

I have a java module and it has a web facet and when the war is built it simply doesn't put any of the modules' classes in the war only the dependent classes/jars

Do I have to have a web module in order for this thing to build the war the way I want?

16 comments

As far as I know "Java module" or "web module" don't exist anymore.

There is only 2 types of modules "Plugins modules" and "non plugins modules".
You can attach a web facet to non plugins

0

So why then when I have a Java module (IntelliJ considers it a Java Module) does it not include the classes for that module when building the war?

0
Avatar
Nikolay Chashnikov

Hello Robert,

Please make sure that the Java module is marked as "Copy module output" in
Web Facet settings ("Web Settings" tab, "Modules and libraries to package"
table).

So why then when I have a Java module (IntelliJ considers it a Java
Module) does it not include the classes for that module when building
the war?



0

That applies to dependent modules doesn't it?

ie. the module I'm building doesn't appear in the list. The module that owns the facet itself doesn't appear in the "Modules and Libraries to Package" pane and since it doesn't apply I figured the module itself would default to having it's class files put in the war.

0

When I look at the .iml file for the facet I can see quite clearly that there's
a

]]>

in packaging.

But those classes still don't get put in the war file I'm building.

0

Some additional follow up information... Because we use maven I'm using mvn idea:idea to build the initial .iml file and then using that inside IntelliJ. It's not currently allow me to add anything other than "module" ie. New->module from the Project Settings page. I cannot currently add a facet to a new module I've created.

I know things work correctly if I start from scratch as I've seen the module dependency for the facets owner get put into the dependencies list and the list of dependencies for the war. but for some reason when you start with a project file built using mvn idea:idea ... IntellJ doesn't let you create a new facet for the module or include the facet's owers module's class files in the war.

I was trying to avoid having to manually create all the dependencies for this module by hand but that's not going to be easy it seems.

0

So what I'm saying is that in IDEA 6 you can do a mvn idea:idea at the command line and use that .iml file to create a module and all dependencies will be setup correctly and when you build your web module the output of the facet owning module's classes will be put in the war.

In IDEA 7 when you do the same thing the entry that you'd normally set "copy module output..." etc isn't there for the modules source.

If you create a module from scratch it's there but that means I have to manually setup all the dependencies by hand after you get to that point. So clearly the maven plugin for IDEA isn't completely compatible with what IDEA 7 expects.

0
Avatar
Nikolay Chashnikov

Robert Nicholson wrote:

When I look at the .iml file for the facet I can see quite clearly that there's
a

<containerElement type="module" name="ttlistener">
<attribute name="method" value="1"/>
<attribute name="URI" value="/WEB-INF/classes" />
</containerElement>

in packaging.

But those classes still don't get put in the war file I'm building.


Try clean compiler caches by deleting <idea.system.dir>/compiler.

Anyway please attach your iml- and ipr- files.

0

I tried what you suggested but under Web Settings for the facet it does not show the facet's owning module as a dependency in "modules and libraries to package" and when I build the war those classes are still not being included.

Unfortunately I'm unable to include the .iml file as it's confidential work.

If you have anything you want me to take a look at further I'd be happy to do that.

What I'm seeing is a clear difference b/w 7 and 6 insofar as 6 would always include those classes from the facet owners module.

0

Please try the latest EAP build (7549) and check whether the problem
persists.

I tried what you suggested but under Web Settings for the facet it does not show the facet's owning module as a dependency in "modules and libraries to package" and when I build the war those classes are still not being included.

Unfortunately I'm unable to include the .iml file as it's confidential work.

If you have anything you want me to take a look at further I'd be happy to do that.

What I'm seeing is a clear difference b/w 7 and 6 insofar as 6 would always include those classes from the facet owners module.



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0

Well I just tried 7549 and it still doesn't put the classes in the war or show an explicit dependency when defining what should be copied to the war (In the Modules and Libraries to Package pane). So the behaviour is still different from 6 in that with 6 it doesn't show an explicit dependency when defining what should be copied to the war but that the classes for the module will be included implicitly when the war is built.

So in either case there isn't a line in Modules and Libraries to Package for the owing module's classes and in 6 those classes are implicitly included in the war where as in 7 they aren't.

Again, this is all based on an .iml constructed with the maven idea plugin at the command line.

I've noticed that when I create a new module in v7 it will show the module explicitly as an item to include the war in the Modules and Libraries to Package pane. I just don't understand why the implicit treatment has changed b/w 6 and 7.

Is there anything in the .iml file that would tell IDEA to include the facet's owning module classes in the war when it's built?

0

Looking at this again and it looks like I can hand construct an iml file that will work. Idea 6.0 .iml file generated via mvn idea:idea didn't have modulename as a containerElement under WebModuleProperties but I see in 7 it creates that as the first containerElement under packaging for the facet.

so if you take a file generated by mvn idea:idea it might not necessarily work correctly with Idea 7.

I suspect that this might all be due to a bug or a misunderstanding as to what is necessary in 6 because in Idea 6 it doesn't need to have an explicit containerElement for the webapp's module's source.

0

Ok so, I take it all back and say that in 7.0 (Selena) I simply cannot get it to work correctly.

In "Modules and Libraries to Package" I show

module A copy module output to /WEB-INF/classes
module B copy module output to /WEB-INF/classes
module C copy module output to /WEB-INF/classes

none of these classes end up and there is not WEB-INF/classes folder in the created war.

0

Robert,

I had a similar problem when using mvn idea:idea.

The solution is to run mvn idea:idea --clean so that it deletes and generate your projects ipr file from scratch.

-- Izak

0

Actually I believe I've done that several times but I'll try again and report back findings.

Just exactly why do you believe that would fix things? Is there a bug that was fixed in the maven idea:idea plugin then?

0

Please sign in to leave a comment.