You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by RICHARD DOUST <rd...@mac.com> on 2013/06/10 18:44:04 UTC

Newbie trying to understand how to use some plugins

Hi, 

I'm new to Maven. I'm migrating an EAR that contains 2 war files and an EJB jar file from JBoss 4.2.2 to JBoss AS 7. In the process, I'm moving to Maven, as it seems to manage dependencies quite a lot better than Ant. So far, I've created a multi-module POM with 5 sub-modules. I've gotten past the compilation phase for all of the 5 sub-modules, and am attempting to deploy the EJB jar file to JBoss AS 7. (I'm not sure this will be my final configuration, i.e., one master POM and 5 sub-modules, but it's my first cut.) Anyway, I'm running into issues at deployment time (just starting with the EJB jar as a standalone deployment) because the EJB jar depends on a 3rd party jar that is not available on the server. In 4.2.2 I copied the 3rd party jar to $JBOSS_HOME/server/default/lib. I'd like to avoid that this time, so I'm thinking, much like WAR and EAR files have META-INF/lib directories, a jar file might have something similar. Does this fall outside the definition of a jar? Is there no way to package a 3rd party jar upon which one's code depends with one's jar, so that at runtime the dependencies can be resolved by the classloader?

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


Re: Newbie trying to understand how to use some plugins

Posted by Ron Wheeler <rw...@artifact-software.com>.
Is this a problem that an installer solves in a much more flexible way?

Clearly assembly and shade can do a lot but sometimes it appears that 
linking to an existing installer with a Maven plug-in (izpack for 
example) might do it in a more simple and flexible way and allow a lot 
more pieces to be pulled in.

Ron



On 10/06/2013 1:05 PM, Wayne Fay wrote:
>> Anyway, I'm running into issues at deployment time (just starting with the EJB jar as a
>> standalone deployment) because the EJB jar depends on a 3rd party jar that is not
>> available on the server.
> If you **really** need to make the EJB jar work in standalone
> deployment (which is not especially common IME), you could make this
> work with the shade plugin (or other similar plugins) by packaging the
> contents of your dependencies in alongside your own project files in
> an "uberjar" or "onejar."
>
>> I'd like to avoid that this time, so I'm thinking, much like WAR and EAR files have
>> META-INF/lib directories, a jar file might have something similar. Does this fall outside
>> the definition of a jar? Is there no way to package a 3rd party jar upon which one's code
>> depends with one's jar, so that at runtime the dependencies can be resolved by the
>> classloader?
> The Java Jar file specification does not allow Jar files to contain
> other Jar files so this is not possible (unless you are using a
> special classloader which does not conform to the spec like
> Classworlds).
>
> Instead, you should be using dependencies in your WAR and EAR pom
> files to declare "this project depends on these libraries" and Maven
> will automatically pull those Jar files in and include them in the WAR
> or EAR packages when they are constructed.
>
> Are you sure that you need this EJB jar to work in standalone
> deployment? Or is this just something you're trying for something to
> do, and you will generally deploy the EJB in a WAR/EAR? If the latter,
> I would ignore this "problem" for now and continue working to make the
> WAR/EAR function as you require.
>
> Wayne
>
> ---------------------------------------------------------------------
> 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


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


Re: Newbie trying to understand how to use some plugins

Posted by rdiddly <rd...@mac.com>.
Greg,

When I said that the jar was not on the server, I meant that it's not part
of the JBoss AS 7 deployment, so it's not possible for it to be specified as
"provided". It's in my local repository (because I put it there) and clearly
needs to be packaged with my application. I think I've got it now.

Now I'm dealing with other dependencies not being resolved at deployment.
I'll undoubtedly post more specifics later.

Thanks



--
View this message in context: http://maven.40175.n5.nabble.com/Newbie-trying-to-understand-how-to-use-some-plugins-tp5758923p5759133.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: Newbie trying to understand how to use some plugins

Posted by Greg Trasuk <gr...@webagesolutions.com>.
Re: "Local" access crossing different EAR files:

That isn't Maven related, but I happened to be discussing this with some
folks in my company just this morning.  Basically it's a classloading
issue.  An Enterprise Application (ear file) has its own classloader. 
So the client in ear file B, trying to make a local access to
"com.my.bean.MyBean" in ear file A is actually looking at a completely
different class from the "com.my.bean.MyBean" that is defined in ear
file A, even though the name appears to be the same.  The same byte code
loaded by two different class loaders makes two different classes.

The application server _may_ have a way to define a common library that
spans the two applications  I think Websphere does, but I'm not sure
about JBoss.  The EJB spec allows it but doesn't require it, and makes
clear that such an arrangement is not portable.

So if you put your web and ejb modules in separate enterprise
applications, you most likely need to use the remote interface.  Calls
don't necessarily go out over the network, as the local ORB might
optimize it, but parameters and return values will be serialized, so you
won't have call-by reference semantics.

I wonder, though, if you could repeat the original question?  I recall
something about "the library jar isn't on the server", and I'm not sure
if you meant "it isn't in Maven Central" or something else.

Cheers,

Greg.

On Tue, 2013-06-11 at 11:11, RICHARD DOUST wrote:
> Wayne,
> 
> Thanks for your response.
> 
> I don't really need to make the EJB jar work standalone. I was trying to divide and conquer. In 4.2.2 I deployed the EJB jar as part of an EAR with 2 WARs. I think that I'd like to deploy to JBoss AS 7 with an EAR containing the EJB jar, and two separate wars that use the services of the beans packaged in the EAR. I'm a little concerned though because I read that if I go this route, the web tier will be forced to use the remote interfaces while they currently use local interfaces. Do you know if this is correct?  
> 
> Thanks,
> 
> Richard
> 
> On Jun 10, 2013, at 1:05 PM, Wayne Fay <wa...@gmail.com> wrote:
> 
> >> Anyway, I'm running into issues at deployment time (just starting with the EJB jar as a
> >> standalone deployment) because the EJB jar depends on a 3rd party jar that is not
> >> available on the server.
> > 
> > If you **really** need to make the EJB jar work in standalone
> > deployment (which is not especially common IME), you could make this
> > work with the shade plugin (or other similar plugins) by packaging the
> > contents of your dependencies in alongside your own project files in
> > an "uberjar" or "onejar."
> > 
> >> I'd like to avoid that this time, so I'm thinking, much like WAR and EAR files have
> >> META-INF/lib directories, a jar file might have something similar. Does this fall outside
> >> the definition of a jar? Is there no way to package a 3rd party jar upon which one's code
> >> depends with one's jar, so that at runtime the dependencies can be resolved by the
> >> classloader?
> > 
> > The Java Jar file specification does not allow Jar files to contain
> > other Jar files so this is not possible (unless you are using a
> > special classloader which does not conform to the spec like
> > Classworlds).
> > 
> > Instead, you should be using dependencies in your WAR and EAR pom
> > files to declare "this project depends on these libraries" and Maven
> > will automatically pull those Jar files in and include them in the WAR
> > or EAR packages when they are constructed.
> > 
> > Are you sure that you need this EJB jar to work in standalone
> > deployment? Or is this just something you're trying for something to
> > do, and you will generally deploy the EJB in a WAR/EAR? If the latter,
> > I would ignore this "problem" for now and continue working to make the
> > WAR/EAR function as you require.
> > 
> > Wayne
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
-- 
Greg Trasuk.  
Stream Lead - Open Source Technologies
Ph: 905-315-9509
Cell: 905-921-6464


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


Re: Newbie trying to understand how to use some plugins

Posted by Stephen Coy <st...@resolvesw.com>.
Richard,

When a Java EE server deploys an application EAR, its various components are categorised as modules:
Each EJB jar is a separate module
Each WAR is a separate module - including all of the jars in it's WEB-INF/lib directory
All the jars in the EAR/lib directory are considered as a single module

Each module gets its own class loader. Contrary to popular belief, there is *no* EAR class loader. (Consequently it's not normally possible to read resources from the EAR/META-INF directory, which I've seen many developers attempt).

