ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • import Lucene4.1 project in eclipse
    개발하면서/etc 2013. 1. 30. 21:56
    반응형

    팀내 과장님을 통해 루씬 4.1이 나온 걸 알았습니다.

     

    이번 기회에 미루고 미루던 루씬이 내부적으로 어떻게 구성되는지 보려고 (아는 게 없으니, 무작정 해 보자라는 마음으로) 

    이클립스에 import 하려고 했습니다.

     

    http://softwaregeeks.org/2012/10/30/how-to-import-lucene40-in-eclipse/  링크처럼 진행 했는데,
    제가 뭘 잘못 건드렸는지는 모르겠지만 아래와 같은 오류가 발생 했습니다.  

    (ant ivy-bootstrap resolve 까지 진행한 상태, ant 설정은 위 url 참고.)

     

     

     

     

    이 글을 위의 화면 처럼 나오는 분들께 바칩니다. ㅎㅎ

     

    우선  New -> Java Project 에서 lucene이라고 프로젝트를 하나 만듭니다.

    그 다음 lucene 폴더에서 우 클릭을 누르고 import -> File System,   과감히 lucene-4.1.0을  선택합니다.

     

     

     

     

     

    그럼 왼쪽 그림 처럼 프로젝트가 구성됩니다.

     

     

    우선 lucene core를 보는게 목적 이었기때문에  

    core -> src -> java 에서  Build Path -> Use as Source Folder,

    core -> src -> test 에서  Use as Source Folder

     

     

    테스트에서 빨강색이 왕창 떠서 가봤더니  test-framework, codec이 없다고 난리

     

     

     

    test-framework -> src -> java Use as Source Folder

    codecs-> src -> java       Use as Source Folder

     

    그리고 test-framework -> lib에 있는 library들을 빌드에 추가 시킵니다.

     

    ant-1.8.2.jar, junit-4.10.jar, junit4-ant-2.0.8.jar, randomizedtesting-runner-2.0.8.jar

    Build Path -> Add to Build Path

     

     

     

    여기까지 했으면 빨강색은 뜨지 않습니다.

    TestIndexWriter.java로 가서 테스트 유닛을 돌려봅니다.    vm Argument 에 -ea 인자 주라고 합니다.

    가볍게 추가해주고 다시 실행~!!

     

    java.lang.ExceptionInInitializerError
        at org.apache.lucene.util.TestRuleSetupAndRestoreClassEnv.before(TestRuleSetupAndRestoreClassEnv.java:137)
        at org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:45)
        at org.apache.lucene.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:42)
        at com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule$1.evaluate(SystemPropertiesInvariantRule.java:55)
        at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:39)
        at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:39)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at org.apache.lucene.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:43)
        at org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:48)
        at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:70)
        at org.apache.lucene.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:55)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:358)
        at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.IllegalArgumentException: A SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene41' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []
        at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:104)
        at org.apache.lucene.codecs.Codec.forName(Codec.java:95)
        at org.apache.lucene.codecs.Codec.<clinit>(Codec.java:122)
        ... 14 more

    java.lang.NoClassDefFoundError: Could not initialize class org.apache.lucene.codecs.Codec
        at org.apache.lucene.util.TestRuleSetupAndRestoreClassEnv.after(TestRuleSetupAndRestoreClassEnv.java:254)
        at org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:52)
        at org.apache.lucene.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:42)
        at com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule$1.evaluate(SystemPropertiesInvariantRule.java:55)
        at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:39)
        at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:39)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at org.apache.lucene.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:43)
        at org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:48)
        at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:70)
        at org.apache.lucene.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:55)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:358)
        at java.lang.Thread.run(Thread.java:662)

     

    멘붕입니다.

    더 멘붕인건 ant test로 하면되는데, eclipse에서 테스트하면 안되는게.....역시 얕은 지식으로는 한계가 금방 나타납니다.

     

    이것 때문에 루씬 재설치를 수차례, 혹시나해서 library 받은거 지우기도 했는데 안됩니다.......;;

    trace에 찍힌 소스들 들어가서 보지만, 뭔소린지.......

     

    이것저것 해보다가 포기상태있을 때, 뭔 에런가.....하고 한줄한줄 읽어봤습니다.

     

    "Caused by: java.lang.IllegalArgumentException: A SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene41' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []"

     

    You need to add the corresponding JAR..You need to add the corresponding JAR..You need to add the corresponding JAR......You need to add the corresponding JAR........You need to add the corresponding JAR

     

    혹시나 해서 lucene/core, lucene/codecs, lucene/test-framework에서 build 해서(폴더 이동후 ant만 실행하면 만들어줘요)
    jar 파일을 만든 후에 추가했습니다.  (jar는 lucene/build에 폴더별)

     

     

     

    다시 TestIndexWriter.java Junit 궈궈 ~~~~~~~~~~~~~~  

     

     

    잘됩니다. : )

     

    도움이 되셨으면 좋겠습니다.

    더불어 루씬 소스 보신 분들의 조언, 함께 하시고 싶은 분들 알려주세요~~

    제가 백지부터 시작 하는 거라 함께 백지에 글 써 가듯이.....: )

     

    ※교훈 : 에러 로그를 잘 보자. 영어를 공부하자. 응? ㅋㅋㅋ

    반응형

    댓글

Designed by Tistory.