gpt4 book ai didi

Gradle NoClassDefFoundError

转载 作者:行者123 更新时间:2023-12-04 04:41:40 29 4
gpt4 key购买 nike

所以我正在尝试构建一个简单的gradle应用,当我运行它时,

geb.ConfigurationLoader$UnableToLoadException: Unable to load configuration @ 'file:/Users/john/Development/groovy/gradlegebautomation/build/resources/test/GebConfig.groovy' (with environment: null)
at geb.ConfigurationLoader.loadRawConfig(ConfigurationLoader.groovy:297)
at geb.ConfigurationLoader.loadRawConfig(ConfigurationLoader.groovy:281)
at geb.ConfigurationLoader.getConf(ConfigurationLoader.groovy:161)
at geb.ConfigurationLoader.doGetConf(ConfigurationLoader.groovy:139)
at geb.ConfigurationLoader.getConf(ConfigurationLoader.groovy:95)
at geb.ConfigurationLoader.getConf(ConfigurationLoader.groovy:114)
at geb.spock.GebSpec.createConf(GebSpec.groovy:29)
at geb.spock.GebSpec.createBrowser(GebSpec.groovy:33)
at geb.spock.GebSpec.getBrowser(GebSpec.groovy:38)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at geb.spock.GebReportingSpec.setupSpec(GebReportingSpec.groovy:30)
Caused by: java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport
at java.lang.Class.privateGetDeclaredMethods(Class.java:2436)
at java.lang.Class.getDeclaredMethods(Class.java:1793)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at groovy.grape.GrapeIvy.<init>(GrapeIvy.groovy:75)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at groovy.grape.Grape.getInstance(Grape.java:101)
at groovy.grape.Grape.grab(Grape.java:136)
at groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:291)
at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:319)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:903)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:566)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:542)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:519)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:202)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:212)
at groovy.util.ConfigSlurper.parse(ConfigSlurper.groovy:146)
at geb.ConfigurationLoader.loadRawConfig(ConfigurationLoader.groovy:295)
... 10 more
Caused by: java.lang.ClassNotFoundException: org.apache.ivy.core.report.ResolveReport
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 32 more

因此,我创建了文件夹结构src/test/groovy和src/main/groovy。我还在test/groovy内部创建了另一个名为store的文件夹。因此,如果我将GebConfig.groovy放在src/test/groovy和src/test/groovy/store中,则可以使它工作。还有其他我得到上面的错误。这是我的build.gradle
apply plugin: 'groovy'

repositories {
mavenCentral()
}

dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy', version: '2.0.5'
groovy group: 'org.apache.ivy', name:'ivy', version:'2.2.0'
compile 'org.codehaus.groovy:groovy-all:2.0.5'
testCompile 'junit:junit:4.11'
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
testCompile 'org.gebish:geb-spock:0.9.0-RC-1'
testCompile 'org.seleniumhq.selenium:selenium-firefox-driver:2.31.0'
}

这是我的测试
package groovy.store

import geb.spock.GebReportingSpec

class SimpleSpec extends GebReportingSpec {

def "Doing a simple Guest checkout"() {
given: "A test"
def hello

when: ""
hello = "Hello"

then:
assert hello == "Hello"
}
}

有什么想法吗?

更新v1:

好的,看来我需要在build.gradle中添加一个新的依赖项。我添加了 Ivy 部门,现在我收到此错误:
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileTestGroovy'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:72)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:49)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34)
at org.gradle.api.internal.changedetection.CacheLockHandlingTaskExecuter$1.run(CacheLockHandlingTaskExecuter.java:34)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:179)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:232)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:83)
at org.gradle.api.internal.changedetection.CacheLockHandlingTaskExecuter.execute(CacheLockHandlingTaskExecuter.java:32)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:275)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.executeTask(DefaultTaskPlanExecutor.java:52)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.processTask(DefaultTaskPlanExecutor.java:38)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:30)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:84)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38)
at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:25)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:48)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:39)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:121)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:39)
at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(CompilerDaemonServer.java:52)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)

这是我的GebConfig
import org.openqa.selenium.firefox.FirefoxDriver

//reportsDir = "target/geb-reports"

// default is to use firefox
driver = {
def driver = new FirefoxDriver()
driver.manage().window().maximize()
return driver
}

environments {
'firefox' {
driver = {
def driver = new FirefoxDriver()
driver.manage().window().maximize()
return driver
}
}
}

更新V2:

哦,我看如果我在堆栈中走得更高一点,则会看到以下内容:
startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/Users/john/.gradle/caches/artifacts-23/filestore/org.spockframework/spock-core/0.7-groovy-2.0/jar/4de0b428de0c14b6eb6375d8174f71848cbfc1d7/spock-core-0.7-groovy-2.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception org.spockframework.util.IncompatibleGroovyVersionException: The Spock compiler plugin cannot execute because Spock 0.7.0-groovy-2.0 is not compatible with Groovy 1.8.6. For more information, see http://versioninfo.spockframework.org
Spock location: file:/Users/john/.gradle/caches/artifacts-23/filestore/org.spockframework/spock-core/0.7-groovy-2.0/jar/4de0b428de0c14b6eb6375d8174f71848cbfc1d7/spock-core-0.7-groovy-2.0.jar
Groovy location: file:/Users/john/bin/gradle-1.5/lib/groovy-all-1.8.6.jar

更新v3:

因此,我在我的依赖项中添加了常规规则,请参见上文。我没有通过编译阶段,也没有在测试阶段失败。这是报告中出现的消息
geb.ConfigurationLoader$UnableToLoadException: Unable to load configuration from class 'class GebConfig' (with environment: null)
at geb.ConfigurationLoader.loadRawConfig(ConfigurationLoader.groovy:297)
at geb.ConfigurationLoader.loadRawConfig(ConfigurationLoader.groovy:290)
at geb.ConfigurationLoader.getConf(ConfigurationLoader.groovy:226)
at geb.ConfigurationLoader.doGetConfFromClass(ConfigurationLoader.groovy:200)
at geb.ConfigurationLoader.getConf(ConfigurationLoader.groovy:95)
at geb.ConfigurationLoader.getConf(ConfigurationLoader.groovy:114)
at geb.spock.GebSpec.createConf(GebSpec.groovy:29)
at geb.spock.GebSpec.createBrowser(GebSpec.groovy:33)
at geb.spock.GebSpec.getBrowser(GebSpec.groovy:38)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at geb.spock.GebReportingSpec.setupSpec(GebReportingSpec.groovy:30)
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.forName(Class.java:249)
at groovy.util.ConfigSlurper.parse(ConfigSlurper.groovy:127)
at geb.ConfigurationLoader.loadRawConfig(ConfigurationLoader.groovy:295)
... 10 more
Caused by: java.lang.RuntimeException: No suitable ClassLoader found for grab
at groovy.grape.GrapeIvy.chooseClassLoader(GrapeIvy.groovy:181)
at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:247)
at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:236)
at groovy.grape.Grape.grab(Grape.java:129)
... 13 more

最佳答案

首先困扰我的是,配置文件中没有选择要使用哪种环境的选择;您的第一个 list 说:
最喜欢的

所以我正在尝试构建一个简单的gradle应用,当我运行它时,

无法加载配置@'file:/Users/john/Development/groovy/gradlegebautomation/build/resources/test/GebConfig.groovy'(环境为null)

因此,我可能对此不满意,但我会尝试选择使用哪种环境,例如.environment('firefox')-很抱歉,忘记了语法

关于Gradle NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15710821/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com