You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Alex vB <ma...@avomberg.de> on 2011/01/25 16:12:18 UTC

Could not find implementing class

Hello everybody,

I used a small indexing example from "Lucene in Action" and can run and
compile the program under eclipse. If I want to compile and run it by
console I get this error:


java.lang.IllegalArgumentException: Could not find implementing class for
org.apache.lucene.analysis.tokenattributes.TermAttribute
	at
org.apache.lucene.util.AttributeSource$AttributeFactory$DefaultAttributeFactory.getClassForInterface(AttributeSource.java:87)
	at
org.apache.lucene.util.AttributeSource$AttributeFactory$DefaultAttributeFactory.createAttributeInstance(AttributeSource.java:66)
	at
org.apache.lucene.util.AttributeSource.addAttribute(AttributeSource.java:245)
	at
org.apache.lucene.index.DocInverterPerThread$SingleTokenAttributeSource.<init>(DocInverterPerThread.java:41)
	at
org.apache.lucene.index.DocInverterPerThread$SingleTokenAttributeSource.<init>(DocInverterPerThread.java:36)
	at
org.apache.lucene.index.DocInverterPerThread.<init>(DocInverterPerThread.java:34)
	at org.apache.lucene.index.DocInverter.addThread(DocInverter.java:95)
	at
org.apache.lucene.index.DocFieldProcessorPerThread.<init>(DocFieldProcessorPerThread.java:62)
	at
org.apache.lucene.index.DocFieldProcessor.addThread(DocFieldProcessor.java:88)
	at
org.apache.lucene.index.DocumentsWriterThreadState.<init>(DocumentsWriterThreadState.java:43)
	at
org.apache.lucene.index.DocumentsWriter.getThreadState(DocumentsWriter.java:739)
	at
org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:814)
	at
org.apache.lucene.index.DocumentsWriter.addDocument(DocumentsWriter.java:802)
	at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1998)
	at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1972)
	at Demo.setUp(Demo.java:86)
	at Demo.main(Demo.java:46)

I compile the command with javac -cp <path/Lucene/sources> Demo.java which
finishes without errors but running the program isn't possible. What am I
missing?? Basically I am just creating a directory, getting an indexwriter
with analyzer etc.. Line 86 in Demo.java is writer.addDocument(doc);.

Greetings Alex
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Could-not-find-implementing-class-tp2330598p2330598.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


RE: Could not find implementing class

Posted by Alex vB <ma...@avomberg.de>.
Hello Uwe,

I recompiled some classes manually in Lucene sources. No it's running fine!
Something went wrong there.

Thank you very much!

Best regards
Alex
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Could-not-find-implementing-class-tp2330598p2332141.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


RE: Could not find implementing class

Posted by Uwe Schindler <uw...@thetaphi.de>.
You have to also pass the classpath to java runtime, not only to javac.

If you get this problem within Eclipse, have you tried to cleanup the
project, maybe not all files are compiled?

Are you also compiling Lucene from source? If yes, make sure that all Lucene
classes are compiled (see cleanup above, uncheck any options to compile only
used classes). Lucene uses reflection to load some additional classes not
referenced in the .java files directly (dynamic loading), so missing ones
would not be seen by javac? Also it may be the case that inside Eclipse you
are using the veeeeery old Eclipse-shipped lucene-core.jar that interferes
with your program.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Alex vB [mailto:mail@avomberg.de]
> Sent: Tuesday, January 25, 2011 5:41 PM
> To: java-user@lucene.apache.org
> Subject: Re: Could not find implementing class
> 
> 
> Hello Alexander,
> 
> isn't it enough to add the classpath through -cp? If I don't use -cp I
can't
> compile my project. I thought after compiling without errors all sources
are
> correctly added. In Eclipse I added Lucene sources the same  way(which
> works) and I also tried using the jar file. Therefore I seem to find all
classes
> but I don't get a clue with the error message. This error message is
thrown by
> the Lucene class DefaultAttributeFactory in
> org.apache.lucene.util.AttributeSource. I work under Ubuntu and configured
> java with
> 
> - sudo update-alternatives --config java
> - sudo update-java-alternatives -java-6-sun
> 
> Greetings
> Alex
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Could-
> not-find-implementing-class-tp2330598p2331617.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Could not find implementing class

