Java 애플리케이션에서 twitter-korean-text을 사용시 runtime exception이 발생합니다

886 views
Skip to first unread message

구본욱

unread,
Mar 25, 2015, 3:47:04 AM3/25/15
to twitter-k...@googlegroups.com
안녕하세요

먼저 위와 같은 라이브러리를 제공해주셔서 감사합니다 ^^
형태소 분석을 위해 twitter-korean-text 을 사용하려고 합니다

java 애플리케이션에서 사용중이며 
korean-text : 2.4.2
JDK : 1.7
App Server : Tomcat 7.0
maven : 3.2.3
spring framework : 4.1.3
spring batch framework : 2.1.9

위와 환경에서 사용중인데 아래와 같은 runtime exception 이 발생합니다

java.lang.NoClassDefFoundError: Could not initialize class com.twitter.penguin.korean.tokenizer.KoreanChunker
at com.twitter.penguin.korean.tokenizer.KoreanTokenizer$.tokenize(KoreanTokenizer.scala:244)

사용된 코드는 아래와 같습니다(사용된 부분만 복사하였습니다)
혹시 도움을 주실수 있으실까요?

import com.twitter.penguin.korean.TwitterKoreanProcessorJava;
import com.twitter.penguin.korean.tokenizer.KoreanTokenizer;

private TwitterKoreanProcessorJava processor = new TwitterKoreanProcessorJava.Builder()
.disableNormalizer()
.disableStemmer()
.build();

List<CharSequence> phrases = processor.extractPhrases(keyword);
List<String> results = new ArrayList<String>();
for (CharSequence ch : phrases) {
results.add(ch.toString());
}
return results;

Hohyon Ryu

unread,
Mar 25, 2015, 12:45:08 PM3/25/15
to twitter-k...@googlegroups.com
음.. 아무래도 Maven 설정이 문제가 있는 것 같은데요? 


여기 예시 프로젝트를 올려놓았는데요, 이 프로젝트를 열어보시고 실행이 가능한지 확인해 보시면 실마리가 생기지 않을까 싶습니다.

해 보시다가 또 질문 있으시면 알려주세요.

--
You received this message because you are subscribed to the Google Groups "twitter-korean-text" group.
To unsubscribe from this group and stop receiving emails from it, send an email to twitter-korean-...@googlegroups.com.
To post to this group, send email to twitter-k...@googlegroups.com.
Visit this group at http://groups.google.com/group/twitter-korean-text.
To view this discussion on the web visit https://groups.google.com/d/msgid/twitter-korean-text/945f9836-a997-45e4-ae78-52d7bde72e81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hohyon Ryu

unread,
Mar 25, 2015, 7:15:01 PM3/25/15
to twitter-k...@googlegroups.com
혹시 Maven에

<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

추가 하셨는지 확인 부탁드립니다. 

To unsubscribe from this group and stop receiving emails from it, send an email to twitter-korean-text+unsub...@googlegroups.com.
To post to this group, send email to twitter-korean-text@googlegroups.com.
Message has been deleted

구본욱

unread,
Mar 26, 2015, 4:24:31 AM3/26/15
to twitter-k...@googlegroups.com
답변이 늦어 죄송합니다
아래와 같이 진행해 보았습니다
1. 최초 올린 구성 그대로 junit으로 test case 구성해서 실행했을때 정상 동작하였습니다
1.1. 하지만 java 애플리케이션으로 동작할 경우에는 동일한 증상이 발생했습니다
2. sample을 실행시켰을 경우 정상동작하였습니다
3. 위의 maven plugin를 추가했는데도 여전히 동일한 문제가 발생했습니다

