Re: Problem running unit tests from maven (JPA related)

2009-12-01 Thread sim085


Thank you for that, I totally agree. Yesterday I still had some problems
because my persistence module has some session beans. All problems where
solved when org.apache.openejb javaee-api dependency rather then the javaee
javaee-api I used before.

thanks again.


Stephen Connolly-2 wrote:
> 
> 2009/11/30 sim085 :
>>
>> Wayne,
>>
>> Thank you very much for your help. I solved the problem using the first
>> link
>> you suggested. Because that thread might not be very clear I decided to
>> offer an explanation here.
>>
>> Basically the problem was because in my pom.xml file I had the following
>> parts;
>>
>> 
>>        java.net1
>>        Java.Net Maven1 Repository, hosts the javaee-api
>> dependency
>>        http://download.java.net/maven/1
>>        legacy
>> 
>> ...
>> 
>>        javaee
>>        javaee-api
>>        5
>>        provided
>> 
>>
> 
> The above artifact is a pile of cack.
> 
> You're better off using
> 
> 
> org.apache.openejb
> javaee-api
> 5.0-1
> 
> 
> or another equivalent I think geronimo has one too
>> I am not actually making use of this library from my persistence module
>> and
>> therefore I have no problem to remove it (was there by mistake when
>> splitting my project apart). I guess I might face a similar problem when
>> I
>> will unit test my ejb's, however I hope the provided link will help be
>> there
>> as well :)
>>
>> Thanks again.
>>
>>
>>
>>
>> Wayne Fay wrote:
>>>
 java.lang.ClassFormatError: Absent Code attribute in method that is not
 native or abstract in class file javax/persistence/Persistence
>>>
>>> This suggests the jar you are using as a dependency which contains
>>> javax.persistence.Persistence has an issue of some kind. I'd assume
>>> you're depending on the API jar (containing only stubs for the
>>> methods) and yet your tests need an implementation Jar to work
>>> properly.
>>>
>>> I just now Googled and found this thread:
>>> http://forums.java.net/jive/message.jspa?messageID=226931
>>> which links to this blog:
>>> http://weblogs.java.net/blog/ludo/archive/2007/01/java_ee_5_apis.html
>>> which confirms exactly what I stated above.
>>>
>>> Wayne
>>>
>>
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Problem-running-unit-tests-from-maven-%28JPA-related%29-tp26540500p26570571.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
>> For additional commands, e-mail: users-h...@maven.apache.org
>>
>>
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Problem-running-unit-tests-from-maven-%28JPA-related%29-tp26540500p26591982.html
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Problem running unit tests from maven (JPA related)

2009-11-30 Thread Stephen Connolly
2009/11/30 sim085 :
>
> Wayne,
>
> Thank you very much for your help. I solved the problem using the first link
> you suggested. Because that thread might not be very clear I decided to
> offer an explanation here.
>
> Basically the problem was because in my pom.xml file I had the following
> parts;
>
> 
>        java.net1
>        Java.Net Maven1 Repository, hosts the javaee-api 
> dependency
>        http://download.java.net/maven/1
>        legacy
> 
> ...
> 
>        javaee
>        javaee-api
>        5
>        provided
> 
>

The above artifact is a pile of cack.

You're better off using


org.apache.openejb
javaee-api
5.0-1


or another equivalent I think geronimo has one too
> I am not actually making use of this library from my persistence module and
> therefore I have no problem to remove it (was there by mistake when
> splitting my project apart). I guess I might face a similar problem when I
> will unit test my ejb's, however I hope the provided link will help be there
> as well :)
>
> Thanks again.
>
>
>
>
> Wayne Fay wrote:
>>
>>> java.lang.ClassFormatError: Absent Code attribute in method that is not
>>> native or abstract in class file javax/persistence/Persistence
>>
>> This suggests the jar you are using as a dependency which contains
>> javax.persistence.Persistence has an issue of some kind. I'd assume
>> you're depending on the API jar (containing only stubs for the
>> methods) and yet your tests need an implementation Jar to work
>> properly.
>>
>> I just now Googled and found this thread:
>> http://forums.java.net/jive/message.jspa?messageID=226931
>> which links to this blog:
>> http://weblogs.java.net/blog/ludo/archive/2007/01/java_ee_5_apis.html
>> which confirms exactly what I stated above.
>>
>> Wayne
>>
>
>
>
> --
> View this message in context: 
> http://old.nabble.com/Problem-running-unit-tests-from-maven-%28JPA-related%29-tp26540500p26570571.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Problem running unit tests from maven (JPA related)

2009-11-30 Thread sim085


mickknutson wrote:
> 
> Do you have an error trace?
> 

Problem solved :) For future reference (in case anyone else has this
problem) I am going to put the error trace here. I solved the problem using
the link provided by Wayne Fay -
http://forums.java.net/jive/message.jspa?messageID=226931


