Hi All,
   To reproduce this behavior:

1.  Create a Maven application
2.  Create a simple Java class
3.  Create a simple Test class that creates a Site using the SiteBuilder
4.  Create a simple site with at least one Element
5.  Create the Element's Java class

Now...try to execute your test with Maven "mvn jetty:run -o" to run the
tests.  Try and get Maven to run the tests without an NPE for the site in
the Test case.  If this is vague, I will try to do this myself and email the
list.

Take care,

Jeremy

On 12/19/06, Jeremy Whitlock <[EMAIL PROTECTED]> wrote:

Hi All,
    I am developing a RIFE web application that I am trying to unit test.
When my surefire tests run, RIFE is unable to load Java classes properly.
Here is the related portion of the pom.xml:

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <excludes>
                <exclude>**/SACBaseTest.java</exclude>
          </excludes>
          <systemProperties>
            <property>
              <name>rife.webapp.path</name>
              <value>${basedir}/target/classes</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
    <testResources>
      <testResource>
        <targetPath>/</targetPath>
        <filtering>false</filtering>
        <directory>${basedir}/src/main/webapp/WEB-INF/classes</directory>
        <includes>
          <include>**/*</include>
        </includes>
      </testResource>
    </testResources>
  </build>

Before I explain the problem, here is a part of the stacktrace:


com.uwyn.rife.engine.exceptions.ElementImplementationInstantiationException:
The implementation 'net.collab.extranet.sac.elements.SACHome' of element
'manual:SACHome' couldn't be instantiated.
        at com.uwyn.rife.engine.ElementFactory.getInstance(
ElementFactory.java:162)
        at com.uwyn.rife.engine.ElementInfo.deploy(ElementInfo.java:242)
        at com.uwyn.rife.engine.SiteBuilder.setupElements(
SiteBuilder.java:984)
        at com.uwyn.rife.engine.SiteBuilder.setupData(SiteBuilder.java
:1618)
        at com.uwyn.rife.engine.SiteBuilder.finish(SiteBuilder.java:261)
        at com.uwyn.rife.engine.SiteBuilder.process (SiteBuilder.java:252)
        at com.uwyn.rife.engine.SiteBuilder.getSite(SiteBuilder.java:178)
        at net.collab.extranet.sac.svn.SVNAdminCLIWrapperClientTest.setUp(
SVNAdminCLIWrapperClientTest.java:21)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run (TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java :25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.surefire.battery.JUnitBattery.executeJUnit(
JUnitBattery.java:246)
        at org.codehaus.surefire.battery.JUnitBattery.execute (
JUnitBattery.java:220)
        at org.codehaus.surefire.Surefire.executeBattery(Surefire.java
:204)
        at org.codehaus.surefire.Surefire.run(Surefire.java:153)
        at org.codehaus.surefire.Surefire.run(Surefire.java :77)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke (
DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.surefire.SurefireBooter.run(SurefireBooter.java
:104)
        at org.apache.maven.test.SurefirePlugin.execute (
SurefirePlugin.java:303)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(
DefaultPluginManager.java:412)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(
DefaultLifecycleExecutor.java :534)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle
(DefaultLifecycleExecutor.java:475)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal
(DefaultLifecycleExecutor.java :454)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
(DefaultLifecycleExecutor.java:306)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments (
DefaultLifecycleExecutor.java:273)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(
DefaultLifecycleExecutor.java:140)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke (Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java
:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode (
Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.NullPointerException
        at com.uwyn.rife.engine.ElementFactory.getJavaClass(
ElementFactory.java:100)
        at com.uwyn.rife.engine.ElementFactory.getJavaInstance(
ElementFactory.java:124)
        at com.uwyn.rife.engine.ElementFactory.getInstance(
ElementFactory.java:153)
        ... 47 more

So...a little information about the structure.  When my Maven application
runs the tests, the target directory looks like this:

target
  /classes
  /test-classes
    /sites
    /rep
    /templates

RIFE can successfully load the sites/main.xml but RIFE then starts to
instantiate the SACHome object.  This object is compiled to target/classes
but RIFE cannot find it.  RIFE developers tell me that RIFE's ClassLoader is
being circumvented or is using the same classpath as what the surefire tests
are.  How can I get my tests, which include RIFE's engine, to have the same
classpath?  I've done everything I can think of.  Just to show you all the
surefire classpath:

[DEBUG] Test Classpath :
[DEBUG] /Users/jwhitlock/work/sac/src/web-app/target/test-classes
[DEBUG] /Users/jwhitlock/work/sac/src/web-app/target/classes
[DEBUG] /Users/jwhitlock/work/sac/src/web-app/target/classes
[DEBUG] /Users/jwhitlock/work/sac/src/web-app/target/test-classes
[DEBUG] /Users/jwhitlock/.m2/repository/com/uwyn/rife-jdk15/1.5.1/rife-
jdk15-1.5.1.jar
[DEBUG] /Users/jwhitlock/.m2/repository/junit/junit/3.8.1/junit- 3.8.1.jar
[DEBUG] /Users/jwhitlock/.m2/repository/commons-io/commons-io/1.2/commons-
io-1.2.jar
[DEBUG] Adding to surefire test classpath:
/Users/jwhitlock/.m2/repository/surefire/surefire/1.4/surefire-1.4.jar
[DEBUG] Adding to surefire test classpath:
/Users/jwhitlock/.m2/repository/junit/junit/3.8.1/junit- 3.8.1.jar
[DEBUG] Adding to surefire test classpath:
/Users/jwhitlock/.m2/repository/surefire/surefire-booter/1.4/surefire-
booter-1.4.jar
[DEBUG] Adding to surefire test classpath: /usr/local/maven-2.0
/core/plexus-utils-1.1.jar

As you can see, target/classes and target/test-classes are both on the
classpath and should allow RIFE to be able to load classes from
target/classes but is not able to do so.

Take care,

Jeremy

_______________________________________________
Rife-users mailing list
Rife-users@uwyn.com
http://lists.uwyn.com/mailman/listinfo/rife-users

Reply via email to