publicissapient-france / selma

Selma Java bean mapping that compiles
http://selma-java.org
Apache License 2.0
213 stars 38 forks source link

[Question] How to setup selma in Eclipse #175

Open SergioArrighi opened 7 years ago

SergioArrighi commented 7 years ago

Hello,

I've been trying to set up a maven project with Selma test.zip

I followed all steps: 1) Added deps 2) Turned on annotation processing 3) Tried to turn on factories

If I run mvn clean install I get the mapper class generated in the jar. But if I build in eclipse and run the JUnit I have class not found exception for the mapper java.lang.IllegalArgumentException: Unable to load generated mapper class com.amadeus.ISelmaTestSelmaGeneratedClass failed : com.amadeus.ISelmaTestSelmaGeneratedClass at fr.xebia.extras.selma.Selma.getMapper(Selma.java:240) at fr.xebia.extras.selma.Selma.access$100(Selma.java:55) at fr.xebia.extras.selma.Selma$MapperBuilder.build(Selma.java:315) at com.amadeus.test.AppTest.testApp(AppTest.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) 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 org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: java.lang.ClassNotFoundException: com.amadeus.ISelmaTestSelmaGeneratedClass at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at fr.xebia.extras.selma.Selma.getMapper(Selma.java:166) ... 19 more

Also, no files are generated in the generated-sources folder. I really don't know what I'm doing wrong. I tried both in eclipse neon and mars with no luck. Mars installation was fresh capture

Would be awesome if you guys could advice me on what I'm doing wrong.

Thanks in advance and best regards!

digitalillusion commented 7 years ago

Hi Sergio. Looking at org.eclipse.jdt.core.prefs in your test project I can see that you are using jdk 1.5 As you may know, direct support for annotation processing was added in 1.6 I see no other solution if not to configure an ant task to run annotation preprocessor before junit tests in case you really need to stick to such an old jdk, but I suggest to use 1.6 or higher instead