Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 358870

Summary: Annotation Properties view causes IllegalArgumentException when quickly setting annotations
Product: [WebTools] WTP Webservices Reporter: Danail Branekov <danail.branekov>
Component: jst.ws.jaxwsAssignee: Shane Clarke <shane_clarke>
Status: RESOLVED FIXED QA Contact: Shane Clarke <shane_clarke>
Severity: normal    
Priority: P3    
Version: 3.2.4   
Target Milestone: 3.4 M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Flash movie demonstrating the issue (part1)
none
Flash movie demonstrating the issue (part2)
none
Movie demonstrating the error
none
Sample project none

Description Danail Branekov CLA 2011-09-26 07:16:13 EDT
An IllegalArgumentException occurs when the user quickly enables JAX-WS annotations for a java class. As a result the source code, especially its import statements, get quite messy and the code cannot be compiled.

I am attaching a flash video which demonstrates the issue.
Do note that the exception occurs in most of the cases but not always.
Here is the exception stack trace:

java.lang.IllegalArgumentException: Document does not match the AST
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.handleException(ASTRewriteAnalyzer.java:3583)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1729)
	at org.eclipse.jdt.core.dom.ReturnStatement.accept0(ReturnStatement.java:134)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisit(ASTRewriteAnalyzer.java:350)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisitList(ASTRewriteAnalyzer.java:388)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisit(ASTRewriteAnalyzer.java:382)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisitUnchangedChildren(ASTRewriteAnalyzer.java:395)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1700)
	at org.eclipse.jdt.core.dom.Block.accept0(Block.java:134)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisit(ASTRewriteAnalyzer.java:374)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisit(ASTRewriteAnalyzer.java:380)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisitUnchangedChildren(ASTRewriteAnalyzer.java:395)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1644)
	at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:489)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisit(ASTRewriteAnalyzer.java:350)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisitList(ASTRewriteAnalyzer.java:368)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisit(ASTRewriteAnalyzer.java:359)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.rewriteParagraphList(ASTRewriteAnalyzer.java:1003)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1606)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:467)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
	at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.internalRewriteAST(ASTRewrite.java:271)
	at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.rewriteAST(ASTRewrite.java:260)
	at org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils.createAddAnnotationTextEdit(AnnotationUtils.java:538)
	at org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils.createAddAnnotationTextEdit(AnnotationUtils.java:418)
	at org.eclipse.jst.ws.internal.jaxws.ui.views.AnnotationsValuesEditingSupport.setValueForClass(AnnotationsValuesEditingSupport.java:391)
	at org.eclipse.jst.ws.internal.jaxws.ui.views.AnnotationsValuesEditingSupport.setValueForClass(AnnotationsValuesEditingSupport.java:337)
	at org.eclipse.jst.ws.internal.jaxws.ui.views.AnnotationsValuesEditingSupport.setValue(AnnotationsValuesEditingSupport.java:318)
	at org.eclipse.jface.viewers.EditingSupport.saveCellEditorValue(EditingSupport.java:113)
	at org.eclipse.jface.viewers.ColumnViewerEditor.saveEditorValue(ColumnViewerEditor.java:455)
	at org.eclipse.jface.viewers.ColumnViewerEditor.applyEditorValue(ColumnViewerEditor.java:311)
	at org.eclipse.jface.viewers.ColumnViewerEditor$2.applyEditorValue(ColumnViewerEditor.java:153)
	at org.eclipse.jface.viewers.CellEditor$1.run(CellEditor.java:333)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.CellEditor.fireApplyEditorValue(CellEditor.java:331)
	at org.eclipse.jface.viewers.CheckboxCellEditor.activate(CheckboxCellEditor.java:85)
	at org.eclipse.jface.viewers.CellEditor.activate(CellEditor.java:899)
	at org.eclipse.jface.viewers.CheckboxCellEditor.activate(CheckboxCellEditor.java:129)
	at org.eclipse.jface.viewers.ColumnViewerEditor.activateCellEditor(ColumnViewerEditor.java:203)
	at org.eclipse.jface.viewers.ColumnViewerEditor.handleEditorActivationEvent(ColumnViewerEditor.java:444)
	at org.eclipse.jface.viewers.ColumnViewer.triggerEditorActivationEvent(ColumnViewer.java:680)
	at org.eclipse.jface.viewers.ColumnViewer.handleMouseDown(ColumnViewer.java:664)
	at org.eclipse.jface.viewers.ColumnViewer.access$0(ColumnViewer.java:660)
	at org.eclipse.jface.viewers.ColumnViewer$1.mouseDown(ColumnViewer.java:89)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:185)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
