dependencies across modules

hi all.

I have a CRITICAL dependency problems that's stopping me from fully using v4.0! IDEA does not allow circular dependencies between modules. And I can appriciate why it would do this. BUT, this has the nasty side effect of not allowing me to work with a J2EE project that have modules with circular dependencies.

You can say all you want about this not being good practice...

This is the current states of some of the projects i have to work on, and because of this, much of IDEA power is crippled: I can't do any reliable usage searches, some objects used across modules cannot be found.

I just think there should be a way to model this situation since we do manage to build and run the app on an appserver even though we have circular dependencies. Possibly there should be a project level flag that allows all classpath to be merged.

Is any body else affected by this? Are ther any reliable work arounds?

Florian HEHLEN

13 comments

Florian Hehlen wrote:

hi all.

I have a CRITICAL dependency problems that's stopping me from fully using v4.0! IDEA does not allow circular dependencies between modules. And I can appriciate why it would do this. BUT, this has the nasty side effect of not allowing me to work with a J2EE project that have modules with circular dependencies.

You can say all you want about this not being good practice...

This is the current states of some of the projects i have to work on, and because of this, much of IDEA power is crippled: I can't do any reliable usage searches, some objects used across modules cannot be found.

I just think there should be a way to model this situation since we do manage to build and run the app on an appserver even though we have circular dependencies. Possibly there should be a project level flag that allows all classpath to be merged.

Is any body else affected by this? Are ther any reliable work arounds?

Florian HEHLEN


Maybe the problem is in your module setup. Can you explain what the
structure of your directories are, and where the module markers are, and
where the dependecies lie? Without that I personally can't tell you how
to get around it. I used to get circular dependancies when I first
started with modules in idea, but then figured out how to properly setup
modules which avoided the whole issue.

R

0

ok here we go.

-Each module represents a completely seperate directory structure in which deployment files, compiled code, and source is stored:

-My project contains ejb, web, and plain java modules.
-Each uses seperate output directories(*.class).
-I do not use an enterprise app module. I used to, but it created even more dependency problems.

that's about it for how things are configured

Florian

0

Hello Florian,

is there anything that prevents you from making both src dirs into one Java module? So you would have 2 content roots for the java module with the src dirs in there. Then the module just depends on itself for src, and everything else can have a dependancy on the java module.

R

FH> ok here we go.
FH>
FH> -Each module represents a completely seperate directory structure in
FH> which deployment files, compiled code, and source is stored:
FH> ejbmodule/ FH> classes/ FH> src/ FH> META-INF/ FH> ejb-jar.xml FH> com/ FH> etc/ FH> webmodule/ FH> src/ FH> com/ FH> etc/ FH> webApp/ FH> WEB-INF/ FH> classes/ FH> web.xml FH> ]]>
FH> -My project contains ejb, web, and plain java modules.
FH> -Each uses seperate output directories(*.class).
FH> -I do not use an enterprise app module. I used to, but it created
FH> even more dependency problems.
FH> that's about it for how things are configured
FH>
FH> Florian
FH>

-- Posted by JetBrains OmniaMea

0

hi.

is there anything that prevents you from making both
src dirs into one Java module? So you would have 2


well... I could do that but then I lose all the ejb intellijence that IDEa provides... like ejb intentions, remote interface/home/bean dependencies. This is because as far as i can tell an ejb module can only have 1 ejb-jar.xml config file.

Florian

0

Hello Florian,

FH> hi.
FH>
>> is there anything that prevents you from making both src dirs into
>> one Java module? So you would have 2
>>
FH> well... I could do that but then I lose all the ejb intellijence
FH> that IDEa provides... like ejb intentions, remote
FH> interface/home/bean dependencies. This is because as far as i can
FH> tell an ejb module can only have 1 ejb-jar.xml config file.

Ok another solution, a bit funky though.

Make a module with your ejb-jar.xml in it (with other relevant files too of course), create 2 modules for each of the src dirs, and make the module which contains ejb-jar.xml depend on the 2 other modules with the src dirs.

That's a little ugly, though it might be nice since you have specific modules for sources which you can quickly switch around if you need to, and it might be a workaround to getting you to work in I4. That wouldn't cause a circular dependency.

I tend to think of modules like Java's single inheritance model :) Make one module and extend it, if you need to have multiple inheritance, you make an intermediary class which extends the main module and you extend that if you have to.

R
-- Posted by JetBrains OmniaMea

0

Robert S. Sfeir wrote:

Hello Florian,

FH> hi.
FH>

>>>is there anything that prevents you from making both src dirs into
>>>one Java module? So you would have 2
>>>


