PDA

View Full Version : Spring Data Graph + Eclipse + AJDT : Editor errors



anodynos
Sep 14th, 2011, 01:51 PM
Hi to all Graphistas,

First of all I want to congratulate all the the developers of SDG - version 1.1 has added a lot of functionality, especially in terms of querying (Cypher, Gremlin etc).

Now to the problem, Summary : Eclipse editor reports errors such as
Type mismatch : Cannot convert from Class<XXX> to Class<? extends RelationshipBacked>
or
The method relateTo(World, String) is undefined for the type

Its is an old problem that's been mentioned a lot

http://forum.springsource.org/showthread.php?108930-spring-data-graph-persist-undefined
http://forum.springsource.org/showthread.php?113629-Using-Spring-Data-Graph-in-real & http://stackoverflow.com/questions/7144097/spring-data-graph-and-eclipse
http://forum.springsource.org/showthread.php?110204-Spring-Data-Graph-Example-(cineasts)-Related-blues-amp-how-to-run (http://forum.springsource.org/showthread.php?110204-Spring-Data-Graph-Example-%28cineasts%29-Related-blues-amp-how-to-run)
http://forum.springsource.org/showthread.php?110744-Neo4j-and-quot-Type-mismatch-quot-using-RelatedTo
http://forum.springsource.org/showthread.php?113244-Developing-Spring-Data-Graph-with-eclipse
http://forum.springsource.org/showthread.php?111908-Error-in-RelatedTo-Spring-Data-graph

Having spent the last couple of days trying every possible solution, I can assure you it has not been solved!

I 've created a JIRA issue (https://jira.springsource.org/browse/DATAGRAPH-104) inahope that the appropriate springers can rectify it...

To sum it up:

a) In @RelatedToVia & @RelatedTo & @NodeEntity annotations, you get something like : Type mismatch : Cannot convert from Class<XXX> to Class<? extends RelationshipBacked>

b) In relateTo(...) , getRelationshipTo(), persist() and all other introduced methods, you get a
The method relateTo(World, String) is undefined for the type XXX
or
The method persist() is undefined for the type XXX
etc

c) Finally in repository definitions like

public interface XXXRepository extends GraphRepository<XXX>, NamedIndexRepository<XXX> {}
you get:
Bound mismatch: The type XXX is not a valid substitute for the bounded parameter <T
extends GraphBacked<?>> of the type NamedIndexRepository<T>

Bound mismatch: The type XXX is not a valid substitute for the bounded parameter <T
extends GraphBacked<?>> of the type GraphRepository<T>

Remedies (with no cure)
a) The method with adding **/*.aj to the build path
(mentioned in https://jira.springsource.org/browse/DATAGRAPH-39 and elsewhere including par 18.1.1 in http://static.springsource.org/spring-data/data-graph/docs/current/reference/multi/programming-model.html) DOES NOT work.

It seems that it does, cause once you add **/*.aj as the the build path inclusion, your *.java files are not included in your build path anymore!
Therefore, ALL errors in those *.java files aren't reported & the editor functionality is hammered (no refactoring etc).
Now, trying to also add **/*.java to the include build path, reveals that the problem persists):-(

b) Updating Eclipse tools to the latest versions & configuring them is not verified to cure anything - check bellow :

Configurations
I have used various configurations that had the exact problem, my current is :
- Eclipse 3.7 Indigo (Version: 3.7.0, Build id: I20110613-1736) on a Windows 2003 VM with 4GB RAM and the following plugin versions :


AspectJ Development Tools
2.2.0.e37x-20110907-1500


AspectJ Development Tools (AJDT) Source Code
2.2.0.e37x-20110907-1500


Eclipse Weaving Service Feature
2.2.0.e37x-20110907-1500


Equinox Weaving SDK
1.0.100.v20110502-79-F8PEVVFNNFsFV


Maven Integration for Eclipse (Required)
0.12.1.20110112-1712


Maven Integration for WTP (Optional)
0.12.0.20110421-1500


Project configurators for commonly used maven plugins (temporary)
0.12.0.20101103-1500


Spring IDE AJDT Integration (optional)
2.7.1.201107082359-RELEASE


Spring IDE AOP Extension (optional)
2.7.1.201107082359-RELEASE


Spring IDE Autowire Extension (optional)
2.7.1.201107082359-RELEASE


Spring IDE Batch Extension (optional)
2.7.1.201107082359-RELEASE


Spring IDE Core (required)
2.7.1.201107082359-RELEASE


Spring IDE Integration, Flex and Web Services Extension (optional)
2.7.1.201107082359-RELEASE


Spring IDE Mylyn Integration (optional)
2.7.1.201107082359-RELEASE


Spring IDE OSGi Extension (optional)
2.7.1.201107082359-RELEASE


Spring IDE Security Extension (optional)
2.7.1.201107082359-RELEASE


Spring IDE Web Flow Extension (optional)
2.7.1.201107082359-RELEASE


SpringSource Tool Suite (required)
2.7.1.201107091000-RELEASE


SpringSource Tool Suite dm Server Tools
2.7.1.201107091000-RELEASE


SpringSource Tool Suite Maven Support
2.7.1.201107091000-RELEASE


SpringSource Tool Suite Roo Support
2.7.1.201107091000-RELEASE


SpringSource Tool Suite tc Server Tools
2.7.1.201107091000-RELEASE


SpringSource Tool Suite Tutorials
2.7.1.201107091000-RELEASE


SpringSource Tool Suite VMware Integration
2.7.1.201107091000-RELEASE





My Maven (3.0.3) pom has the following versions :
<spring.version>3.0.5.RELEASE</spring.version>
<aspectj.version>1.6.12.M1</aspectj.version> (also tried M2)
<slf4j.version>1.6.1</slf4j.version>
<datastore-graph.version>1.1.0.RELEASE</datastore-graph.version> (same problems with SDG 1.0.0.RELEASE)

Eclipse & Tools Configuration
Tried various possible Eclipse / plugin settings:
- Preferences -> JDT Weaving -> on & off (default) & reindexed
- Preferences -> AspectJ Compiler -> Incremental Compiler Optimizations on & off(default)
- Preferences -> Spring (used defaults)
Projects compile & run
I've verified the same exists problem on at least
- Spring Data Graph examples like hello-worlds (https://github.com/SpringSource/spring-data-graph-examples)
- Cineast (git://github.com/jexp/cineasts.git)
and my own apps.
Important : these apps compile fine with eclipse build and maven test. They also run fine.
But there are the following Spring related warnings [WARNING] this affected type is not exposed to the weaver: org.neo4j.cineasts.domain.Person [Xlint:typeNotExposedToWeaver]
[WARNING] this affected type is not exposed to the weaver: org.neo4j.cineasts.domain.Movie [Xlint:typeNotExposedToWeaver]
[WARNING] this affected type is not exposed to the weaver: org.neo4j.cineasts.domain.Role [Xlint:typeNotExposedToWeaver]
[WARNING] this affected type is not exposed to the weaver: org.neo4j.cineasts.domain.User [Xlint:typeNotExposedToWeaver]
[WARNING] this affected type is not exposed to the weaver: org.neo4j.cineasts.domain.Rating [Xlint:typeNotExposedToWeaver]

[WARNING] advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTr anslatorAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsy ncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.data.neo4j.support.node.Neo4jN odeBacking has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.data.neo4j.support.node.Neo4jN odeBacking has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.data.neo4j.support.node.Neo4jN odeBacking has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDriv enStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethod MockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethod MockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.data.neo4j.support.relationshi p.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.data.neo4j.support.relationshi p.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]

StefanOllinger
Sep 14th, 2011, 03:22 PM
Hi,

you could try my test project: https://github.com/dozed/neo4j-test
There are instructions on how to import it in eclipse.

Here my setup:
Eclipse Version: 3.7.0 Build id: I20110613-1736
AJDT 2.2.0.e37x-20110907-1500
M2E - Maven Integration for Eclipse

Regards,
Stefan

MichaelHunger
Sep 15th, 2011, 03:09 AM
Sorry for all that fuss and thanks for your efforts so far. I'm very sad about those repeated issues.

I forwarded your problems to Andy Clement the AJ project lead. He certainly has more insights in that than any of us :)

Cheers

Michael

trisberg
Sep 15th, 2011, 12:21 PM
I tried that test project and I end up with some compile errors from just running "mvn clean test".

Seeing a few errors like this
ajdt-tests/neo4j-test/src/main/java/org/noorg/fink/neo4j/test/entities/Page.java:[14,31] incompatible types
[ERROR] found : java.lang.Class<org.noorg.fink.neo4j.test.entities.Page>
[ERROR] required: java.lang.Class<? extends org.springframework.data.neo4j.core.NodeBacked>

Do you get a clean compile?

Also, saw the note where you run "mvn eclipse:eclipse". I don't recommend that since the eclipse plugin isn't fully compatible with m2eclipse that is used in STS. Just import maven project from STS.

-Thomas

MichaelHunger
Sep 16th, 2011, 04:28 AM
Andy Clement commented at your JIRA issue.

Hope that helps.

Michael

anodynos
Sep 16th, 2011, 04:31 AM
Same here - I imported https://github.com/dozed/neo4j-test and followed Stefan's instructions : eclipse errors persist.
Also it doesn't build with "mvn test". It gives the same naive errors like :


ERROR \GITHome\git\neo4j-test\src\main\java\org\noorg\fink\neo4j\test\entit ies
\Page.java:[14,31] incompatible types
found : java.lang.Class<org.noorg.fink.neo4j.test.entities.Page>
required: java.lang.Class<? extends org.springframework.data.neo4j.core.NodeBack
ed>

StefanOllinger
Sep 16th, 2011, 05:47 AM
Try the following:

% mvn -DskipTests clean aspectj:compile compile package

Seems that the AspectJ Maven plugin doesnt get active. (The tests are supposed to fail atm.)

trisberg: for eclipse:eclipse, see my comments and the diff on the JIRA issue (https://jira.springsource.org/browse/DATAGRAPH-104?focusedCommentId=70484&page=com.atlassian.jira.plugin.system.issuetabpane ls:comment-tabpanel#comment-70484).

anodynos
Sep 16th, 2011, 06:07 AM
Stefan, I dont understand : have you made the SDG errors disappear from Eclipse editor? In your example project the problem is still there IMHO.

The problem we talk about is not compiling & running an SDG app in general or with maven; its only about the Eclipse editor errors on SDG annotations and introduced methods.

StefanOllinger
Sep 16th, 2011, 06:11 AM
There are problems with maven and with eclipse.

- Maven: aspectj:compile does not get executed
The solution here is to specifically execute the aspectj:compile goal.

- Eclipse: AspectJ plugin does not weave the aspects in
Here you need to run the eclipse:eclipse goal, then refresh the project in Eclipse. That works for me at least and creates a working eclipse project.

Regards,
Stefan

anodynos
Sep 16th, 2011, 04:08 PM
Stefan thanks - I think it's kind of workable after running "mvn eclipse:eclipse" once, it makes the errors go away, for a while...

After some edits / runs, they come back andyou have to rebuild. EDIT: you have to restart eclipse, re build, re-something along with voodoo and it might work! Then run aspectj:compile and it got bad again.. it wont even build / run tests on eclipse...
Thank god there is the command line that works!

Can you provide directions if you've managed to automate these goals running within eclipse ?

My "Project > Properties > Maven > Lifecycle Mapping" has "process-resources resources:testResources" as goals to invoke on changes.
I tried to introduce aspectj:compile between them, but doesnt seem to work...

Any ideas ?

StefanOllinger
Sep 18th, 2011, 10:28 AM
Sorry, i cant really say why the errors re-appear. What you can try is to find out if any eclipse artifacts change (.project, .classpath, .settings). For example create a git repository in your project and after each change do a commit. That way you can see all deltas, if there are any.

rdouglas
Sep 26th, 2011, 02:42 PM
is there a recommended way to develope SDG applications with an IDE? I am also having all sorts of errors, using both STS 2.7.2 and STS 2.8.0.M2.

In either case, I have to make my @NodeEntity class implement NodeBacked, else the repository complains. If I do this, my @NodeEntity class complains that I'm not implementing required methods. Project is setup as a Maven & AspectJ project in STS.

I'd really like to use SDG & Neo, but these tooling errors are a real time waster. How are people using this project right now? Are you foregoing code completion etc & building using a text editor?

MichaelHunger
Sep 26th, 2011, 05:40 PM
How did you set up the maven project? As you can see in some of the previous posts. maven eclipse:eclipse forgets to add the aspectj-files/paths to the build-path so it can't find the actual aspects.

When I opened existing sample applications with m2eclipse I didn't run into issues. But I'll re-check.

Thanks for the feedback

Michael

MichaelHunger
Sep 26th, 2011, 06:25 PM
I just checked it with STS 2.7.1, 2.7.2 and 2.8.0.M2 using Import -> Maven -> Existing Maven Maven Project and imported the SDG HelloWorld project, there were no editor errors at all.

Please make sure that Project Properties -> AspectJ Build -> Aspect Path should contain two entries, first spring-aspects from the springframework and the spring-data-neo4j jars.

42924292

rdouglas
Sep 26th, 2011, 10:03 PM
The project was created from scratch in STS using New > Maven Project. I then added the various SDG dependencies, and copy & pasted in the maven-aspectj-plugin configuration section. I've checked the Aspect Path & the 2 JARs are there.

I should note that things seem to have sort resolved themselves, though I'm not quite sure why. To try verify the issue, I imported all the sample projects using Import > Existing Maven Projects. And, yes, they seemed to import fine & show no errors. After that, my project also showed no errors, though this is probably a co-incidence: I had restarted the IDE inbetween to install some updates. Note those updates weren't AJDT or anything like that. I later removed JDK 1.7 and JDK 1.5 JREs out of baseless suspicion, but I think it was working already before that.

Now my project looks good in the IDE, and I can compile it with a Maven Build run configuration, as long as I specify goals: clean aspectj:compile install (i.e. need to explicitly call aspectj:compile before compile, package or install). By the way, the advice to "add **/*.aj file to build path" is not really relevant to a general project. I read the JIRA issue, and it was a response based on an assumption that someone was having trouble building the Spring Data Graph project itself. I don't see an *.aj files in my project at all, and I assume that any aspects in SDG or core Spring are made available by having the JARs on the Aspect Path.

