anjlab / eclipse-tapestry5-plugin

Eclipse Plugin for Tapestry5
Apache License 2.0
21 stars 9 forks source link

NullPointer in AssetReference when opening a source file #21

Closed kaosko closed 9 years ago

kaosko commented 9 years ago

I'm regularly getting a NullPointerException just when I open a .java file for a page in Tapestry5 project. Things still seem to work fine after the initial exception. It seems that this started happening when I updated this plugin or some of the underlying components to a new version. I'm using Luna Service Release 1 (4.4.1), "Tapestry5 Support" version 2.6.3 (basic + additional for Eclipse4) and many other plugins.

!ENTRY org.eclipse.core.jobs 4 2 2015-01-19 08:40:24.797
!MESSAGE An internal error occurred during: "Eclipse Integration for Tapestry5".
!STACK 0
java.lang.NullPointerException
    at com.anjlab.eclipse.tapestry5.AssetReference.<init>(AssetReference.java:13)
    at com.anjlab.eclipse.tapestry5.TapestryContext.processImportedFile(TapestryContext.java:298)
    at com.anjlab.eclipse.tapestry5.TapestryContext.processImport(TapestryContext.java:266)
    at com.anjlab.eclipse.tapestry5.TapestryContext.access$1(TapestryContext.java:260)
    at com.anjlab.eclipse.tapestry5.TapestryContext$3.run(TapestryContext.java:246)
    at com.anjlab.eclipse.tapestry5.TapestryContext.analyzeCompilationUnit(TapestryContext.java:156)
    at com.anjlab.eclipse.tapestry5.TapestryContext.addImports(TapestryContext.java:224)
    at com.anjlab.eclipse.tapestry5.TapestryContext.analyzeCompilationUnit(TapestryContext.java:138)
    at com.anjlab.eclipse.tapestry5.TapestryContext.initFromJavaOrTemplateFile(TapestryContext.java:419)
    at com.anjlab.eclipse.tapestry5.TapestryContext.initFromFile(TapestryContext.java:120)
    at com.anjlab.eclipse.tapestry5.LocalTapestryContext.<init>(LocalTapestryContext.java:32)
    at com.anjlab.eclipse.tapestry5.TapestryUtils.createTapestryContext(TapestryUtils.java:229)
    at com.anjlab.eclipse.tapestry5.TapestryModule$6.callback(TapestryModule.java:769)
    at com.anjlab.eclipse.tapestry5.LocalTapestryModule.enumJavaClassesRecursively(LocalTapestryModule.java:89)
    at com.anjlab.eclipse.tapestry5.LocalTapestryModule.enumJavaClassesRecursively(LocalTapestryModule.java:65)
    at com.anjlab.eclipse.tapestry5.TapestryModule.enumJavaClassesRecursively(TapestryModule.java:753)
    at com.anjlab.eclipse.tapestry5.TapestryModule.findComponents(TapestryModule.java:739)
    at com.anjlab.eclipse.tapestry5.TapestryModule.initialize(TapestryModule.java:133)
    at com.anjlab.eclipse.tapestry5.TapestryProject.addModule(TapestryProject.java:410)
    at com.anjlab.eclipse.tapestry5.TapestryProject.addModule(TapestryProject.java:387)
    at com.anjlab.eclipse.tapestry5.TapestryProject.findModules(TapestryProject.java:274)
    at com.anjlab.eclipse.tapestry5.TapestryProject.initialize(TapestryProject.java:121)
    at com.anjlab.eclipse.tapestry5.watchdog.TapestryProjectWatchdog$TapestryProjectAnalyzerJob.run(TapestryProjectWatchdog.java:85)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
dmitrygusev commented 9 years ago