그래서 아래와 같이 maven의 plugin 설정을 추가해서 올립니다
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.16</version>
        <configuration>
            <excludes>
                <exclude>**/*Test.java</exclude>
            </excludes>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <version>2.15.2</version>
        <executions>
            <execution>
                <goals>
                    <goal>compile</goal>
                    <goal>testCompile</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>

2015년 3월 25일 수요일 오후 4시 47분 4초 UTC+9, 구본욱 님의 말:

Hohyon Ryu

unread,
Mar 26, 2015, 1:12:33 PM3/26/15
to twitter-k...@googlegroups.com
Tomcat에서 twitter-korean-text를 이용한 예제입니다.

https://github.com/gunjaag/twitter-korean-tokenizer-api


혹시 도움이 될까 해서 보내드립니다. 


--
You received this message because you are subscribed to the Google Groups "twitter-korean-text" group.
To unsubscribe from this group and stop receiving emails from it, send an email to twitter-korean-...@googlegroups.com.
To post to this group, send email to twitter-k...@googlegroups.com.

구본욱

unread,
Mar 31, 2015, 12:56:23 AM3/31/15
to twitter-k...@googlegroups.com
네, 시도해 볼께요 
감사합니다 ^^

2015년 3월 27일 금요일 오전 2시 12분 33초 UTC+9, Hohyon Ryu 님의 말:
To unsubscribe from this group and stop receiving emails from it, send an email to twitter-korean-text+unsub...@googlegroups.com.

구본욱

unread,
Apr 12, 2015, 9:31:00 PM4/12/15
to twitter-k...@googlegroups.com
안녕하세요
오랜만에 다시 인사드립니다
알려주신 방법과 함께 주위 분들의 도움으로 아래와 해결했습니다
원인과 해결 방법은 아래와 같습니다

1) 원인
 - 제가 전달드린 exception 이전에 I/O Stream exception이 먼저 발생했었습니다
 - 이 부분은 제가 미처 전달드리지 못했네요
 - 최초 exception은 twitter-text1.10.1.jar 에서 사용하는 Regex.java 에서 아래와 코드에서 발생했습니다
 - 
private static final Map tlds = (Map)yaml.load(
    ClassLoader.getSystemResourceAsStream("tld_lib.yml")
  );

 - 대략적인 원인으로는 tomcat 환경에서  classpath를 제대로 찾질 못해서 그런것 같은데 해결 방법을 찾질 못했습니다

2) 해결
 - twitter-text.1.11.1.jar 에서는 위 Regex.java에서 문제 되는 코드가 사라졌습니다
 - 따라서 현재 maven 설정을 아래와 같이 사용중이며 문제없이 동작중입니다
<dependency>
<groupId>com.twitter.penguin</groupId>
<artifactId>korean-text</artifactId>
<version>2.4.2</version>
<exclusions>
<exclusion>
<groupId>com.twitter</groupId>
<artifactId>twitter-text</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>twitter-text</artifactId>
<version>1.11.1</version>
</dependency>



3) 요청
 - 가능하다면 twitter-korean-text에서 참조하는 twitter-text 라이브러리 버전을 1.11.1 로 올려주시면 좋을 것 같아요

감사합니다 ^^


2015년 3월 25일 수요일 오후 4시 47분 4초 UTC+9, 구본욱 님의 말:
안녕하세요

Hohyon Ryu

unread,
Apr 13, 2015, 6:41:47 PM4/13/15
to twitter-k...@googlegroups.com
오 감사합니다!! 1.11.1로 올리도록 할께요. 

--
You received this message because you are subscribed to the Google Groups "twitter-korean-text" group.
To unsubscribe from this group and stop receiving emails from it, send an email to twitter-korean-...@googlegroups.com.

To post to this group, send email to twitter-k...@googlegroups.com.
Visit this group at http://groups.google.com/group/twitter-korean-text.

Hohyon Ryu

unread,
Apr 13, 2015, 6:44:01 PM4/13/15
to twitter-k...@googlegroups.com
혹시 이거 해 주실 분 계신가요?

git checkout -b 57_twitter-text_upgrade 

해서 그냥 pom.xml의 버전만 바꿔주시고, mvn test 해보고 다 패스 하면 pull request 하시면 되요. 혹시 재미로 해 보실 분 계시면 부탁드려요. :)

Minwoo Kang

unread,
Feb 16, 2016, 10:16:41 AM2/16/16
to twitter-korean-text
안녕하세요~ 페이스북에서 보고 찾아들어왔습니다.
이 게시글이 꽤 오래되었는데
git checkout -b 57_twitter-text_upgrade
이것 실행하셨겠죠?

Hohyon Ryu

unread,
Feb 16, 2016, 11:27:02 AM2/16/16
to twitter-korean-text
네 했습니다 :) 감사합니다!
--
You received this message because you are subscribed to the Google Groups "twitter-korean-text" group.
To unsubscribe from this group and stop receiving emails from it, send an email to twitter-korean-...@googlegroups.com.
To post to this group, send email to twitter-k...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Will Hohyon Ryu
유호현
Senior Software Engineer at Twitter
Reply all
Reply to author
Forward
0 new messages