jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Lindwall <JLindw...@Xifin.com>
Subject Classloader hell -- need help testing protected/package level met hods using cactus
Date Fri, 20 May 2005 01:10:17 GMT
We've been using cactus 1.6 productively for over 6 months, against WebLogic 6.1. We are now
starting to have some problems that I believe are related to the classloader heirarchy of
WebLogic and I wonder if anyone has any advice.

We had no problems until somebody modified one of the objects under test from having a public
constructor to a protected constructor.  Now we get an illegal access exception:

java.lang.IllegalAccessError: try to access method com.mbasys.mars.pricing.PricingCalcs.<init>()V
from class com.mbasys.mars.pricing.ServerTestPricingCalcs at ...

The test case is simply constructing the object under test at the line in question:

package com.mbasys.mars.pricing;
    protected void setUp() throws Exception

        pc = new PricingCalcs();    // <----------- This line bombs !!!!!!!!!!

If I change the PricingCalcs constructor back to public it works fine.  We see this same type
of problem with any test that tries to access protected or package level items.

The ServletTestCase implementation is in the same package (com.mbasys.mars.pricing) as the
application class under test (PricingCalcs).  I do this intentionally when writing unit tests
(as most do) to allow testing of protected and package level methods.  However I don't think
that matters in this case, because the test case is loaded by the webapp ClassLoader but the
application class is loaded by the EJB ClassLoader (which is the parent classloader of the

WebLogic has this kind of ClassLoader heirarchy AFAIK:

	WebApp ClassLoader -> EJB ClassLoader -> System ClassLoader

The cactus test cases are deployed to the cactus webapp's WEB-INF/classes dir so we can hot
deploy them.  I'd hate to lose that capability.

The application classes are in the EJB ClassLoader's classpath since the EJBs reference the
app classes.

I've tried deploying the application classes to cactus webapp's WEB-INF/classes alongside
the test cases and it clears up the (IllegalAccessException) issue mentioned above, but creates
some new ugly ClassLoader issues ones which I can detail if need be.  Briefly: One issue was
that our application looks up a service in JNDI which depends on some appplication classes/interfaces
so we got ClassCastExceptions when accessing these objects in the testcases.    I've tried
excluding select application classes from the cactus webapp's WEB-INF/classes dir but it just
seems to get messier and messier.

Any ideas?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message