• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Application error when running an Junit test case

 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having an problem when running an junittestcase on a java class(which extends another class)
The error trace is:

junit] arguments are not type compatible (class: org/apache/log4j/LogManager method: <clinit>()V) at pc: 18
junit] java.lang.VerifyError: arguments are not type compatible (class: org/apache/log4j/LogManager method: <clinit
at pc: 18



consider I'm running a test case on a class c which extends class B.
These class B has a Logger in which error is showing.
When I'm instantiating Class C on my test case, it will normally call its superclass constructor(i.e B) in which the java.lang.verify error surfaces

class C extends B
{
}

class B
{
//Here in the following line the above error java.lang.verify error is showing up
private static Logger m_cat = Logger.getLogger(MLBatchProcessSetup.class);
}

}



Note when I'm building the application these classes are running properly, but only when I'm running an test case it throws the java.lang.verify error.
Can anybody throw some light on this?
Regards.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when I go through that sun site, the reason for that error is mentioned as:
java.lang.verifyerror gets

Thrown when the "verifier" detects that a class file, though well formed, contains some sort of internal inconsistency or security problem.


This the url of that link:
java.lang.verifyError
With this can anyone throw their insights.
Regards.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This link also provides some very valid inputs into the problem.
Fixing java.lang.verifyError
But I don't know how this can be resonated in my case.
Regards.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main problem is that Logger of that super class does not gets instantiated.
But when I'm building the application , it's working fine, only when I'm testing the implementation by writing an API Test case these verifyError surfaces.
Regards.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using jdk1.3 version.
Regards
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you are using differents version of the Log4J library when you compile your software and in the runtime environment. Make sure you use exactly the same Log4J JAR files.

What version of Log4J are you using? Are you sure you're using a version that is compatible with Java 1.3?

Also, make sure that you are compiling your source code with the JDK version that matches exactly with the runtime version that you're using. So, make sure that you're using JDK 1.3 to compile your source code, if you're running it on Java 1.3.

Are you compiling and running the software on the same environment (same operating system, etc.)?
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It sounds like you are using differents version of the Log4J library when you compile your software and in the runtime environment. Make sure you use exactly the same Log4J JAR files.


When I searched for jar files, I found only these jars for log files.
log4j.jar
log4j_patch.jar

1)These log4j_patch.jar is located in C:\CustomizationsWorking\deploy\approot\WEB-INF\lib and also in C:\CustomizationsWorking\customresources\lib
log4j.jar is located in C:\CustomizationsWorking\deploy\approot\WEB-INF\lib

2) Both of these jar files contains a class LogLog.class.( Is the error surfaces due to these issue both of the jars contains the same class)

3) This LogLog.class is the only class in log4j_patch.jar

What version of Log4J are you using? Are you sure you're using a version that is compatible with Java 1.3?


I'm using the above mentioned jar files & don't know if it is compatible with jdk1.3.
But one thing is sure.
When i build & test the application under RegressionTestBed(RTB) environment it is working fine, but when I try to run it through my test case, it is throwing the java.lang.verifyError.(the exact error trace in my first post)

Are you compiling and running the software on the same environment (same operating system, etc.)?



Yes

Also, make sure that you are compiling your source code with the JDK version that matches exactly with the runtime version that you're using. So, make sure that you're using JDK 1.3 to compile your source code, if you're running it on Java 1.3.


How to check this one?
Regards.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any replies?
 
Ranch Hand
Posts: 326
Android Mac OS X Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ramya narayanan:

How to check this one?
Regards.



Read the release notes...
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you could brief me I appreciate it.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both of these jar files contains a class LogLog.class.( Is the error surfaces due to these issue both of the jars contains the same class)
Regards.
 
Marshal
Posts: 79707
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think this is a real beginner's subject. Moving thread.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To give clarity, I hereby present the Testcase which I've written

package p2;
import com.trilogy.util.override.BundleStack;
import com.trilogy.util.override.BundleStackFactory;
import com.trilogy.ffc.html.FFCTracer;
import com.trilogy.sc.ISCCMProduct;
import p1.A;
import junit.framework.JUnit4TestAdapter;
import junit.framework.Assert;

import java.util.Vector;
import org.junit.Test;
import java.lang.reflect.*;
import com.trilogy.fs.dms.core.validator.test.ValidatorTestCase;

