Well, it is simple to explain why the tests run well in mvn: None of the code 
covered by the tests is throwing or catching the mentioned exception. So it is 
not a problem that the class is abstract.

 

Von: m2e-users-boun...@eclipse.org [mailto:m2e-users-boun...@eclipse.org] Im 
Auftrag von Fred Bricon
Gesendet: Dienstag, 24. Juli 2012 12:37
An: Maven Integration for Eclipse users mailing list
Betreff: Re: [m2e-users] JUnit runs well using "Run As > Maven test" but fails 
at "Run As > JUnit test"

 

javaee-api-6.0.jar contains classes with empty methods and is only useful for 
compiling. 

 

You should use one of the javaee6 implementations provided by jboss ( 
http://search.maven.org/#artifactdetails%7Corg.jboss.spec%7Cjboss-javaee_6.0_spec%7C1.0.0.Beta3%7Cpom
 ) or glassfish (not sure what artifactId they use) to actually run things, 
like tests.

 

I don't understand why the tests run under maven though, it'd be interesting to 
provide a sample project to reproduce the bug.

 

Regards,

 

Fred Bricon

On Tue, Jul 24, 2012 at 12:23 PM, Markus Karg <k...@quipsy.de> wrote:

I have a strange classpath problem in m2e and hope you can help.

 

At the command line (CMD.EXE) on my Windows 7 (64 Bit) machine I can type “mvn 
test”, which compiles and tests and then says all is good.

 

Also, I can run “Run As > Maven test”, which prints in the “Console” view that 
the test passed and all is good.

 

But within Eclipse when doing “Run As > JUnit Test”, it flips the bar to red 
after some tests and then says:

 

java.lang.ClassFormatError: Absent Code attribute in method that is not native 
or abstract in class file javax/ejb/EJBException

                at java.lang.ClassLoader.defineClass1(Native Method)

                at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

                at java.lang.ClassLoader.defineClass(ClassLoader.java:615)

                at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)

                at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)

                at java.net.URLClassLoader.access$000(URLClassLoader.java:58)

                at java.net.URLClassLoader$1.run(URLClassLoader.java:197)

                at java.security.AccessController.doPrivileged(Native Method)

                at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

                at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

                at 
de.quipsy.entities.ProjectAPQPCompliance.canBeEdited(ProjectAPQPCompliance.java:68)

                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:597)

                at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

                at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

                at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at 
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at 
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at 
org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at 
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

 

Why is this working at CLI but not in GUI? And what the heck is “Absent Code 
attribute” (I only know “ClassNotFoundException”)?

 

I tried to fix it using “Maven > Update Project…”, but this did not help. 
Strange but true, the code compiles very well in Eclipse, including all uses of 
javax.ejb.EJBException in the java source, and the tree node “Maven 
Dependencies” actually shows “javaee-api-6.0.jar” containing 
“javax/ejb/EJBException” in Eclipse’s “Package Explorer” view!

 

I’m really confused…!

 

Thanks!

Markus


_______________________________________________
m2e-users mailing list
m2e-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/m2e-users





 

-- 
"Have you tried turning it off and on again" - The IT Crowd

_______________________________________________
m2e-users mailing list
m2e-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/m2e-users

Reply via email to