2011-05-14 4 views
0

그라데이션 스크립트에서 클래스를로드하는 데 문제가 있습니다. 나는이 코드를 실행하면 :Jaxp 문제가 있습니까? 그라디언트를 사용하여 org.apache.xerces.jaxp.DocumentBuilderFactoryImpl을 찾을 수 없습니다.

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath(group:"xerces", name:'xercesImpl', version:'2.9.1') 
    } 
} 

task hello { 
    doLast { 
     println 'Hello world!' 
     Class testClass = Class.forName("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl") 
     assert testClass: "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found" 
     println "found" 
    } 
} 

을 내가 "Gradle을 안녕하세요"를 실행했을 때이 얻을 : java.lang.ClassNotFoundException가 :의 org.apache.xerces.jaxp.DocumentBuilderFactoryImpl "

을 내가 JAXP의 된 구현에 문제를 의심 하지만 방법 JAXP 작품에 대해 잘 모른다. 어떤 도움

감사를

이 이 같은

답변

0

겠습니까 뭔가가 충분?

import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; 

buildscript { 
    repositories { 
     mavenCentral() 
    } 

    dependencies { 
     classpath group:"xerces", name:'xercesImpl', version:'2.9.1' 
    } 
} 

task hello { 
     println 'Hello world!' 
     DocumentBuilderFactoryImpl obj = new DocumentBuilderFactoryImpl() 
     // do something with obj 
} 
0

대신 getClass().getClassLoader()을 시도하십시오. Class.forName()은 전혀 사용하지 않아야합니다. Java에서 호출 할 때 알려진 문제점이 있으며 Groovy에서 호출 할 때 완전히 신뢰할 수 없습니다. 일반적으로 호출자의 클래스 로더 대신 Groovy 라이브러리의 클래스 로더를 가져옵니다.

관련 문제