---
Test set: jpa.test.persistence.EntityTest
---
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.729 sec
<<< FAILURE!
testPersistence(jpa.test.persistence.EntityTest)  Time elapsed: 1.636 sec 
<<< ERROR!
java.lang.ClassFormatError: Absent Code attribute in method that is not
native or abstract in class file javax/persistence/Persistence
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at jpa.test.persistence.EntityTest.setUp(EntityTest.java:105)
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:597)
at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:334)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:980)



-- 
View this message in context: 
http://old.nabble.com/Problem-running-unit-tests-from-maven-%28JPA-related%29-tp26540500p26570570.html
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Problem running unit tests from maven (JPA related)

2009-11-30 Thread sim085

Wayne,

Thank you very much for your help. I solved the problem using the first link
you suggested. Because that thread might not be very clear I decided to
offer an explanation here. 

Basically the problem was because in my pom.xml file I had the following
parts; 


java.net1  
Java.Net Maven1 Repository, hosts the javaee-api 
dependency
http://download.java.net/maven/1 
legacy 
   
...
  
javaee  
javaee-api  
5  
provided  


I am not actually making use of this library from my persistence module and
therefore I have no problem to remove it (was there by mistake when
splitting my project apart). I guess I might face a similar problem when I
will unit test my ejb's, however I hope the provided link will help be there
as well :)

Thanks again.




Wayne Fay wrote:
> 
>> java.lang.ClassFormatError: Absent Code attribute in method that is not
>> native or abstract in class file javax/persistence/Persistence
> 
> This suggests the jar you are using as a dependency which contains
> javax.persistence.Persistence has an issue of some kind. I'd assume
> you're depending on the API jar (containing only stubs for the
> methods) and yet your tests need an implementation Jar to work
> properly.
> 
> I just now Googled and found this thread:
> http://forums.java.net/jive/message.jspa?messageID=226931
> which links to this blog:
> http://weblogs.java.net/blog/ludo/archive/2007/01/java_ee_5_apis.html
> which confirms exactly what I stated above.
> 
> Wayne
> 



-- 
View this message in context: 
http://old.nabble.com/Problem-running-unit-tests-from-maven-%28JPA-related%29-tp26540500p26570571.html
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Problem running unit tests from maven (JPA related)

2009-11-27 Thread Wayne Fay
> java.lang.ClassFormatError: Absent Code attribute in method that is not
> native or abstract in class file javax/persistence/Persistence

This suggests the jar you are using as a dependency which contains
javax.persistence.Persistence has an issue of some kind. I'd assume
you're depending on the API jar (containing only stubs for the
methods) and yet your tests need an implementation Jar to work
properly.

I just now Googled and found this thread:
http://forums.java.net/jive/message.jspa?messageID=226931
which links to this blog:
http://weblogs.java.net/blog/ludo/archive/2007/01/java_ee_5_apis.html
which confirms exactly what I stated above.

Wayne

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Problem running unit tests from maven (JPA related)

2009-11-27 Thread Mick Knutson
Do you have an error trace?

---
Thank You…

Mick Knutson, President

BASE Logic, Inc.
Enterprise Architecture, Design, Mentoring & Agile Consulting
p. (866) BLiNC-411: (254-6241-1)
f. (415) 685-4233

Website: http://baselogic.com
Linked IN: http://linkedin.com/in/mickknutson
Vacation Rental: http://tahoe.baselogic.com
---



On Fri, Nov 27, 2009 at 3:11 PM, sim085  wrote:

>
> Does anyone know at least where I can find more information on how maven
> run
> unit tests? I am sure it is something related to this, since when I pakcage
> the application in a jar file and run it using java -jar  the
> whole application runs without any problem!
> --
> View this message in context:
> http://old.nabble.com/Problem-running-unit-tests-from-maven-%28JPA-related%29-tp26540500p26545399.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


Re: Problem running unit tests from maven (JPA related)

2009-11-27 Thread sim085

Does anyone know at least where I can find more information on how maven run
unit tests? I am sure it is something related to this, since when I pakcage
the application in a jar file and run it using java -jar  the
whole application runs without any problem!
-- 
View this message in context: 
http://old.nabble.com/Problem-running-unit-tests-from-maven-%28JPA-related%29-tp26540500p26545399.html
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Problem running unit tests from maven (JPA related)

2009-11-27 Thread sim085

Hi,

I am trying to set some unit tests that will create a derby database in
memory and persist objects in this database using openJPA. However when I
run the test scripts from maven I get the following exception:

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

The fact is that if I move the same unit test code and run it as a normal
java application (with proper class-path set in META-INF file) then I have
no problems and the application runs as a charm (i.e. - objects are
persisted accordingly).

For a JPA application to run properly you need an xml file called
persistence.xml. I placed this file in both src\main\resources\META-INF\
directory and also in the src\test\resources\META-INF\ directory, however to
no avail! 

The fact is that the unit test only fails on the Persistence dependency
(defined in pom as dependency with scope 'test') while the Derby dependency
(used to create database) works like a charm from unit tests as well.

Does anyone have any idea what this might be?

Regards,
Simon J. 
-- 
View this message in context: 
http://old.nabble.com/Problem-running-unit-tests-from-maven-%28JPA-related%29-tp26540500p26540500.html
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org