Posted by Alex vB <ma...@avomberg.de>.
Hello Alexander,

isn't it enough to add the classpath through -cp? If I don't use -cp I can't
compile my project. I thought after compiling without errors all sources are
correctly added. In Eclipse I added Lucene sources the same  way(which
works) and I also tried using the jar file. Therefore I seem to find all
classes but I don't get a clue with the error message. This error message is
thrown by the Lucene class DefaultAttributeFactory in 
org.apache.lucene.util.AttributeSource. I work under Ubuntu and configured
java with 

- sudo update-alternatives --config java 
- sudo update-java-alternatives -java-6-sun

Greetings
Alex


-- 
View this message in context: http://lucene.472066.n3.nabble.com/Could-not-find-implementing-class-tp2330598p2331617.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Could not find implementing class

Posted by Alexander Aristov <al...@gmail.com>.
Set correct classpath. you may want to compare which libraries eclipse
includes in classpath.


Best Regards
Alexander Aristov


On 25 January 2011 18:12, Alex vB <ma...@avomberg.de> wrote:

>
> Hello everybody,
>
> I used a small indexing example from "Lucene in Action" and can run and
> compile the program under eclipse. If I want to compile and run it by
> console I get this error:
>
>
> java.lang.IllegalArgumentException: Could not find implementing class for
> org.apache.lucene.analysis.tokenattributes.TermAttribute
>        at
>
> org.apache.lucene.util.AttributeSource$AttributeFactory$DefaultAttributeFactory.getClassForInterface(AttributeSource.java:87)
>        at
>
> org.apache.lucene.util.AttributeSource$AttributeFactory$DefaultAttributeFactory.createAttributeInstance(AttributeSource.java:66)
>        at
>
> org.apache.lucene.util.AttributeSource.addAttribute(AttributeSource.java:245)
>        at
>
> org.apache.lucene.index.DocInverterPerThread$SingleTokenAttributeSource.<init>(DocInverterPerThread.java:41)
>        at
>
> org.apache.lucene.index.DocInverterPerThread$SingleTokenAttributeSource.<init>(DocInverterPerThread.java:36)
>        at
>
> org.apache.lucene.index.DocInverterPerThread.<init>(DocInverterPerThread.java:34)
>        at
> org.apache.lucene.index.DocInverter.addThread(DocInverter.java:95)
>        at
>
> org.apache.lucene.index.DocFieldProcessorPerThread.<init>(DocFieldProcessorPerThread.java:62)
>        at
>
> org.apache.lucene.index.DocFieldProcessor.addThread(DocFieldProcessor.java:88)
>        at
>
> org.apache.lucene.index.DocumentsWriterThreadState.<init>(DocumentsWriterThreadState.java:43)
>        at
>
> org.apache.lucene.index.DocumentsWriter.getThreadState(DocumentsWriter.java:739)
>        at
>
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:814)
>        at
>
> org.apache.lucene.index.DocumentsWriter.addDocument(DocumentsWriter.java:802)
>        at
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1998)
>        at
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1972)
>        at Demo.setUp(Demo.java:86)
>        at Demo.main(Demo.java:46)
>
> I compile the command with javac -cp <path/Lucene/sources> Demo.java which
> finishes without errors but running the program isn't possible. What am I
> missing?? Basically I am just creating a directory, getting an indexwriter
> with analyzer etc.. Line 86 in Demo.java is writer.addDocument(doc);.
>
> Greetings Alex
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Could-not-find-implementing-class-tp2330598p2330598.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>