Menu

getting java.lang.ExceptionInInitializerError

2008-04-15
2013-04-25
  • Pankaj Sharma

    Pankaj Sharma - 2008-04-15

    Hi
    I am trying to run some test cases using mockStrutsTestCase I added commons-logging.jar in the test class path to reslove noclassdefinitionfound error But after that I am getting following stack trace .Any help

    java.lang.ExceptionInInitializerError
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at junit.framework.TestSuite.createTest(TestSuite.java:135)
        at junit.framework.TestSuite.addTestMethod(TestSuite.java:114)
        at junit.framework.TestSuite.<init>(TestSuite.java:75)
        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:102)
        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
        at servletunit.struts.MockStrutsTestCase.<clinit>(MockStrutsTestCase.java:82)
        ... 13 more
    Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
        at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
        ... 17 more
    Caused by: java.lang.NullPointerException
        at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
        ... 18 more

     
    • marfa posadniza

      marfa posadniza - 2008-04-15

      make sure you have all the jars in your classpath to run MockStruts:
      junit.jar
      servlet.jar
      struts.jar
      commons-digester.jar
      commons-collections.jar
      commons-logging.jar
      commons-beanutils.jar
      jaxp.jar
      crimson.jar
      strutstest.jar

      I dont' know which environment you are using - it might have its own jars like mine did, I had to actually use the ones that came with StrutsTest - in the test.war package.

      and you also need a log4j.properites file in your web-inf

       
    • Pankaj Sharma

      Pankaj Sharma - 2008-04-16

      Hi
      I have following jars in my test classpath.
      strutstest-2.1.4.jar
      j2ee.jar
      struts.jar
      junit-3.8.1.jar
      commons-logging.jar
      log4j-1.2.8.jar
      commons-collection.jar
      commons-digester.jar
      commons-beanutils.jar

      commons-logging.properties file contains the following entry

      log4jConfigFileName=log4j/P1M_MRC_BPres_log4j.xml

      Please let me know if there is anything wrong with the setup.

       
    • marfa posadniza

      marfa posadniza - 2008-04-16

      what dev env are you using?
      make sure the .jars in your path are from StrutsTestCase download - from the .war file
      are you able to run the examples that came with the download?
      the log4j properties file should be in your Junit  TC classpath too

       

Log in to post a comment.