public class ATest extends ValidatorTestCase {
public static junit.framework.Test suite() {
System.out.println("In Test suite");
return new JUnit4TestAdapter(ATest.class);
}

@Test (timeout = 50000)
public void processCompEventsTest() throws Throwable{
System.out.println("Inside API Test case method to test the compevent processing ..... SAI...");
Class c=Class.forName("A");
//These processCompEvents is a protected method in A class
Method m = c.getDeclaredMethod("processCompEvents", null);
m.setAccessible(true);
m.invoke(c, null);
}

}



I've written an ant target to run this:



<target name="Custom.test" depends="-SetCustomClasspathForTest, Custom.test-init, Custom.TestBuild">
<junit printsummary="false" errorProperty="test.failed" failureProperty="test.failed" fork="yes">
<classpath refid="ATF.classpath"/>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${test.reports.dir}/jtf/data">
<fileset dir="${test.classes.dir}" includes="**/*Test.class" excludes="**/*Task.class,com/ml/inst/icp/loader/validator/*Validator.class"/>
</batchtest>
</junit>
<junitreport todir="${test.reports.dir}/jtf/data">
<fileset dir="${test.reports.dir}/jtf/data">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${test.reports.dir}/jtf"/>
</junitreport>
<fail message="Tests failed. Check log and/or reports." if="test.failed"/>
</target>


When I run this target by issuing this command:

ant -buildfile test\test.xml Custom.test -Denvironment=LOCAL



It's giving the following error trace:



[junit] arguments are not type compatible (class: org/apache/log4j/LogManager method: <clinit>()V) at pc: 18
[junit] java.lang.VerifyError: arguments are not type compatible (class: org/apache/log4j/LogManager method: <clinit
>()V) at pc: 18
[junit] at java.lang.J9VMInternals.verifyImpl(Native Method)
[junit] at java.lang.J9VMInternals.verify(J9VMInternals.java:55)
[junit] at java.lang.J9VMInternals.initialize(J9VMInternals.java:124)
[junit] at org.apache.log4j.Logger.getLogger(Logger.java:94)
[junit] at com.metlife.inst.icp.engine.Bsuper.<clinit>(Bsuper.java:32)
[junit] at java.lang.J9VMInternals.initializeImpl(Native Method)
[junit] at java.lang.J9VMInternals.initialize(J9VMInternals.java:161)
[junit] at java.lang.J9VMInternals.initialize(J9VMInternals.java:140)
[junit] at java.lang.Class.forNameImpl(Native Method)
[junit] at java.lang.Class.forName(Class.java:131)



The following line is in Bsuper which is a superclass for my A .java
on which I'm running the test case.
In line no 32 of Bsuper

private static Logger m_cat = Logger.getLogger(Bsuper.class);



The following are the structure in which the test case classes & log4j jars are present

1)ValidatorTestCase.class in present in C:\.....\Test\lib as a jar file in which junit4.3.jar is also present

2) The error showing LogManager.class is present in log4j.jar present in C:\CustomizationsWorking\deploy\approot\WEB-INF\lib

3) The other log jar log4jpatch.jar is located in two places:
C:\CustomizationsWorking\deploy\approot\WEB-INF\lib
C:\CustomizationsWorking\customresources\lib


Regards.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any replies?
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramya,
It sounds like your compile time and runtime classpaths are using different jars. Or that you have two copies of the same jar in your classpath.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I've fixed this java.lang.verifyError.
Actually the problem is not with log4j installation jars or classpath or not.
The main problem is with logger instantiation.
When I remove the loggers in my .java & in its dependent classes(superclasses or composition classes) it's working fine.
But seriously I don't know why my testcase written in junit-4.3 & ant1.6 & the log jars I'm using are log4j.jar & log4j_patch.jar.
Anyhow thanks for all the good hearts who supported me in this endeavour.
Regards.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ramya,

I am facing a similar error when running hot code plugin on Eclipse.

Here is the complete stack trace :


Redefining the class...
* Redefining amdocs.oms.apcore.ApItem
Exception in thread "main" java.lang.VerifyError: verifier detected internal inc
onsistency or security problem
at com.sun.tools.jdi.VirtualMachineImpl.redefineClasses(VirtualMachineIm
pl.java:296)
at SwapperEnc.main(SwapperEnc.java:119)


Can you suggest a possible trouble shoot for this ? We are stuck with this all day.

I am working on J2sdk 1.4 update 7.

Thanks
Prashant


 
them good ole boys were drinking whiskey and rye singin' this'll be the day that I die. Drink tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic