2012-08-28 3 views
0

우리는 사용자 정의 Google GUICE 기반 애플리케이션 모듈과 함께 재생 프레임 워크 (play-1.2.5)를 사용하는 프로젝트를 진행하고 있습니다.기본 클래스 로더 및 PlayFramework 사용자 정의 클래스 로더와의 충돌

나는 내 코드에서 현재 예외를 얻고있다 :

play.exceptions.JavaExecutionException: loader constraint violation: when resolving method "mypackage.Runner.queueJob(Lmodels/Job;)V" the class loader (instance of play/classloading/ApplicationClassloader) of the current class, controllers/Jobs, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for resolved class, mypackage/Runner, have different Class objects for the type models/Job used in the signature 
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:237) 
    at Invocation.HTTP Request(Play!) 
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "mypackage.Runner.queueJob(Lmodels/Job;)V" the class loader (instance of play/classloading/ApplicationClassloader) of the current class, controllers/Job, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for resolved class, mypackage/Runner, have different Class objects for the type models/Job used in the signature 
    at controllers.Jobs.listJobs(Jobs.java:19) 
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:557) 
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:508) 
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:484) 
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:479) 
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161) 
    ... 1 more 

을 내 현재의 분석에 따르면 문제가 소스 폴더 구조와 관련된 응용 프로그램이 어떻게 초기화 것처럼 보인다.

I의 구조는 다음과 같습니다

프로젝트/응용 프로그램/{플레이 컨트롤러와 모델 등} 재생 응용 프로그램을 시작할 때

프로젝트/SRC/{비즈니스 로직을 구현하는 내 프로젝트 특정 클래스} 또한 "src"폴더 (작업 관리 응용 프로그램 클래스 바깥 쪽)에서 작업을 시작합니다. 무슨 일이 일어날 것 같아요 모델과 다른 클래스는 이러한 작업에 의해 액세스 할 때 기본 클래스 - 로더와 함께이 시간에로드되면, 내가 플레이 응용 프로그램 클래스 (보기 등)에서 이것을 사용하려고 할 때 나는이 오류를 말하는 사용 된 클래스는 다른 클래스 로더로 작성되므로 다른 서명을 가지게됩니다.

결론적으로 기본 클래스 로더와 재생 클래스 로더는 동일한 클래스를로드하며 호출 방법에 따라 미스 매치 오류가 발생합니다.

나는 모든 소스 파일을 project/app/source 폴더로 옮기는 것으로이 문제를 해결할 수 있었지만 src 폴더를 재생 응용 프로그램 폴더와 별도로 유지하고 싶습니다.

  1. 분석에 맞는지 누구에게 알 수 있습니까?
  2. 1. "예"인 경우 앱 폴더의 클래스를로드 할뿐만 아니라 내 src 폴더에서도 재생을 구성 할 수 있습니까?

모든 의견을 환영합니다.

답변

1

"src"폴더를 Play.javaPath 목록에 추가하여 Play에서 클래스를 컴파일하고로드 할 수 있습니다.