2011-05-04 2 views
6

에 대한 찾을 수 없습니다 적합 클래스 로더 ...일반 오류 : 나는 아래의 코드를 시도했습니다 잡아

@Grapes([ 
    @Grab('org.hsqldb:hsqldb:2.0.0'), 
    @GrabConfig(systemClassLoader=true, initContextClassLoader=true) 
]) 
import groovy.sql.Sql 
println Class.forName('org.hsqldb.jdbc.JDBCDriver').newInstance() 

그것은 groovyConsole에 작동하지만, Web Start를 실행하지 못했습니다. 다음은 오류 메시지입니다.

startup failed: 
General error during conversion: No suitable ClassLoader found for grab 

java.lang.RuntimeException: No suitable ClassLoader found for grab 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) 
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) 
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190) 
    at groovy.grape.GrapeIvy.chooseClassLoader(GrapeIvy.groovy:173) 
    at groovy.grape.GrapeIvy$chooseClassLoader.callCurrent(Unknown Source) 
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141) 
    at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:239) 
    at groovy.grape.Grape.grab(Grape.java:141) 
    at groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:282) 
    at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:302) 
    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:839) 
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:544) 
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:520) 
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:497) 
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306) 
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287) 
    at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731) 
    at groovy.lang.GroovyShell.parse(GroovyShell.java:743) 
    at groovy.lang.GroovyShell.parse(GroovyShell.java:698) 
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:648) 
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:636) 
    at com.lyhdev.mrcode.ScriptLoader.loadGroovy(Unknown Source) 
    at com.lyhdev.mrcode.ScriptLoader$loadGroovy.call(Unknown Source) 
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) 
    at Script1.run(Script1.groovy:30) 
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:650) 
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:636) 
    at com.lyhdev.mrcode.ScriptLoader.loadGroovy(Unknown Source) 
    at com.lyhdev.mrcode.ScriptLoader.main(Unknown Source) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.sun.javaws.Launcher.executeApplication(Launcher.java:1804) 
    at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1750) 
    at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1512) 
    at com.sun.javaws.Launcher.run(Launcher.java:130) 
    at java.lang.Thread.run(Thread.java:662) 

1 error 

답변

1

모든 클래스 로더가 관련되어 있습니다. 예를 들어 ant에서 groovy를 실행하는 것과 동일한 문제가 발생합니다. 나는 시스템 클래스 로더가 개미 또는 웹 시작 아래 그루비를 실행할 때 그루비 클래스 로더 또는 루트 로더가 아니기 때문에 나는 보인다. GrapeIvy.groovy에서 isValidTargetClassLoader()를 참조하십시오.

문제의 해결책 중 하나는 그루비 RootLoader가 있는지 확인하고 스크립트에 필요한 모든 classpath를 추가 한 다음 Groovy 스크립트/클래스에서 앱을 실행하는 것입니다. 웹 시작으로는 까다로울 것입니다.

관련 문제