In the absence of any manifest class path settings, class loading works as follows:
Each EJB jar module has visibility of all classes contained in jars in the EAR/lib directory
EJB jar modules cannot see each other's classes, nor those in WAR modules
Each WAR module has visibility of all classes contained in jars in the EAR/lib directory and all classes in each EJB module (this is optional in the spec, but in practice most app servers support this)
WAR modules cannot see each other's classes

JBossAS/WildFly 7.x relaxes the EJB module visibility rule through default configuration so that EJB modules *can* see each other's classes.
Aside from this, JBossAS/WildFly 7.x/8.x is highly spec compliant when it comes to class loading, which has caused a lot of confusion because spec compliant class loading had to be *enabled* through configuration in older versions of JBossAS.

In addition to the above, the containers provide access to the JavaSE classes and JavaEE classes*. This means that you should *never* deploy these with your application. In maven terms, API jars used to support builds should have a scope of "provided". This is particularly important in WAR modules because (for historical reasons), classes are loaded from a WAR module *first*, whereas everything else is parent first.

* Only WAR modules can see the servlet/jsp/jsf APIs. Some people get caught out by this.

As far as your separate EJB jar is concerned, just build it in to the EAR. Life will be easier! Additionally, package your third party jar in the EAR/lib directory.

Another common mistake is to specify library jars as jar-modules in the EAR. jar-modules are for EJB client jars (intended to be executed standalone) and are very rare in practice.

Hope this helps,

Steve C


On 12/06/2013, at 1:11 AM, RICHARD DOUST <rd...@mac.com> wrote:

> Wayne,
> 
> Thanks for your response.
> 
> I don't really need to make the EJB jar work standalone. I was trying to divide and conquer. In 4.2.2 I deployed the EJB jar as part of an EAR with 2 WARs. I think that I'd like to deploy to JBoss AS 7 with an EAR containing the EJB jar, and two separate wars that use the services of the beans packaged in the EAR. I'm a little concerned though because I read that if I go this route, the web tier will be forced to use the remote interfaces while they currently use local interfaces. Do you know if this is correct?  
> 
> Thanks,
> 
> Richard
> 
> On Jun 10, 2013, at 1:05 PM, Wayne Fay <wa...@gmail.com> wrote:
> 
>>> Anyway, I'm running into issues at deployment time (just starting with the EJB jar as a
>>> standalone deployment) because the EJB jar depends on a 3rd party jar that is not
>>> available on the server.
>> 
>> If you **really** need to make the EJB jar work in standalone
>> deployment (which is not especially common IME), you could make this
>> work with the shade plugin (or other similar plugins) by packaging the
>> contents of your dependencies in alongside your own project files in
>> an "uberjar" or "onejar."
>> 
>>> I'd like to avoid that this time, so I'm thinking, much like WAR and EAR files have
>>> META-INF/lib directories, a jar file might have something similar. Does this fall outside
>>> the definition of a jar? Is there no way to package a 3rd party jar upon which one's code
>>> depends with one's jar, so that at runtime the dependencies can be resolved by the
>>> classloader?
>> 
>> The Java Jar file specification does not allow Jar files to contain
>> other Jar files so this is not possible (unless you are using a
>> special classloader which does not conform to the spec like
>> Classworlds).
>> 
>> Instead, you should be using dependencies in your WAR and EAR pom
>> files to declare "this project depends on these libraries" and Maven
>> will automatically pull those Jar files in and include them in the WAR
>> or EAR packages when they are constructed.
>> 
>> Are you sure that you need this EJB jar to work in standalone
>> deployment? Or is this just something you're trying for something to
>> do, and you will generally deploy the EJB in a WAR/EAR? If the latter,
>> I would ignore this "problem" for now and continue working to make the
>> WAR/EAR function as you require.
>> 
>> Wayne
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


Re: Newbie trying to understand how to use some plugins

Posted by Wayne Fay <wa...@gmail.com>.
> I think that I'd like to deploy to JBoss AS 7 with an EAR containing the EJB jar, and two
> separate wars that use the services of the beans packaged in the EAR. I'm a little
> concerned though because I read that if I go this route, the web tier will be forced to use
> the remote interfaces while they currently use local interfaces. Do you know if this is correct?

This is more of a JBoss-specific J2EE question so you should probably
ask it somewhere that specializes in those discussions. There may be a
JBoss-specific configuration (via jboss.xml or something) that would
allow you to use local interfaces rather than remote, I honestly have
no idea.

Wayne

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


Re: Newbie trying to understand how to use some plugins

Posted by RICHARD DOUST <rd...@mac.com>.
Wayne,

Thanks for your response.

I don't really need to make the EJB jar work standalone. I was trying to divide and conquer. In 4.2.2 I deployed the EJB jar as part of an EAR with 2 WARs. I think that I'd like to deploy to JBoss AS 7 with an EAR containing the EJB jar, and two separate wars that use the services of the beans packaged in the EAR. I'm a little concerned though because I read that if I go this route, the web tier will be forced to use the remote interfaces while they currently use local interfaces. Do you know if this is correct?  

Thanks,

Richard

On Jun 10, 2013, at 1:05 PM, Wayne Fay <wa...@gmail.com> wrote:

>> Anyway, I'm running into issues at deployment time (just starting with the EJB jar as a
>> standalone deployment) because the EJB jar depends on a 3rd party jar that is not
>> available on the server.
> 
> If you **really** need to make the EJB jar work in standalone
> deployment (which is not especially common IME), you could make this
> work with the shade plugin (or other similar plugins) by packaging the
> contents of your dependencies in alongside your own project files in
> an "uberjar" or "onejar."
> 
>> I'd like to avoid that this time, so I'm thinking, much like WAR and EAR files have
>> META-INF/lib directories, a jar file might have something similar. Does this fall outside
>> the definition of a jar? Is there no way to package a 3rd party jar upon which one's code
>> depends with one's jar, so that at runtime the dependencies can be resolved by the
>> classloader?
> 
> The Java Jar file specification does not allow Jar files to contain
> other Jar files so this is not possible (unless you are using a
> special classloader which does not conform to the spec like
> Classworlds).
> 
> Instead, you should be using dependencies in your WAR and EAR pom
> files to declare "this project depends on these libraries" and Maven
> will automatically pull those Jar files in and include them in the WAR
> or EAR packages when they are constructed.
> 
> Are you sure that you need this EJB jar to work in standalone
> deployment? Or is this just something you're trying for something to
> do, and you will generally deploy the EJB in a WAR/EAR? If the latter,
> I would ignore this "problem" for now and continue working to make the
> WAR/EAR function as you require.
> 
> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


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


Re: Newbie trying to understand how to use some plugins

Posted by Wayne Fay <wa...@gmail.com>.
> Anyway, I'm running into issues at deployment time (just starting with the EJB jar as a
> standalone deployment) because the EJB jar depends on a 3rd party jar that is not
> available on the server.

If you **really** need to make the EJB jar work in standalone
deployment (which is not especially common IME), you could make this
work with the shade plugin (or other similar plugins) by packaging the
contents of your dependencies in alongside your own project files in
an "uberjar" or "onejar."

> I'd like to avoid that this time, so I'm thinking, much like WAR and EAR files have
> META-INF/lib directories, a jar file might have something similar. Does this fall outside
> the definition of a jar? Is there no way to package a 3rd party jar upon which one's code
> depends with one's jar, so that at runtime the dependencies can be resolved by the
> classloader?

The Java Jar file specification does not allow Jar files to contain
other Jar files so this is not possible (unless you are using a
special classloader which does not conform to the spec like
Classworlds).

Instead, you should be using dependencies in your WAR and EAR pom
files to declare "this project depends on these libraries" and Maven
will automatically pull those Jar files in and include them in the WAR
or EAR packages when they are constructed.

Are you sure that you need this EJB jar to work in standalone
deployment? Or is this just something you're trying for something to
do, and you will generally deploy the EJB in a WAR/EAR? If the latter,
I would ignore this "problem" for now and continue working to make the
WAR/EAR function as you require.

Wayne

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