Please try updating to latest version (it's 2.7.5 currently), I've added more logging to this release to help you identify failing page/component class.

From what I see there's a problem parsing the @Import annotation. Could you paste it here?

kaosko commented 9 years ago

Will do, but my Eclipse didn't find any updates - is the update is still at https://dl.bintray.com/anjlab/eclipse-tapestry5-plugin?

dmitrygusev commented 9 years ago

Yep, try restarting Eclipse?

version-2 7 5

kaosko commented 9 years ago

Ok, so you must have just updated it because I scanned for a new update in the morning. Not sure if this helps, but with 2.7.5, I get:

!ENTRY org.eclipse.core.resources 4 2 2015-01-19 23:14:57.433
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
!STACK 0
java.lang.RuntimeException: Error creating context from L/xxx/yyy/zzz/Xxx.java
    at com.anjlab.eclipse.tapestry5.TapestryUtils.createTapestryContext(TapestryUtils.java:225)
    at com.anjlab.eclipse.tapestry5.watchdog.TapestryProjectWatchdog$2.resourceChanged(TapestryProjectWatchdog.java:247)
    at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:291)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:285)
    at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:149)
    at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:378)
    at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1498)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2322)
    at org.eclipse.mylyn.internal.java.ui.LandmarkMarkerManager$LandmarkUpdateJob.run(LandmarkMarkerManager.java:259)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
    at com.anjlab.eclipse.tapestry5.AssetReference.<init>(AssetReference.java:13)
    at com.anjlab.eclipse.tapestry5.TapestryContext.processImportedFile(TapestryContext.java:298)
    at com.anjlab.eclipse.tapestry5.TapestryContext.processImport(TapestryContext.java:266)
    at com.anjlab.eclipse.tapestry5.TapestryContext.access$1(TapestryContext.java:260)
    at com.anjlab.eclipse.tapestry5.TapestryContext$3.run(TapestryContext.java:246)
    at com.anjlab.eclipse.tapestry5.TapestryContext.analyzeCompilationUnit(TapestryContext.java:156)
    at com.anjlab.eclipse.tapestry5.TapestryContext.addImports(TapestryContext.java:224)
    at com.anjlab.eclipse.tapestry5.TapestryContext.analyzeCompilationUnit(TapestryContext.java:138)
    at com.anjlab.eclipse.tapestry5.TapestryContext.initFromJavaOrTemplateFile(TapestryContext.java:419)
    at com.anjlab.eclipse.tapestry5.TapestryContext.initFromFile(TapestryContext.java:120)
    at com.anjlab.eclipse.tapestry5.LocalTapestryContext.<init>(LocalTapestryContext.java:32)
    at com.anjlab.eclipse.tapestry5.TapestryUtils.createTapestryContext(TapestryUtils.java:221)
    ... 10 more

I'm starting to think perhaps there's some damaged library in my Eclipse installation that causes this.

dmitrygusev commented 9 years ago

Could you paste source code of the @Import annotation that's declared in /xxx/yyy/zzz/Xxx.java?

dmitrygusev commented 9 years ago

I need this bit:

@org.apache.tapestry5.annotations.Import(
        stylesheet = "index.css")
public class Index
kaosko commented 9 years ago

It happens on opening any Java class. Anyhow, figured it out, the issue is an incompatibility with JRE 1.8. I'm running Eclipse on Java 8 and saw this in the log on startup:

!ENTRY org.eclipse.core.jobs 4 2 2015-01-19 23:14:51.802
!MESSAGE An internal error occurred during: "Eclipse Integration for Tapestry5".
!STACK 0
java.lang.IllegalArgumentException: Unsupported JLS level
    at org.eclipse.jdt.core.dom.AST.<init>(AST.java:681)
    at org.eclipse.jdt.core.dom.AST.newAST(AST.java:270)
    at com.anjlab.eclipse.tapestry5.TapestryModule.readValuesFromAnnotation(TapestryModule.java:1000)
    at com.anjlab.eclipse.tapestry5.TapestryModule.readMarkerAnnotation(TapestryModule.java:183)
    at com.anjlab.eclipse.tapestry5.TapestryModule.findMarkers(TapestryModule.java:166)
    at com.anjlab.eclipse.tapestry5.TapestryModule.initialize(TapestryModule.java:144)
    at com.anjlab.eclipse.tapestry5.TapestryProject.addModule(TapestryProject.java:410)
    at com.anjlab.eclipse.tapestry5.TapestryProject.addModule(TapestryProject.java:387)
    at com.anjlab.eclipse.tapestry5.TapestryProject.findModules(TapestryProject.java:274)
    at com.anjlab.eclipse.tapestry5.TapestryProject.initialize(TapestryProject.java:121)
    at com.anjlab.eclipse.tapestry5.watchdog.TapestryProjectWatchdog$TapestryProjectAnalyzerJob.run(TapestryProjectWatchdog.java:85)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

I switched back to running with JRE 1.7.0 and the issue is gone. Looks like this is a problem with Eclipse libraries rather than your plugin (still looking for an Eclipse bug report and/or an updated version of the underlying library).

dmitrygusev commented 9 years ago

@kaosko please try version 2.7.6

dmitrygusev commented 9 years ago

I assume this fixed now?

kaosko commented 9 years ago

Sorry failed to reply. Works great thanks!