Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with Eclipse? #5

Closed
nkavian opened this issue Mar 24, 2013 · 8 comments
Closed

Not working with Eclipse? #5

nkavian opened this issue Mar 24, 2013 · 8 comments

Comments

@nkavian
Copy link

nkavian commented Mar 24, 2013

I created a new Java project in Eclipse, added the evo and guava jars, followed the example in the "Usage", but I don't see any index file being generated and it doesn't print out what it's supposed to print out.

What am I missing?

Using evo-classindex-1.3.jar and guava-14.0.1.jar

It only print out the first line, not the others:

  System.out.println("!!!! Hello");
  for(final Class<?> klass : ClassIndex.getAnnotated(Entity.class))
     {
     System.out.println("!!!! " + klass.getName());
     }

Eclipse Juno on a Mac

@sentinelt
Copy link
Member

Eclipse uses its own Java compiler which is not strictly standard compliant and requires extra configuration.
See screenshot below:
eclipse_screenshot

@sentinelt
Copy link
Member

Instructions from Eclipse page: http://www.eclipse.org/jdt/apt/introToAPT.php

Let me know if that helps. I will add relevant info to the README file.

@nkavian
Copy link
Author

nkavian commented Mar 25, 2013

Thanks so much, I'm so excited that this is going to work. I found that screen but would never have figured out to load both jars. I ran into another error afterwards when using this with a Java EE Tomcat 7 project. I found out to turn off "Serve modules without publishing" because when it was enabled it would cause this exception:

java.lang.RuntimeException: Evo Class Index: Cannot read class index
at org.atteo.evo.classindex.ClassIndex.readIndexFile(ClassIndex.java:174)
......
Caused by: java.io.FileNotFoundException: /Website/Java/WebContent/WEB-INF/classes/META-INF/annotations/model.internal.client.Entity (No such file or directory)
at java.io.FileInputStream.open(Native Method)
......

During compilation, the output was in:
/Website/Java/build/classes/META-INF/annotations/model.internal.client.Entity

But when run it expects it in:
/Website/Java/WebContent/WEB-INF/classes/META-INF/annotations/model.internal.client.Entity

A few links that kind of talk about similar problems but no solutions except to disable the feature:
http://stackoverflow.com/questions/5924720/serve-modules-without-publishing-not-working-in-helios
spring-attic/spring-mvc-showcase#18

Any chance you have a solution?

@nkavian
Copy link
Author

nkavian commented Mar 25, 2013

In this file I think there needs to be a try/catch inside the first while loop before the second while loop to avoid an exception from breaking the iteration..

If the first URL resources throws an IOException then it will not scan the rest of the URL resources..

https://github.com/atteo/evo-classindex/blob/master/classindex/src/main/java/org/atteo/evo/classindex/ClassIndex.java

I noticed the exception referenced ClassIndex line 154..

Caused by: java.io.FileNotFoundException: /Website/Java/WebContent/WEB-INF/classes/META-INF/annotations/model.internal.client.Entity (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:97)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at java.net.URL.openStream(URL.java:1035)
at org.atteo.evo.classindex.ClassIndex.readIndexFile(ClassIndex.java:154)
... 25 more

This may be why my earlier problem happend..?..

Part of the solution may just be ignoring the IOException and return an empty classes list.

@sentinelt
Copy link
Member

So there really is some index file because it is returned from getResources method in ClassIndex line 150, but somehow it cannot be opened.

Would You be able to provide me with a sample project with which I could reproduce the issue?

sentinelt added a commit that referenced this issue Mar 25, 2013
Change-Id: Ie1b94316496f6175d71deecd3b0aecf2565da2f4
Refs: #5
@sentinelt
Copy link
Member

Thanks, for the sample project.

sentinelt added a commit that referenced this issue Mar 26, 2013
When Executed under Tomcat started from Eclipse with "Serve modules
without publishing" opiton turned on, ClassLoader.getResources() method
returnes the same resource two times: first with incorrect path and second
time with the correct one. This change ignores any resources which throws
FileNotFoundException when opened.

Fixes: #5
Change-Id: I89c281db81a38b65b66d030ebec04ecbbcbbba9f
Tested-by: Mr. Jenkins
Reviewed-by: Sławek Piotrowski <[email protected]>
@sentinelt
Copy link
Member

Fixed in 1.4. Thanks for all your support.

@sentinelt
Copy link
Member

As of version 3.0 it is no longer necessary to load Guava in Eclipse, because ClassIndex was rewritten to not use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants