[mvn-intg] maven-from-source : An issue when invoking mvn

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[mvn-intg] maven-from-source : An issue when invoking mvn

Kasun Gajasinghe
Hi,
After bumping more than 50 ebuilds, we were finally able to bump maven
package itself. But there's few issues to get over with.

Following error occurs when mvn-2.2 is invoked. As you probably
already know, maven uses classworlds-1.1 for class loading. Further,
upstream uses uberjar, which packages all the dependencies together.
We have circumvented the need for having an uberjar by creating
symlinks of needed jars under the directory /usr/share/maven-2.2/lib/.

As I see, it fails before getting in to maven through classworlds.
Unfortunately, I haven't have much experience with of classworlds
behaves. Does anyone of you have any idea to get rid of this error?
This _may_ not be an issue of maven having an incorrect classpath.

 If this is through, we'll be much closer to getting maven from source working.

$ mvn-2.2 -X
+ Error stacktraces are turned on.
Apache Maven 2.2.1 (r1135082; 2011-06-26 09:41:29+0530)
Java version: 1.6.0_25
Java home: /opt/sun-jdk-1.6.0.25/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux" version: "2.6.36-gentoo-r8" arch: "i386" Family: "unix"
org.codehaus.classworlds.NoSuchRealmException: plexus.core
        at org.codehaus.classworlds.ClassWorld.getRealm(ClassWorld.java:128)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:434)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)


Maven is called via classworlds with the command:
       "${JAVACMD}" \
       $MAVEN_OPTS \
       -classpath $(java-config -p classworlds-1.1) \
       -Dclassworlds.conf=/usr/share/maven-2/maven_home/bin/m2.conf \  #the m2.
       -Dmaven.home=/usr/share/maven-2.2 \
       -Dmaven.repo.remote=${HOME}/.m2/repository \
       -Dmaven.repo.local=${HOME}/.m2/repository  \
       ${CLASSWORLDS_LAUNCHER} \
       ${@}

