You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Eric Stein <st...@locustec.com> on 2012/02/24 13:55:22 UTC

Lookup from WAR to external JAR

Hi,
  I'm trying to set up a WAR project which uses NetBeans Lookup to find
services in external JAR files. Right now, I define an interface in the WAR
and the implementations in a couple of JAR projects. I tried adding a
dependency on the WAR to the JAR poms, but mvn clean package doesn't seem to
like that.

0. Is this the right design, or should I be doing something different?
1. What am I missing that I need to make this work?

Thanks,
Eric

--
View this message in context: http://maven.40175.n5.nabble.com/Lookup-from-WAR-to-external-JAR-tp5512685p5512685.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Lookup from WAR to external JAR

Posted by Ch...@emc.com.

> Hi,
>   I'm trying to set up a WAR project which uses NetBeans Lookup to find
> services in external JAR files. Right now, I define an interface in the WAR and
> the implementations in a couple of JAR projects. I tried adding a dependency
> on the WAR to the JAR poms, but mvn clean package doesn't seem to like
> that.
> 
> 0. Is this the right design, or should I be doing something different?
> 1. What am I missing that I need to make this work?
> 


What do you mean by "doesn't like"?  It sounds like you probably have a circular dependency:  your jars must depend upon the interfaces in the war, but doesn't your war depend upon the jars since they'll probably be built into the web app?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Lookup from WAR to external JAR

Posted by Eric Stein <st...@locustec.com>.
Ron, Chad, Wayne,

  Thanks for your help. I'm still pretty new to J2EE, and I wasn't thinking
about the classloader & WAR files. I adjusted the relevant code to be in its
own JAR file, and it is working swimmingly.

Eric

--
View this message in context: http://maven.40175.n5.nabble.com/Lookup-from-WAR-to-external-JAR-tp5512685p5513143.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Lookup from WAR to external JAR

Posted by Wayne Fay <wa...@gmail.com>.
> PS This doesn't work. Application Servers have special ClassLoaders
> that can handle War files.

I read the beginning of your email again and you mentioned using
Netbeans Lookup. I have no experience with this. For all I know, there
may be a Maven plugin the Netbeans people have produced which will
help with what you are trying to do.

Perhaps ask the Netbeans people for help. Ultimately I don't see this
being the right approach and you should externalize your interfaces to
their own Jar.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Lookup from WAR to external JAR

Posted by Wayne Fay <wa...@gmail.com>.
> services in external JAR files. Right now, I define an interface in the WAR
> and the implementations in a couple of JAR projects. I tried adding a
> dependency on the WAR to the JAR poms, but mvn clean package doesn't seem to
> like that.

Try an experiment for me. Try to use your system's javac to build a
class in one of your Jars which depends on a class in your War, and
specify the War file in the -classpath parameter. Keep in mind this is
what Maven has to do to build your project by calling out to your
system JDK.

PS This doesn't work. Application Servers have special ClassLoaders
that can handle War files.
PPS Extract the code from the War to its own Jar file, and depend on
that in both the War and the other Jars which is what Ron already
said.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Lookup from WAR to external JAR

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 24/02/2012 7:55 AM, Eric Stein wrote:
> Hi,
>    I'm trying to set up a WAR project which uses NetBeans Lookup to find
> services in external JAR files. Right now, I define an interface in the WAR
> and the implementations in a couple of JAR projects. I tried adding a
> dependency on the WAR to the JAR poms, but mvn clean package doesn't seem to
> like that.
>
> 0. Is this the right design, or should I be doing something different?
> 1. What am I missing that I need to make this work?


Not sure why  the interface is defined in the WAR.
Interfraces would usually be in with the implementations or in a JAR by 
itself if the idea is to have each implementation in its own JAR.

WARs are not really places for code most of the time and certainly not 
interfaces.

I like to see a WAR project that only has configuration files and the 
very minimal java required to start whatever is being run.


Ron

> Thanks,
> Eric
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Lookup-from-WAR-to-external-JAR-tp5512685p5512685.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102