I'll try go back to a completely empty workspace & start a completely new Maven project to see if I can recreate the problems. One thing about the sample apps I noticed is they depend on 1.0.0 release of SDG. Again, haven't had time to see if that makes a difference (i'm using 1.1.0 release).

Thanks for your help, I'll get back to you if I can recreate the issue in a sandbox setup.

anodynos
Sep 28th, 2011, 08:49 AM
Still the same problem : I used a fresh installation of Eclipse 3.7 with STS 2.7.2 & m2e 1.0.100 and imported cineasts in its latest 1.1 release. The project runs OK on cmd line maven.
I ve added the Aspect Path libraries. The maven on the command line (mvn clean test) works Ok, but it gives WARNINGs like :


advice defined in org.springframework.data.neo4j.support.relationshi p.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]

advice defined in org.springframework.data.neo4j.support.node.Neo4jN odeBacking has not been applied [Xlint:adviceDidNotMatch]



When I build within Eclipse I get similar warnings.

Also I noticed that sometimes, the Eclipse Package/Project Explorer show files as being OK (no red x on them), but once you go in them and on the offending @ annotations the errors are there.

Andy Clement
Sep 29th, 2011, 11:26 AM
I've put some more comments on the bug report as we try to investigate further. I still can't get things to fail for me inside eclipse and without that I can't debug it. The myrestaurants-social project seems to contain more weirdness than the cineasts project as its .project contains ajbuilder twice (even after an mvn eclipse:eclipse) indicating the pom isn't quite right, I think. But the cineasts one looks fine, just won't fail for me.

If we could get a simple set of reliable steps that show a failure in the IDE, we can properly investigate it.

Andy

alexmaz
Dec 14th, 2011, 11:28 AM
I just checked it with STS 2.7.1, 2.7.2 and 2.8.0.M2 using Import -> Maven -> Existing Maven Maven Project and imported the SDG HelloWorld project, there were no editor errors at all.

Please make sure that Project Properties -> AspectJ Build -> Aspect Path should contain two entries, first spring-aspects from the springframework and the spring-data-neo4j jars.

42924292

Thanks for this I was about to get crazy :p

MichaelHunger
Dec 15th, 2011, 04:01 AM
It's also part of the docs (http://static.springsource.org/spring-data/data-graph/snapshot-site/reference/html/#d0e1496) and the DeveloperNotes (http://spring.neo4j.org/notes)