« Return to Thread: additional classpath for tomcat5x not working

Re: additional classpath for tomcat5x not working

by Adrian Cole :: Rate this Message:

Reply to Author | View in Thread

Wow.  Seems like you have done a lot of work here.  I'll paste your notes into the Jira.

To clarify the use case, you basically want to patch a class that exists in the webapp classloader externally somehow?

class A extends class B
class A is what you want to add to the classpath
class B is in a webapp classloader, ex. WEB-INF/lib/my.jar

is that right?

thanks,
-Adrian

On Mon, Feb 9, 2009 at 12:09 PM, Paul Hammes <Paul.Hammes@...> wrote:
Hi Adrian,

I have done a lot of testing and debugging and I hope I've identified the problem.

As location in the configuration of cargo the path to the classes are defined. This path will be set in the StandardClassLoader.
The class A which will be loaded per reflection can be found in the specified path but extends a class B stored in a jar.
As defined in the policy of Java the StandardClassLoader will try to load class A before the WebappClassLoader. The problem here is that the StandardClassLoader has no information about class B.

I tried to remove the location dependency and put the jar with class A to WEB_INF/lib of the container and it works. But this is not a solution for me. You can't define the project as a dependency to itself.

A solution would be to give the paths defined as location dependencies to the WebappClassLoader.

Cheers

Paul



Hi, Paul.

If you can do the following, it would help identify the problem. We don't have an integration test for a folder element in the classpath, yet. I cannot get to that today or tomorrow, but it seems worthwhile. In the meantime, I can review debug for at least a second set of eyes.

Why don't you attach your pom.xml and the output of mvn -X into the jira?

On Thu, Feb 5, 2009 at 1:52 PM, Paul Hammes <Paul...@...> wrote:

Hi Adrian,

I moved the classes folder to ${basedir}/target/tomcat/target/main. This has no effect. I also tried to specify the path absolutly but it doesn't work. If the classes were packed as jar and copied to WEB-INF/lib everything works fine. But this way of doing it is not a possible solution for me.

Any other idea how to solve this issue?

Cheers

Paul

-------- Original-Nachricht --------

Datum: Thu, 5 Feb 2009 13:02:36 +0000 Von: Adrian Cole <fern...@...> An: us...@... Betreff: Re: [cargo-user] additional classpath for tomcat5x not working

Thanks for trying the patch. I think there is also a relative path issue, Paul.

You've specifed: target/main/classes The container runs from its home: ${basedir}/target/tomcat

So, it is looking for: ${basedir}/target/tomcat/target/main/classes, if I'm not mistaken.

Can you check into this?

Best of luck, -Adrian On Thu, Feb 5, 2009 at 11:08 AM, Paul Hammes <Paul...@...> wrote:

Hi Adrian,

I have tested the artifact cargo-core-uberjar-1.0-SNAPSHOT.jar listed in CARGO-TRUNKM2JDK15-265 after you have done the fix. I have the same problem as before.

my pom:

<plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.0-beta-2</version> <dependencies> <dependency> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-core-uberjar</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> ...

What have I did wrong?

I debugged my application and read out the classpath using System.getProperty("java.class.path") and the path specified in the location was listed in the classpath. A Class.forName(clazz) throws the NoClassDefFoundException.

Cheers

Paul

-------- Original-Nachricht --------

Datum: Thu, 5 Feb 2009 10:07:07 +0000 Von: Adrian Cole <fern...@...> An: us...@... Betreff: Re: [cargo-user] additional classpath for tomcat5x not

working

No worries. Have a look at the jira, I believe this fix may not be

in

the

beta you are using.

Cheers, -Adrian

On Thu, Feb 5, 2009 at 9:44 AM, Paul Hammes <Paul...@...> wrote:

Hi Adrian,

thanks for your fast reply. I've recorded this issue as CARGO-663.

Cheers,

Paul

-------- Original-Nachricht --------

Datum: Thu, 5 Feb 2009 09:28:27 +0000 Von: Adrian Cole <fern...@...> An: us...@... Betreff: Re: [cargo-user] additional classpath for tomcat5x not
On Thu, Feb 5, 2009 at 9:22 AM, Paul Hammes <Paul...@...> wrote:

Hi all,

we have an application which is divided into serveral projects.

One

project

containing all resources for the client (js, css, ...) is

packaged

as a

war

and will be deployed to tomcat5x in another project. This

second

project

can

only be packaged as jar due to deployment issues of another

team

in

our

company. As I read in the documentation of the cargo plugin an

additional

classpath

can be specified within a <location> as a dependency. This has

no

effect

at

runtime even the tomcat lists this path in the

JspRuntimeContext

at

startup.

A NoClassDefFoundError is thrown when instantiating a class out

of

the

specified location. The jars listed in JspRuntimeContext are working correctly. You can find my pom file below. I tried to specify the dependency to the second project as a

jar

but

this

is a cycle dependency.

I hope you can help me.

Kind regards

Paul

<plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.0-beta-2</version> <configuration> <configuration> <type>existing</type> <home>${basedir}/target/tomcat</home> <properties> <cargo.jvmargs><![CDATA[-Xdebug

-Xrunjdwp:transport=dt_socket,address=5555,server=y,suspend=n]]>

</cargo.jvmargs> </properties> <deployables> <deployable> <artifactId>webresources</artifactId> <groupId>${project.groupId}</groupId> <type>war</type> <properties> <context>myproject</context> </properties> </deployable> </deployables> </configuration> <container> <containerId>tomcat5x</containerId> <home>${basedir}/target/tomcat</home> <dependencies> <dependency> <location>target/main/classes</location> </dependency> </dependencies> </container> </configuration> </plugin>

-- Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s

mit

allen:

http://www.gmx.net/de/go/multimessenger01

---------------------------------------------------------------------

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

-- Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01

---------------------------------------------------------------------

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

-- Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a

--------------------------------------------------------------------- To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

-- Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01

--------------------------------------------------------------------- To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



 « Return to Thread: additional classpath for tomcat5x not working