(The full script:
http://overlays.gentoo.org/proj/java/browser/gsoc-maven-overlay/dev-java/maven/files/2.2.1/bin/mvn)

And, m2.conf file looks like this:
=======
main is org.apache.maven.cli.compat.CompatibleMain from plexus.core

set maven.home default ${user.home}/m2

[plexus.core]
load ${maven.home}/lib/*.jar
========

Let me know if any more information is needed

Thanks,
--Kasun

--
~~~*******'''''''''''''*******~~~
Kasun Gajasinghe,
University of Moratuwa,
Sri Lanka.
Blog: http://blog.kasunbg.org
Twitter: http://twitter.com/kasunbg

Reply | Threaded
Open this post in threaded view
|

Re: [mvn-intg] maven-from-source : An issue when invoking mvn

Jörg Schaible-2
Hi Kasun,

Kasun Gajasinghe wrote:

> Hi,
> After bumping more than 50 ebuilds, we were finally able to bump maven
> package itself. But there's few issues to get over with.
>
> Following error occurs when mvn-2.2 is invoked. As you probably
> already know, maven uses classworlds-1.1 for class loading. Further,
> upstream uses uberjar, which packages all the dependencies together.
> We have circumvented the need for having an uberjar by creating
> symlinks of needed jars under the directory /usr/share/maven-2.2/lib/.
>
> As I see, it fails before getting in to maven through classworlds.
> Unfortunately, I haven't have much experience with of classworlds
> behaves. Does anyone of you have any idea to get rid of this error?
> This _may_ not be an issue of maven having an incorrect classpath.
>
>  If this is through, we'll be much closer to getting maven from source
>  working.
>
> $ mvn-2.2 -X
> + Error stacktraces are turned on.
> Apache Maven 2.2.1 (r1135082; 2011-06-26 09:41:29+0530)
> Java version: 1.6.0_25
> Java home: /opt/sun-jdk-1.6.0.25/jre
> Default locale: en_US, platform encoding: ANSI_X3.4-1968
> OS name: "linux" version: "2.6.36-gentoo-r8" arch: "i386" Family: "unix"
> org.codehaus.classworlds.NoSuchRealmException: plexus.core
> at org.codehaus.classworlds.ClassWorld.getRealm(ClassWorld.java:128)
> at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:434)
> at org.codehaus.classworlds.Launcher.main(Launcher.java:375)


Did you try this without symlinks, just for test?


> Maven is called via classworlds with the command:
> "${JAVACMD}" \
> $MAVEN_OPTS \
> -classpath $(java-config -p classworlds-1.1) \
> -Dclassworlds.conf=/usr/share/maven-2/maven_home/bin/m2.conf \  #the m2.
> -Dmaven.home=/usr/share/maven-2.2 \
> -Dmaven.repo.remote=${HOME}/.m2/repository \
> -Dmaven.repo.local=${HOME}/.m2/repository  \
> ${CLASSWORLDS_LAUNCHER} \
> ${@}
>
> (The full script:
> http://overlays.gentoo.org/proj/java/browser/gsoc-maven-overlay/dev-
java/maven/files/2.2.1/bin/mvn)

Explain __MAVENHOME__ and __MAVEN_SHARE__.

I am also wondering about:

> -Dmaven.repo.remote=${HOME}/.m2/repository \
> -Dmaven.repo.local=${HOME}/.m2/repository  \

Note, that the format of the meta data in a remote and a local repo
*differs*. AFAICS you cannot have both at the same location. Why not have
one single system-wide remote repo, that is "stuffed" with the Gentoo-
installed libraries only? Simply add that to
/usr/share/maven-2.2/conf/settings.xml in an always active profile named
e.g. "gentoo-system".

>
> And, m2.conf file looks like this:
> =======
> main is org.apache.maven.cli.compat.CompatibleMain from plexus.core
>
> set maven.home default ${user.home}/m2
>
> [plexus.core]
> load ${maven.home}/lib/*.jar
> ========
>
> Let me know if any more information is needed

Maybe it's simply stupid?

$ file /usr/share/maven-bin-2.2/bin/m2.conf
/usr/share/maven-bin-2.2/bin/m2.conf: ASCII text, with CRLF line terminators

- Jörg


Reply | Threaded
Open this post in threaded view
|

Re: Re: [mvn-intg] maven-from-source : An issue when invoking mvn

Kasun Gajasinghe
Jörg,

Thanks for the suggestions. I was able to get over this issue at last.
It's probably because I haven't given priority to maven-compat (which
has the class org.apache.maven.cli.compat.CompatibleMain) over other
(symlinked) packages. I've renamed it to 01_maven-compat.jar. I've
tried the your suggestions as well, may be the CRLF case played a part
here too!

Right now, `mvn-2 clean` works _with_ a pre-setup m2 repo with
necessary plugins! ;)
There's this error pops up when trying 'clean' with an empty m2 repo.
'mvn compile' fails whether or not the needed plugins already
available. I'm trying to track down this error now. It's failing
either because it does not try to download needed jars or some version
mismatch (which I doubt) triggering NoSuchMethodError or because of a
missing component. If you have any inputs, please let me know.

The generated component
org.sonatype.plexus.components.sec.dispatcher.SecDispatcher is of type
'default' not 'maven'!

http://pastebin.com/NMp7ULXx

More comments below...

On Thu, Jun 30, 2011 at 2:46 AM, Jörg Schaible <[hidden email]> wrote:

>
>> Maven is called via classworlds with the command:
>> "${JAVACMD}" \
>> $MAVEN_OPTS \
>> -classpath $(java-config -p classworlds-1.1) \
>> -Dclassworlds.conf=/usr/share/maven-2/maven_home/bin/m2.conf \  #the m2.
>> -Dmaven.home=/usr/share/maven-2.2 \
>> -Dmaven.repo.remote=${HOME}/.m2/repository \
>> -Dmaven.repo.local=${HOME}/.m2/repository  \
>> ${CLASSWORLDS_LAUNCHER} \
>> ${@}
>>
>> (The full script:
>> http://overlays.gentoo.org/proj/java/browser/gsoc-maven-overlay/dev-
> java/maven/files/2.2.1/bin/mvn)
>
> Explain __MAVENHOME__ and __MAVEN_SHARE__.

JAVA_MAVEN_SYSTEM_HOME="/usr/share/maven-${JAVA_MAVEN_VERSION}/maven_home"
MAVEN=${PN}-${SLOT}
MAVEN_SHARE="/usr/share/${MAVEN}"

__MAVENHOME__ get replaced by JAVA_MAVEN_SYSTEM_HOME and other one
respectively in src_unpack phase.

See:
http://overlays.gentoo.org/proj/java/browser/gsoc-maven-overlay/dev-java/maven/maven-2.2.1.ebuild#L152
http://overlays.gentoo.org/proj/java/browser/gsoc-maven-overlay/eclass/java-maven-2.eclass#L93

>
> I am also wondering about:
>
>> -Dmaven.repo.remote=${HOME}/.m2/repository \
>> -Dmaven.repo.local=${HOME}/.m2/repository  \
>
> Note, that the format of the meta data in a remote and a local repo
> *differs*. AFAICS you cannot have both at the same location. Why not have
> one single system-wide remote repo, that is "stuffed" with the Gentoo-
> installed libraries only? Simply add that to
> /usr/share/maven-2.2/conf/settings.xml in an always active profile named
> e.g. "gentoo-system".

Yes, I think we should remove
-Dmaven.repo.remote=${HOME}/.m2/repository. Actually, remote repo
refers to a server which we generally via http protocal anyway, right?
User can provide the remote repo via settings.xml later on.

what do you mean by "system-wide remote repo"? Currently we have a
system wide _local_ repo at /usr/share/maven-2/maven_home/gentoo-repo.


Thanks,
--Kasun

--
~~~*******'''''''''''''*******~~~
Kasun Gajasinghe,
University of Moratuwa,
Sri Lanka.
Blog: http://blog.kasunbg.org
Twitter: http://twitter.com/kasunbg

Reply | Threaded
Open this post in threaded view
|

Re: Re: [mvn-intg] maven-from-source : An issue when invoking mvn

Kasun Gajasinghe
Hi,
Finally, we got maven from source working. Still there's some tweaks
to be done, and fix the shortcuts I took; but overall, it's working.
So, hopefully, after about week or so, it will be ready for some
rigorous testing.

Just wanted to tell you all the happy news. Appreciate any help we can
get to test this. We'll let you all know when it's fully ready.
Development is carried out at:
https://overlays.gentoo.org/svn/proj/java/gsoc-maven-overlay/dev-java/

Regards,
--Kasun

--
~~~*******'''''''''''''*******~~~
Kasun Gajasinghe,
University of Moratuwa,
Sri Lanka.
Blog: http://blog.kasunbg.org
Twitter: http://twitter.com/kasunbg

Reply | Threaded
Open this post in threaded view
|

Re: Re: [mvn-intg] maven-from-source : An issue when invoking mvn

Jörg Schaible-2
In reply to this post by Kasun Gajasinghe
Hi,

Kasun Gajasinghe wrote:

just answering for the repo for now ...

[snip]

>>
>> I am also wondering about:
>>
>>> -Dmaven.repo.remote=${HOME}/.m2/repository \
>>> -Dmaven.repo.local=${HOME}/.m2/repository  \
>>
>> Note, that the format of the meta data in a remote and a local repo
>> *differs*. AFAICS you cannot have both at the same location. Why not have
>> one single system-wide remote repo, that is "stuffed" with the Gentoo-
>> installed libraries only? Simply add that to
>> /usr/share/maven-2.2/conf/settings.xml in an always active profile named
>> e.g. "gentoo-system".
>
> Yes, I think we should remove
> -Dmaven.repo.remote=${HOME}/.m2/repository. Actually, remote repo
> refers to a server which we generally via http protocal anyway, right?

Any valid URL can do. Even using "file:" protocol.

> User can provide the remote repo via settings.xml later on.
>
> what do you mean by "system-wide remote repo"? Currently we have a
> system wide _local_ repo at /usr/share/maven-2/maven_home/gentoo-repo.

Every user will have to use an own local repo. You cannot share a local repo
between different users reliably. Additionally this is the repo the current
user *writes to* even if he downloads something (this is already critical if
you use M3's parallel build). Therefore you will have to establish a system-
wide *remote* repo that is filled up with the Gentoo-built stuff. If that
one is referred as remote repo in the settings.xml of the current Maven
installation, it is always considered independently of a user's own
repository declarations in his settings.xml.

In the end it means that the different local repo's will always contain
copies. Note, that it is for a developer a quite common task to wipe the
local repo from time to time.

If you set "maven.repo.remote", you overwrite Maven Central i.e. Maven's
default repo, but it will not prevent other remote lookups. If you want to
ensure that Maven is not using something else during ebuilds, you should use
a special settings.xml anyway that declares the system-wide *remote* repo as
mirror for everything ...

- Jörg