This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 435540 - Using Eclipse Luna RC2 candidate creation of xdoclet session bean fails
Summary: Using Eclipse Luna RC2 candidate creation of xdoclet session bean fails
Status: RESOLVED FIXED
Alias: None
Product: WTP EJB Tools
Classification: WebTools
Component: jst.ejb (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: jst.ejb CLA
QA Contact: Kaloyan Raev CLA
URL:
Whiteboard:
Keywords:
Depends on: 435571
Blocks:
  Show dependency tree
 
Reported: 2014-05-22 12:30 EDT by Dimitar Giormov CLA
Modified: 2014-06-12 04:29 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitar Giormov CLA 2014-05-22 12:30:11 EDT
Steps to reproduce:

1. Install a J2EE 1.4-compatible server, such as JOnAS, JBoss or WebSphere
2. Add the server in Window -> Preferences -> Server -> Runtime Environments
3. Install the XDoclet support (1.2.1, 1.2.2 or 1.2.3)
4. Add the XDoclet support in Window -> Preferences -> Java EE -> XDoclet
5. Expand the XDoclet node and configure the ejbdoclet and webdoclet support for your installed server(s). 

6. Create an EJB 2.1 project
6.1. Target it at the installed J2EE server
6.2. Choose "EJB Project with XDoclet" from Configurations
6.3. Choose "Add project to an EAR" and choose the previously created EAR project
6.4. Create a new XDoclet Enterprise JavaBean
        choose Session Bean as a type
        enter "test" for Java package 


Result:
Bean file has no content at all.

Exception in error log:

eclipse.buildId=4.4.0.I20140515-1230
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64

org.eclipse.jst.j2ee.ejb.annotation.model
Error
Thu May 22 19:26:03 EEST 2014
Operation only supported in JLS8 and later AST

java.lang.UnsupportedOperationException: Operation only supported in JLS8 and later AST
	at org.eclipse.jdt.core.dom.ASTNode.unsupportedIn2_3_4(ASTNode.java:1968)
	at org.eclipse.jdt.core.dom.AnnotatableType.annotations(AnnotatableType.java:99)
	at org.eclipse.jdt.internal.corext.codemanipulation.ImportReferencesCollector.visit(ImportReferencesCollector.java:203)
	at org.eclipse.jdt.core.dom.SimpleType.accept0(SimpleType.java:197)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:469)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:212)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
	at org.eclipse.jdt.internal.corext.codemanipulation.ImportReferencesCollector.collect(ImportReferencesCollector.java:68)
	at org.eclipse.jdt.internal.corext.codemanipulation.ImportReferencesCollector.collect(ImportReferencesCollector.java:62)
	at org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext.getImportedNames(ContextSensitiveImportRewriteContext.java:226)
	at org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext.findInContext(ContextSensitiveImportRewriteContext.java:99)
	at org.eclipse.jdt.core.dom.rewrite.ImportRewrite.internalAddImport(ImportRewrite.java:941)
	at org.eclipse.jdt.core.dom.rewrite.ImportRewrite.addImport(ImportRewrite.java:639)
	at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.createThrownExceptions(StubUtility2.java:509)
	at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.createImplementationStub(StubUtility2.java:349)
	at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.createImplementationStub(StubUtility2.java:315)
	at org.eclipse.jdt.internal.corext.codemanipulation.AddUnimplementedMethodsOperation.run(AddUnimplementedMethodsOperation.java:213)
	at org.eclipse.jst.j2ee.ejb.annotations.internal.classgen.EjbBuilder.createInheritedMethods(EjbBuilder.java:221)
	at org.eclipse.jst.j2ee.ejb.annotations.internal.classgen.EjbBuilder.createType(EjbBuilder.java:144)
	at org.eclipse.jst.j2ee.ejb.annotations.internal.xdoclet.provider.XDocletAnnotationProvider.generateSession(XDocletAnnotationProvider.java:130)
	at org.eclipse.jst.j2ee.ejb.annotation.internal.operations.AddSessionBeanOperation.execute(AddSessionBeanOperation.java:39)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(DataModelPausibleOperationImpl.java:385)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:410)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:360)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(DataModelPausibleOperationImpl.java:247)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.executeImpl(DataModelPausibleOperationImpl.java:219)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.cacheThreadAndContinue(DataModelPausibleOperationImpl.java:89)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.execute(DataModelPausibleOperationImpl.java:207)
	at org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard$1CatchThrowableRunnableWithProgress.run(DataModelWizard.java:220)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Comment 1 Chuck Bridgham CLA 2014-05-22 13:35:14 EDT
