Loading ...
Sorry, an error occurred while loading the content.

Re: Reading property files fails when running from Ant / Classpath not set

Expand Messages
  • samponiskanen
    My previous email didn t seem to come through to the list... Resending. Hi, ... I did also that already, just forgot to mention in the previous email. JUnit
    Message 1 of 4 , Oct 2, 2009
    • 0 Attachment
      My previous email didn't seem to come through to the list... Resending.


      Hi,

      On Mon, Sep 28, 2009 at 7:13 AM, Mike Forsberg <bigmike@...> wrote:
      > My first suggestion is to run ant with the -v command option. This
      > will list the command line execution to the junit call. (I think :) )
      >
      > Once you have the command line execution you should be able to see the issue.

      I did also that already, just forgot to mention in the previous
      email. JUnit first writes out the system properties, in which
      java.class.path does not contain anything related to my project. Then
      it states that it is "Using CLASSPATH" that includes my 3rd party
      libraries, the class directories and the base directory of my project.
      But this latter classpath is not passed on within the tests.

      Since it's being run from ant, I guess JUnit is being called directly
      instead of using a command line call.

      I've included below excerpts from ant -v -d output. There JUnit
      states that /home/sampo/Projects/OpenRocket (the base directory) is in
      the classpath. (Sorry for the extremely long lines)

      I'm using the Ubuntu JUnit 4.3.1-4 package.

      Thanks for your help!



      ... zillion lines of compiling ...

      [echo] Running unit tests
      [junit] Found /usr/share/ant/lib/junit.jar
      [junit] Found /usr/share/ant/lib/ant-launcher.jar
      [junit] Found /usr/share/ant/lib/ant.jar
      [junit] Found /usr/share/ant/lib/ant-junit.jar
      fileset: Setup scanner in dir
      /home/sampo/Projects/OpenRocket/build/test with patternSet{ includes:
      [**/*Test*.class] excludes: [Test.class] }
      [junit] Using System properties {java.runtime.name=Java(TM) SE
      Runtime Environment,
      sun.boot.library.path=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386,
      java.vm.version=14.2-b01, ant.library.dir=/usr/share/ant/lib,
      java.vm.vendor=Sun Microsystems Inc.,
      java.vendor.url=http://java.sun.com/, path.separator=:,
      java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io,
      user.country=US, sun.java.launcher=SUN_STANDARD,
      sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual
      Machine Specification, user.dir=/home/sampo/Projects/OpenRocket,
      java.runtime.version=1.6.0_16-b01,
      java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment,
      java.endorsed.dirs=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/endorsed,
      os.arch=i386, java.io.tmpdir=/tmp, line.separator=
      [junit] , java.vm.specification.vendor=Sun Microsystems Inc.,
      os.name=Linux, ant.home=/usr/share/ant, sun.jnu.encoding=UTF-8,
      java.library.path=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib,
      java.specification.name=Java Platform API Specification,
      java.class.version=50.0, sun.management.compiler=HotSpot Client
      Compiler, os.version=2.6.28-15-generic, user.home=/home/sampo,
      user.timezone=, java.awt.printerjob=sun.print.PSPrinterJob,
      file.encoding=UTF-8, java.specification.version=1.6,
      java.class.path=/usr/share/ant/lib/ant-launcher.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/xercesImpl.jar:/usr/share/ant/lib/ant-junit.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant-trax.jar:/usr/share/ant/lib/ant-apache-bsf.jar:/usr/share/ant/lib/catalina5.5-ant.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-apache-log4j.jar:/usr/share/ant/lib/junit.jar:/usr/share/ant/lib/ant-commons-net.jar:/usr/share/ant/lib/ant-javamail.jar:/usr/share/ant/lib/ant-antlr.jar:/usr/share/ant/lib/ant-jsch.jar:/usr/share/ant/lib/tomcat5.5-jkstatus-ant.jar:/usr/share/ant/lib/ant-jdepend.jar:/usr/share/ant/lib/jsch.jar:/usr/share/ant/lib/bcel.jar:/usr/share/ant/lib/ant-apache-bcel.jar:/usr/share/ant/lib/ant-apache-oro.jar:/usr/share/ant/lib/ant-nodeps.jar:/usr/share/ant/lib/ant-commons-logging.jar:/usr/share/ant/lib/ant-jmf.jar:/usr/share/ant/lib/ant-apache-regexp.jar:/usr/share/ant/lib/ant-swing.jar:/usr/share/ant/lib/junit4.jar:/usr/share/ant/lib/ant-apache-resolver.jar:/usr/share/ant/lib/catalina5.5-ant-jmx.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/lib/tools.jar,
      user.name=sampo, java.vm.specification.version=1.0,
      java.home=/usr/lib/jvm/java-6-sun-1.6.0.16/jre,
      sun.arch.data.model=32, user.language=en,
      java.specification.vendor=Sun Microsystems Inc., java.vm.info=mixed
      mode, sharing, java.version=1.6.0_16,
      java.ext.dirs=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/ext:/usr/java/packages/lib/ext,
      sun.boot.class.path=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/classes,
      java.vendor=Sun Microsystems Inc., file.separator=/,
      java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi,
      sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little,
      sun.cpu.isalist=}
      [junit] Implicitly adding
      /usr/share/ant/lib/junit.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar
      to CLASSPATH
      [junit] Using CLASSPATH
      /home/sampo/Projects/OpenRocket/lib/jcommon-1.0.16.jar:/home/sampo/Projects/OpenRocket/lib/jfreechart-1.0.13.jar:/home/sampo/Projects/OpenRocket/lib/miglayout15-swing.jar:/home/sampo/Projects/OpenRocket:/home/sampo/Projects/OpenRocket/build/test:/home/sampo/Projects/OpenRocket/build/dist:/usr/share/ant/lib/junit4.jar:/usr/share/ant/lib/junit.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar

      ... loading a zillion JRE and my project's classes ...

      [junit] Running net.sf.openrocket.rocketcomponent.ComponentCompareTest
      ResourceStream for
      META-INF/services/javax.xml.parsers.DocumentBuilderFactory loaded from
      parent loader
      Finding class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
      Class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl loaded from
      parent loader
      Couldn't load ResourceStream for
      META-INF/services/org.apache.xerces.xni.parser.XMLParserConfiguration
      Finding class org.apache.xerces.parsers.XIncludeAwareParserConfiguration
      Class org.apache.xerces.parsers.XIncludeAwareParserConfiguration
      loaded from parent loader
      Finding class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl
      Class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl loaded from parent loader
      [junit] junit.framework.TestListener: tests to run: 2
      [junit] junit.framework.TestListener: startTest(testComponentEquality)
      ... loading ...
      Class java.io.IOException loaded from parent loader (parentFirst)
      Class java.util.MissingResourceException loaded from parent loader (parentFirst)
      Class java.lang.ClassLoader loaded from parent loader (parentFirst)
      [junit] junit.framework.TestListener: addError(testComponentEquality, null)
      [junit] junit.framework.TestListener: endTest(testComponentEquality)
      [junit] junit.framework.TestListener: startTest(testComponentSimilarity)
      [junit] junit.framework.TestListener:
      addError(testComponentSimilarity, Could not initialize class
      net.sf.openrocket.util.Prefs)
      [junit] junit.framework.TestListener: endTest(testComponentSimilarity)
      [junit] Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.389 sec
      [junit] Test net.sf.openrocket.rocketcomponent.ComponentCompareTest FAILED
      Setting project property: junit.failure -> true
    • David Saff
      Did you ever get a resolution to this? Thanks, David Saff
      Message 2 of 4 , Oct 23, 2009
      • 0 Attachment
        Did you ever get a resolution to this? Thanks,

        David Saff

        On Fri, Oct 2, 2009 at 5:14 PM, samponiskanen <sampo.niskanen@...> wrote:
        > My previous email didn't seem to come through to the list...  Resending.
        >
        >
        > Hi,
        >
        > On Mon, Sep 28, 2009 at 7:13 AM, Mike Forsberg <bigmike@...> wrote:
        >> My first suggestion is to run ant with the -v command option. This
        >> will list the command line execution to the junit call. (I think :) )
        >>
        >> Once you have the command line execution you should be able to see the issue.
        >
        > I did also that already, just forgot to mention in the previous
        > email.  JUnit first writes out the system properties, in which
        > java.class.path does not contain anything related to my project.  Then
        > it states that it is "Using CLASSPATH" that includes my 3rd party
        > libraries, the class directories and the base directory of my project.
        >  But this latter classpath is not passed on within the tests.
        >
        > Since it's being run from ant, I guess JUnit is being called directly
        > instead of using a command line call.
        >
        > I've included below excerpts from ant -v -d output.  There JUnit
        > states that /home/sampo/Projects/OpenRocket (the base directory) is in
        > the classpath.   (Sorry for the extremely long lines)
        >
        > I'm using the Ubuntu JUnit 4.3.1-4 package.
        >
        > Thanks for your help!
        >
        >
        >
        > ... zillion lines of compiling ...
        >
        >    [echo] Running unit tests
        >   [junit] Found /usr/share/ant/lib/junit.jar
        >   [junit] Found /usr/share/ant/lib/ant-launcher.jar
        >   [junit] Found /usr/share/ant/lib/ant.jar
        >   [junit] Found /usr/share/ant/lib/ant-junit.jar
        > fileset: Setup scanner in dir
        > /home/sampo/Projects/OpenRocket/build/test with patternSet{ includes:
        > [**/*Test*.class] excludes: [Test.class] }
        >   [junit] Using System properties {java.runtime.name=Java(TM) SE
        > Runtime Environment,
        > sun.boot.library.path=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386,
        > java.vm.version=14.2-b01, ant.library.dir=/usr/share/ant/lib,
        > java.vm.vendor=Sun Microsystems Inc.,
        > java.vendor.url=http://java.sun.com/, path.separator=:,
        > java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io,
        > user.country=US, sun.java.launcher=SUN_STANDARD,
        > sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual
        > Machine Specification, user.dir=/home/sampo/Projects/OpenRocket,
        > java.runtime.version=1.6.0_16-b01,
        > java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment,
        > java.endorsed.dirs=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/endorsed,
        > os.arch=i386, java.io.tmpdir=/tmp, line.separator=
        >   [junit] , java.vm.specification.vendor=Sun Microsystems Inc.,
        > os.name=Linux, ant.home=/usr/share/ant, sun.jnu.encoding=UTF-8,
        > java.library.path=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib,
        > java.specification.name=Java Platform API Specification,
        > java.class.version=50.0, sun.management.compiler=HotSpot Client
        > Compiler, os.version=2.6.28-15-generic, user.home=/home/sampo,
        > user.timezone=, java.awt.printerjob=sun.print.PSPrinterJob,
        > file.encoding=UTF-8, java.specification.version=1.6,
        > java.class.path=/usr/share/ant/lib/ant-launcher.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/xercesImpl.jar:/usr/share/ant/lib/ant-junit.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant-trax.jar:/usr/share/ant/lib/ant-apache-bsf.jar:/usr/share/ant/lib/catalina5.5-ant.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-apache-log4j.jar:/usr/share/ant/lib/junit.jar:/usr/share/ant/lib/ant-commons-net.jar:/usr/share/ant/lib/ant-javamail.jar:/usr/share/ant/lib/ant-antlr.jar:/usr/share/ant/lib/ant-jsch.jar:/usr/share/ant/lib/tomcat5.5-jkstatus-ant.jar:/usr/share/ant/lib/ant-jdepend.jar:/usr/share/ant/lib/jsch.jar:/usr/share/ant/lib/bcel.jar:/usr/share/ant/lib/ant-apache-bcel.jar:/usr/share/ant/lib/ant-apache-oro.jar:/usr/share/ant/lib/ant-nodeps.jar:/usr/share/ant/lib/ant-commons-logging.jar:/usr/share/ant/lib/ant-jmf.jar:/usr/share/ant/lib/ant-apache-regexp.jar:/usr/share/ant/lib/ant-swing.jar:/usr/share/ant/lib/junit4.jar:/usr/share/ant/lib/ant-apache-resolver.jar:/usr/share/ant/lib/catalina5.5-ant-jmx.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/lib/tools.jar,
        > user.name=sampo, java.vm.specification.version=1.0,
        > java.home=/usr/lib/jvm/java-6-sun-1.6.0.16/jre,
        > sun.arch.data.model=32, user.language=en,
        > java.specification.vendor=Sun Microsystems Inc., java.vm.info=mixed
        > mode, sharing, java.version=1.6.0_16,
        > java.ext.dirs=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/ext:/usr/java/packages/lib/ext,
        > sun.boot.class.path=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/classes,
        > java.vendor=Sun Microsystems Inc., file.separator=/,
        > java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi,
        > sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little,
        > sun.cpu.isalist=}
        >   [junit] Implicitly adding
        > /usr/share/ant/lib/junit.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar
        > to CLASSPATH
        >   [junit] Using CLASSPATH
        > /home/sampo/Projects/OpenRocket/lib/jcommon-1.0.16.jar:/home/sampo/Projects/OpenRocket/lib/jfreechart-1.0.13.jar:/home/sampo/Projects/OpenRocket/lib/miglayout15-swing.jar:/home/sampo/Projects/OpenRocket:/home/sampo/Projects/OpenRocket/build/test:/home/sampo/Projects/OpenRocket/build/dist:/usr/share/ant/lib/junit4.jar:/usr/share/ant/lib/junit.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar
        >
        > ... loading a zillion JRE and my project's classes ...
        >
        >   [junit] Running net.sf.openrocket.rocketcomponent.ComponentCompareTest
        > ResourceStream for
        > META-INF/services/javax.xml.parsers.DocumentBuilderFactory loaded from
        > parent loader
        > Finding class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
        > Class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl loaded from
        > parent loader
        > Couldn't load ResourceStream for
        > META-INF/services/org.apache.xerces.xni.parser.XMLParserConfiguration
        > Finding class org.apache.xerces.parsers.XIncludeAwareParserConfiguration
        > Class org.apache.xerces.parsers.XIncludeAwareParserConfiguration
        > loaded from parent loader
        > Finding class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl
        > Class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl loaded from parent loader
        >   [junit] junit.framework.TestListener: tests to run: 2
        >   [junit] junit.framework.TestListener: startTest(testComponentEquality)
        > ... loading ...
        > Class java.io.IOException loaded from parent loader (parentFirst)
        > Class java.util.MissingResourceException loaded from parent loader (parentFirst)
        > Class java.lang.ClassLoader loaded from parent loader (parentFirst)
        >   [junit] junit.framework.TestListener: addError(testComponentEquality, null)
        >   [junit] junit.framework.TestListener: endTest(testComponentEquality)
        >   [junit] junit.framework.TestListener: startTest(testComponentSimilarity)
        >   [junit] junit.framework.TestListener:
        > addError(testComponentSimilarity, Could not initialize class
        > net.sf.openrocket.util.Prefs)
        >   [junit] junit.framework.TestListener: endTest(testComponentSimilarity)
        >   [junit] Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.389 sec
        >   [junit] Test net.sf.openrocket.rocketcomponent.ComponentCompareTest FAILED
        > Setting project property: junit.failure -> true
        >
        >
        >
        >
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.