Caused by: org.eclipse.core.runtime.CoreException: Invalid_Char_In_String
	at org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner.readNext(TokenScanner.java:95)
	at org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner.readToToken(TokenScanner.java:149)
	at org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner.readToToken(TokenScanner.java:162)
	at org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner.getTokenEndOffset(TokenScanner.java:187)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1719)
	... 73 more
Caused by: org.eclipse.jdt.core.compiler.InvalidInputException: Invalid_Char_In_String
	at org.eclipse.jdt.internal.compiler.parser.Scanner.getNextToken(Scanner.java:1421)
	at org.eclipse.jdt.internal.compiler.parser.RecoveryScanner.getNextToken(RecoveryScanner.java:176)
	at org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner.readNext(TokenScanner.java:90)
	... 77 more


I suspect that the cause of this issue is that the code modification operation runs without a scheduling rule which allows paralel conflicting modification operations
Comment 1 Danail Branekov CLA 2011-09-26 07:18:59 EDT
Created attachment 204002 [details]
Flash movie demonstrating the issue (part1)
Comment 2 Danail Branekov CLA 2011-09-26 07:19:20 EDT
Created attachment 204003 [details]
Flash movie demonstrating the issue (part2)
Comment 3 Danail Branekov CLA 2011-09-30 04:10:19 EDT
I just figured out that I can only reproduce the bug in case the annotation processing is turned on. I am not sure whether this is releated to the bug, or annotation processing simply slows down resource change event handling thus helping raising the exception
Comment 4 Shane Clarke CLA 2011-10-11 16:55:39 EDT
Hi Danail, i've tried to reproduce following your description but have so far been unable to do so.

I'm also unable to play the attached flash movie. Could you try downloading the attachments, unraring them and see if you have any problem with the extracted swf movie?
Comment 5 Danail Branekov CLA 2011-10-12 04:27:39 EDT
H Shane,

I had hard time reproducing this today either. As the issue seems to have something to do with asynchronous event processing, you would probably need a project with a larger content. I am attaching such a project for reference.

I have also managed to record a WMV movie which is much smaller - also attached. In the movie I am creating a new web project, generate an endpoint bean and start modifying an endpoint (WeatherSoapImpl) annotations via the view

Regards, Danail
Comment 6 Danail Branekov CLA 2011-10-12 04:28:22 EDT
Created attachment 205001 [details]
Movie demonstrating the error
Comment 7 Danail Branekov CLA 2011-10-12 04:28:49 EDT
Created attachment 205002 [details]
Sample project
Comment 8 Shane Clarke CLA 2011-10-12 17:55:32 EDT
I was able play the wmv and recreate the problem using the wsdl file in the attached project.

There's an error thrown when the annotation processing is enabled for the wsdl location rule trying to read the wsdl file at http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl which it's unable to do:

javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing '- WSDL Document -'.: org.xml.sax.SAXParseException: The element type "br" must be terminated by the matching end-tag "</br>".
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at org.eclipse.jst.ws.jaxws.core.utils.WSDLUtils.readWSDL(WSDLUtils.java:96)
at org.eclipse.jst.ws.internal.jaxws.core.annotations.validation.WebServiceWSDLLocationRule.validateWSDL(WebServiceWSDLLocationRule.java:130)
at org.eclipse.jst.ws.internal.jaxws.core.annotations.validation.WebServiceWSDLLocationRule.checkWSDLocation(WebServiceWSDLLocationRule.java:97)
at org.eclipse.jst.ws.internal.jaxws.core.annotations.validation.WebServiceWSDLLocationRule.process(WebServiceWSDLLocationRule.java:77)
at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:83)
at org.eclipse.jdt.apt.core.internal.APTDispatchRunnable.dispatchToFileBasedProcessor(APTDispatchRunnable.java:655)
at org.eclipse.jdt.apt.core.internal.APTDispatchRunnable.runAPTInFileBasedMode(APTDispatchRunnable.java:344)
at org.eclipse.jdt.apt.core.internal.APTDispatchRunnable.build(APTDispatchRunnable.java:682)
at org.eclipse.jdt.apt.core.internal.APTDispatchRunnable.access$1(APTDispatchRunnable.java:674)
at org.eclipse.jdt.apt.core.internal.APTDispatchRunnable$1.run(APTDispatchRunnable.java:273)
at org.eclipse.jdt.apt.core.internal.env.BuildEnv$CallbackRequestor.acceptBinding(BuildEnv.java:611)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:925)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:577)
at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:888)
at org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv.createASTs(BaseProcessorEnv.java:859)
at org.eclipse.jdt.apt.core.internal.env.BuildEnv.createASTs(BuildEnv.java:356)
at org.eclipse.jdt.apt.core.internal.env.AbstractCompilationEnv.newBuildEnv(AbstractCompilationEnv.java:111)
at org.eclipse.jdt.apt.core.internal.APTDispatchRunnable.build(APTDispatchRunnable.java:283)
at org.eclipse.jdt.apt.core.internal.APTDispatchRunnable.run(APTDispatchRunnable.java:225)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.jdt.apt.core.internal.APTDispatchRunnable.runAPTDuringBuild(APTDispatchRunnable.java:150)
at org.eclipse.jdt.apt.core.internal.AptCompilationParticipant.processAnnotations(AptCompilationParticipant.java:193)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.processAnnotations(AbstractImageBuilder.java:627)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:338)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:134)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:265)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:193)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.xml.sax.SAXParseException: The element type "br" must be terminated by the matching end-tag "</br>".
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
... 41 more

With that rule removed but annotation processing still enabled i was unable to reproduce the first error.
Comment 9 Shane Clarke CLA 2012-04-15 13:56:44 EDT
Danail I found that the changes i made to fix Bug #371936 has also resolved this issue.

With those changes reverted i can reproduce the problem in a runtime workspace. Reapply the fix and can't reproduce.

I also made a further change to the wsdl location rule to print a warning in the above case when it's unable to locate the wsdl file at the given wsdlLocation: http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl 

Marking as resolved.
Comment 10 Shane Clarke CLA 2012-04-17 06:45:48 EDT
Reopening as the new warning message is causing a test failure at:

junit.framework.AssertionFailedError: Markers unexpectedly found expected:<0> but was:<1> 
	at org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.validation.ValidationTestsSetUp.assertNoValidationErrors(ValidationTestsSetUp.java:250) 
	at org.eclipse.jst.ws.jaxws.dom.runtime.tests.dom.validation.WsValidationTest.testWsdlLocationInWebInfCorrect(WsValidationTest.java:139)

The rule is unable to read the WSDL file because the file has no content.

Couple of ways to fix this. Use a wsdl file with valid content in the test or ignore markers with a serverity of warning in ValidationTestsSetUp.assertNoValidationErrors

Danail, what you think?
Comment 11 Danail Branekov CLA 2012-04-17 07:55:24 EDT
Hi Shane,

I think that using a valid WSDL content seems to be the right way - the test verifies that there are no issues reported when everything is OK. 
Ignoring warnings in the the assertNoValidationErrors method might have side effects which could hide potential future regressions.

As you have introduced a new validation check, I would recommend providing new tests to verify that proper warnings are reported in case the WSDL is not accessible or is empty. See method ValidationTestsSetUp.validateResourceMarkers(IResource, MarkerData...) usages for examples on how a test can specify markers expectations

Regards, Danail
Comment 12 Shane Clarke CLA 2012-04-18 03:39:53 EDT
Current test updated to run with valid wsdl content and new tests added.