FH> well... I could do that but then I lose all the ejb intellijence
FH> that IDEa provides... like ejb intentions, remote
FH> interface/home/bean dependencies. This is because as far as i can
FH> tell an ejb module can only have 1 ejb-jar.xml config file.

Ok another solution, a bit funky though.

Make a module with your ejb-jar.xml in it (with other relevant files too of course), create 2 modules for each of the src dirs, and make the module which contains ejb-jar.xml depend on the 2 other modules with the src dirs.

That's a little ugly, though it might be nice since you have specific modules for sources which you can quickly switch around if you need to, and it might be a workaround to getting you to work in I4. That wouldn't cause a circular dependency.

I tend to think of modules like Java's single inheritance model :) Make one module and extend it, if you need to have multiple inheritance, you make an intermediary class which extends the main module and you extend that if you have to.


That was supposed to be you make an interface which classes implement.
So in your case the 'Interface' module is the one with the EJB in it.
The impls are the modules with the src dirs, and they all implement the
interface.

R

0

Ok, I have a setup somewhat like this, and the part that's messing you up the Java module. You only really need the EJB and Web Modules. Each of those modules types can have a Java source directory. I then make my Web module depend on my EJB module. It sounds like you also need the EJB module to depend on the Web module, but I haven't tried that yet as our EJB source doesn't need anything from the web app.

Patrick

0

the dir structure above was just an example. I am dealing here with many ejb modules. And the circular dependency is between the ejb modules.

Florian

0

hi.

Make a module with your ejb-jar.xml in it (with other
relevant files too of course), create 2 modules for
each of the src dirs, and make the module which
contains ejb-jar.xml depend on the 2 other modules
with the src dirs.


actually... I am not following you here.... can you flesh this out a bit more?

Florian

0

Florian Hehlen wrote:

ok here we go.

-Each module represents a completely seperate directory structure in which deployment files, compiled code, and source is stored:

ejbmodule/
classes/
src/ <-- Module A
META-INF/
ejb-jar.xml <-- EJB Module (Depends on Java Module A and B)
com/
etc/
webmodule/
src/ <-- Module B
com/
etc/
webApp/
WEB-INF/
classes/
web.xml

0

Hello, I have also similar problem.

The directory structure that was stored in the CVS for our project is.
webapp\war\
- jsp and other misc files
src\com\web
- Struts Form and Struts Action
src\com\common
- Data Transfer Objects, Data Transfer Utility
src\com\ejb
- EJB interface, home, implementation

At first, I was using a single content root (source folder) for my Idea project.
However, I want to use Idea's J2EE feature.

This is what I did:
1)
?Web Module
Content Roots:
- webapp\war\
- src\com\web
- src\com\common

?Ejb Module
Content Roots:
- src\com\ejb

Dependency:
?Web Module depends on Ejb Module.
- Struts Action calls the Data Transfer Utility to transfer values from StrutsForm to DTO and vice-versa.
Then calls EJB interface passing Data Transfer Objects as parameter.

?Ejb Module depends on Web Module.
- EJB uses Data Transfer Objects as parameter.

*Obviously, there is a cyclic dependency between Web Module and Ejb Module.

I also tried to separate src\com\common into a Java module.
This is how my project now looks like:

2)
?Web Module
Content Roots:
- webapp\war\
- src\com\web

?Java Module
- src\com\common

?Ejb Module
Content Roots:
- src\com\ejb

Dependency:
?Web Module depends on Java Module.
- Struts Action calls the Data Transfer Utility to transfer values from StrutsForm to DTO and vice-versa.

?Java Module depends on Web Module
- Data Transfer Utility accepts StrutsForm as a parameter (transfer from StrutsForm to DTO vice-versa)

?Web Module depends on Ejb Module.
- Struts Action calls EJB interface passing Data Transfer Objects as parameter.

?Ejb Module depends on Java Module. (no longer depends on Web Module)
- EJB uses Data Transfer Objects as parameter.

*Now, there is a cyclic dependency between Web Module and Java Module.

Is there another way on how to setup an EJB module for this type of directory structure?
This structure is patterned to MVC framework.

Thank you very much!

0

Sounds to me like your Data Transfer Utility needs to be moved to src\com\web. Stuff in src\com\common should probably not have any dependancies on a web application framework.
If you do that, your 3 module setup should work.

0

Thank you very much for the reply.
Yes you are correct, stuff in src\com\common should probably not have any dependencies on a web application framework, however I could not change the directory structure that was saved in the CVS server.
I guess, I'll be back on my old Idea project (web module only, no ejb module).
I hope that there would be other solution for this wherein, the directory structure would not be adjusted, rather the settings in Idea should be adjusted.

0

Please sign in to leave a comment.