Hi Dimitar - was this a recent regression?  I must admit - I don't test the xdoclet very often.
Comment 2 Roberto Sanchez Herrera CLA 2014-05-22 13:41:15 EDT
It would be good to see if this scenario worked in Luna RC1. I tracked some of the code in JDT, and all the changes I saw are from early 2013.
Comment 3 Dani Megert CLA 2014-05-22 15:30:15 EDT
How do you create the AST that you pass into AddUnimplementedMethodsOperation? If you use AST.JLS<something> then you should replace it with AST.JLS8 (in all your code), even if the problem might be a bug in JDT Core (will have to investigate).
Comment 4 Dani Megert CLA 2014-05-22 17:18:34 EDT
It really looks like a bug in JDT Core. Please wait for further instructions.
Comment 5 Markus Keller CLA 2014-05-22 17:45:03 EDT
The bug is actually in JDT UI.

org.eclipse.jdt.ui.actions.OverrideMethodsAction#createRunnable(..) is a legal way to create an AddUnimplementedMethodsOperation, and there's no restriction on the AST level there. Most of JDT UI only uses the latest AST level, but in this case, we have to support older levels as well.

I've opened bug 435571 as a blocker of this bug. JDT UI will provide a fix in 4.4 RC3.

Nevertheless, it would be advisable for WTP to switch to AST.JLS8, since you won't see Java 8 features in older levels, and rewrites of Java 8 code will likely be invalid.
Comment 6 Markus Keller CLA 2014-05-22 18:38:08 EDT
(In reply to Roberto Sanchez Herrera from comment #2)
> It would be good to see if this scenario worked in Luna RC1.

The git history may be hard to understand since we merged branch BETA_JAVA8 into master between Eclipse SDK 4.4 M6 and M7. The problematic code in ImportReferencesCollector was first published in an official milestone in 4.4 M7 aka Luna RC0.

I've attached a patch to bug 435571. Feedback on that would be very welcome.
Comment 7 Dimitar Giormov CLA 2014-05-23 02:42:28 EDT
(In reply to Chuck Bridgham from comment #1)
> Hi Dimitar - was this a recent regression?  I must admit - I don't test the
> xdoclet very often.

I am not sure when exactly, the last I have tested I had to use Eclipse SDK M6, since the current one had some test failures.
Comment 8 Markus Keller CLA 2014-05-23 07:50:59 EDT
(In reply to Markus Keller from comment #5)
> Nevertheless, it would be advisable for WTP to switch to AST.JLS8, since you
> won't see Java 8 features in older levels, and rewrites of Java 8 code will
> likely be invalid.

Just to clarify: For Luna, it's probably too late to switch WTP to JLS8. By switching to JLS8, the ASTs will contain new kinds of ASTNodes, and deprecated APIs of concrete ASTNode classes will throw exceptions.

E.g. calls to ArrayType#get/setComponentType(..) only work in JLS4 and earlier, but need to be replaced with ArrayType#get/setElementType(..) and ArrayType#dimensions() in JLS8 and later.
Comment 9 Markus Keller CLA 2014-06-02 10:19:36 EDT
Please verify the fix for bug 435571 in
http://download.eclipse.org/eclipse/downloads/drops4/S-4.4RC3-201405282000/

The final Eclipse SDK build is this Wednesday, so any follow-up problems would have to be reported and fixed right away.
Comment 10 Dimitar Giormov CLA 2014-06-12 04:29:13 EDT
Yep, the fix works
Thanks