jbosstools / m2e-apt

Maven integration with Eclipse JDT Annotation Processor Toolkit
39 stars 19 forks source link

ClassCastException #19

Open kabir opened 11 years ago

kabir commented 11 years ago

Hi,

I'm trying to use this with https://github.com/jbossas/jboss-as in Eclipse 4.2.1 on OS X Lion . When building the project I get:

Description Resource Path Location Type Internal compiler error: java.lang.ClassCastException: com.sun.istack.internal.ws.AnnotationProcessorFactoryImpl cannot be cast to com.sun.mirror.apt.AnnotationProcessorFactory at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.loadJava5FactoryClasses(AnnotationProcessorFactoryLoader.java:566) JGroupsLogger_$logger.java /jboss-as-clustering-jgroups/target/generated-sources/annotations/org/jboss/as/clustering/jgroups line 0 Java Problem

(We use annotation processing to create the internationalized logger classes). The class it is trying to generate would be based on clustering/jgroups/src/main/java/org/jboss/as/clustering/jgroups/JGroupsLogger.java.

$java -version java version "1.6.0_37" Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909) Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

I enabled the "Automatically Configure JDT..." for all projects in Eclipse/Preferences. Not doing that and enabling it for individual projects works, although I have not tried enabling it for the project causing the error.

fbricon commented 11 years ago

Can you reproduce the issue in a clean workspace, only importing the offending project, or the whole clustering module?

kabir commented 11 years ago

Yes,

Here are the steps 1) Clone a fresh copy of jboss-as 2) Open a new Eclipse workspace 3) Enable Eclipse/Preferences/Maven/Annotation Processing/Automatically configure JDT... 4) Import jboss-as/clustering

I get

Description Resource Path Location Type The project cannot be built until its prerequisite jboss-as-clustering-service is built. Cleaning and building all projects is recommended jboss-as-clustering-singleton Unknown Java Problem The project cannot be built until its prerequisite jboss-as-clustering-infinispan is built. Cleaning and building all projects is recommended jboss-as-clustering-impl Unknown Java Problem The project cannot be built until its prerequisite jboss-as-clustering-api is built. Cleaning and building all projects is recommended jboss-as-clustering-infinispan Unknown Java Problem The project cannot be built until its prerequisite jboss-as-clustering-common is built. Cleaning and building all projects is recommended jboss-as-clustering-jgroups Unknown Java Problem Internal compiler error: java.lang.ClassCastException: com.sun.istack.internal.ws.AnnotationProcessorFactoryImpl cannot be cast to com.sun.mirror.apt.AnnotationProcessorFactory at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.loadJava5FactoryClasses(AnnotationProcessorFactoryLoader.java:566) ManagedExecutorServiceTest.java /jboss-as-clustering-common/src/test/java/org/jboss/as/clustering/concurrent line 0 Java Problem Internal compiler error: java.lang.ClassCastException: com.sun.istack.internal.ws.AnnotationProcessorFactoryImpl cannot be cast to com.sun.mirror.apt.AnnotationProcessorFactory at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.loadJava5FactoryClasses(AnnotationProcessorFactoryLoader.java:566) HashableMarshalledValueFactoryTestCase.java /jboss-as-clustering-api/src/test/java/org/jboss/as/clustering line 0 Java Problem The project cannot be built until its prerequisite jboss-as-clustering-common is built. Cleaning and building all projects is recommended jboss-as-clustering-registry Unknown Java Problem The project cannot be built until its prerequisite jboss-as-clustering-infinispan is built. Cleaning and building all projects is recommended jboss-as-clustering-ejb3-infinispan Unknown Java Problem The project cannot be built until its prerequisite jboss-as-clustering-impl is built. Cleaning and building all projects is recommended jboss-as-clustering-web-infinispan Unknown Java Problem The project cannot be built until its prerequisite jboss-as-clustering-impl is built. Cleaning and building all projects is recommended jboss-as-clustering-service Unknown Java Problem The project cannot be built until its prerequisite jboss-as-clustering-api is built. Cleaning and building all projects is recommended jboss-as-clustering-web-spi Unknown Java Problem

fbricon commented 11 years ago

So far I've been unable to reproduce the problem on win7 64 (eclipse running with JDK 1.7.0_10, project built with JDK 1.6.0_37), using JBDS 6.0.0 (based off eclipse 4.2.1). I'll try on a linux vm tomorrow. Will need someone else to test OSX.

chinshaw commented 11 years ago

I was able to resolve this issue by disabling, validation through Preferences -> Maven -> AnnotationProcessing, then manually removing the .factorypath file from command line. Refresh the project and re enable validation processing in the project preferences. I have a suspicion that the problem was due to adding a dependency for apiviz which forced me initially to add a system dependency on the java classes.jar file. Just a hunch though

<factorypathentry kind="EXTJAR" id="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/classes.jar" enabled="true" runInBatchMode="false"/>
mickaelistria commented 2 years ago

m2e-apt's code is now included in https://github.com/eclipse-m2e/m2e-core , please consider reporting issue to https://github.com/eclipse-m2e/m2e-core/issues if it's still relevant.