]
Max Rydahl Andersen commented on LOGTOOL-51:
--------------------------------------------
ah sorry - did not realize it had its own project :)
Logging generation processing breaks APT rules by loading classes via
reflection
--------------------------------------------------------------------------------
Key: LOGTOOL-51
URL:
https://issues.jboss.org/browse/LOGTOOL-51
Project: Log Tool
Issue Type: Bug
Security Level: Public(Everyone can see)
Environment: JBDS 5.5.0.CR1
Reporter: Fred Bricon
Assignee: David Lloyd
Priority: Blocker
JBDS 5.5.0.CR1 embeds [
m2e-apt|https://github.com/jbosstools/m2e-apt], which
automatically enables Eclipse JDT Annotation Processor Toolkit.
When importing the [
server|https://github.com/jbossas/jboss-as/tree/master/server] module
from
http://github.com/jbossas/jboss-as.git (also happens for other modules), Eclipse
starts crashing (see JBIDE-12087) with errors like :
{noformat}
javax.xml.parsers.FactoryConfigurationError: Provider
__redirected.__DocumentBuilderFactory not found
at
javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:127)
at
org.eclipse.jdt.apt.core.internal.util.FactoryPathUtil.decodeFactoryPath(FactoryPathUtil.java:222)
at
org.eclipse.jdt.apt.core.internal.util.FactoryPathUtil.readFactoryPathFile(FactoryPathUtil.java:115)
at
org.eclipse.jdt.apt.core.internal.util.FactoryPathUtil.calculatePath(FactoryPathUtil.java:342)
at
org.eclipse.jdt.apt.core.internal.util.FactoryPathUtil.getFactoryPath(FactoryPathUtil.java:429)
at
org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.getJava6FactoriesAndAttributesForProject(AnnotationProcessorFactoryLoader.java:420)
at
org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:130)
at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:813)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:432)
at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:364)
at
org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:178)
at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:301)
at
org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:60)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:254)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:173)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.ClassNotFoundException: __redirected/__DocumentBuilderFactory
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:119)
at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:144)
at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:185)
at
javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:121)
{noformat}
It turns out the Eclipse System Properties have been changed to use
javax.xml.parsers.SAXParserFactory=__redirected/__DocumentBuilderFactory
I tracked the code responsible with messing with the properties :
{noformat}
Thread [Worker-24] (Suspended (breakpoint at line 779 in System))
System.setProperty(String, String) line: 779
__SAXParserFactory.<clinit>() line: 68
__JAXPRedirected.initAll() line: 80
Module$1.run() line: 126
Module$1.run() line: 113
AccessController.doPrivileged(PrivilegedAction<T>) line: not available [native
method]
Module.<clinit>() line: 113
Class<T>.forName0(String, boolean, ClassLoader) line: not available [native
method]
Class<T>.forName(String) line: 186 <====== org.jboss.modules.Module
JCodeModel.ref(String) line: 363
MessageBundleImplementor(ImplementationClassModel).createBundleMethod(MessageMethod,
JMethod, JMethod, JVar) line: 150
MessageBundleImplementor.generateModel() line: 86
MessageBundleImplementor(ClassModel).create(JavaFileObject) line: 104
ImplementationClassGenerator.processTypeElement(TypeElement, TypeElement,
MessageInterface) line: 63
LoggingToolsProcessor.process(Set<TypeElement>, RoundEnvironment) line: 155
RoundDispatcher.handleProcessor(ProcessorInfo) line: 139
RoundDispatcher.round() line: 121
IdeAnnotationProcessorManager(BaseAnnotationProcessorManager).processAnnotations(CompilationUnitDeclaration[],
ReferenceBinding[], boolean) line: 159
IdeAnnotationProcessorManager.processAnnotations(CompilationUnitDeclaration[],
ReferenceBinding[], boolean) line: 134
Compiler.processAnnotations() line: 813
Compiler.compile(ICompilationUnit[]) line: 432
BatchImageBuilder(AbstractImageBuilder).compile(SourceFile[], SourceFile[], boolean)
line: 364
BatchImageBuilder.compile(SourceFile[], SourceFile[], boolean) line: 178
BatchImageBuilder(AbstractImageBuilder).compile(SourceFile[]) line: 301
BatchImageBuilder.build() line: 60
JavaBuilder.buildAll() line: 254
JavaBuilder.build(int, Map, IProgressMonitor) line: 173
BuildManager$2.run() line: 728
SafeRunner.run(ISafeRunnable) line: 42
BuildManager.basicBuild(int, IncrementalProjectBuilder, Map<String,String>,
MultiStatus, IProgressMonitor) line: 199
BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, ICommand[], MultiStatus,
IProgressMonitor) line: 239
BuildManager$1.run() line: 292
SafeRunner.run(ISafeRunnable) line: 42
BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, MultiStatus,
IProgressMonitor) line: 295
BuildManager.basicBuildLoop(IBuildConfiguration[], IBuildConfiguration[], int,
MultiStatus, IProgressMonitor) line: 351
BuildManager.build(IBuildConfiguration[], IBuildConfiguration[], int, IProgressMonitor)
line: 374
AutoBuildJob.doBuild(IProgressMonitor) line: 143
AutoBuildJob.run(IProgressMonitor) line: 241
Worker.run() line: 54
{noformat}
That stacktrace represents the processing of
https://github.com/jbossas/jboss-as/blob/master/server/src/main/java/org/...
So basically, whenever a Logger has a dependency to the
[
org.jboss.modules.Module|https://github.com/jbossas/jboss-modules/blob/ma...]
class, stuff starts hitting the fan.
Classes should not be loaded by reflection during APT processing to avoid such issues -
it should use the API provided by APT to iterate over the classes metadata provided by the
compiler and not depend on com.sun.*.internal classes.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: