我想將我的項目從Java 1.6升級到Java 1.8,同時做Gradle構建獲取JIBX綁定編譯Error.If我運行使用Java 1.6它工作正常。Java升級異常從1.6到1.8
我正在使用JIBX版本1.2.5,Gradle 2.9版本.JAVA 1.8.0_71,Groovy 2.4.4。
Attachning我jibx.gradle下面
configurations {
jibx
}
dependencies {
jibx group: 'org.jibx', name: 'jibx-tools', version: '1.2.6'
jibx group: 'org.jibx', name: 'jibx-bind', version: '1.2.6'
jibx group :'org.jibx', name: 'jibx-extras', version:'1.2.6'
}
task generate() {
ant.java(classname: 'org.jibx.binding.Compile', fork: true, classpath: "${configurations.jibx.asPath}") {
arg(line: "-p 'com.cigna.ccmi'")
arg(line: "-t 'src/main/java'")
}
}
def compileJibx() {
ant {
taskdef(name: 'bind',
classname: 'org.jibx.binding.ant.CompileTask',
classpath: configurations.jibx.asPath)
**bind(binding: "${projectDir}/src/main/resources/jibx/common-config-JibX.xml", verbose: 'false')** {
classpath {
pathelement(path: "${projectDir}/build/classes/main")
}
}
}
}
compileJava.dependsOn generate
compileJava.doLast {
compileJibx()
}
在執行綁定方法
附加,我使用的POM
<plugins>
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.6</version>
<configuration>
<schemaBindingDirectory>src/main/resources/jibx</schemaBindingDirectory>
<includeSchemaBindings>
<includeSchemaBindings>common-config-JibX.xml</includeSchemaBindings>
</includeSchemaBindings>
<verbose>true</verbose>
</configuration>
<dependencies>
<!-- Workaround to avoid error compiling with JDK 1.8 -->
<dependency>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<version>6.0-SNAPSHOT</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>bind</goal>
</goals>
</execution>
</executions>
</plugin>
連接錯誤
JIBX插件我收到錯誤* What went wrong:
Execution failed for task ':war:compileJava'.
> JiBXException in JiBX binding compilation
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':war:com
pileJava'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExec
uter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.exec
ute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execut
e(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecu
ter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter
.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execut
e(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter
.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
skWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
skWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(Defaul
tTaskPlanExecutor.java:25)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(Defau
ltTaskGraphExecuter.java:110)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTask
ExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExec
uter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecu
ter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildEx
ecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:30)
at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLa
uncher.java:154)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:151)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGra
dleLauncher.java:32)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:99)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:93)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:93)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:82)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
troller.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(Exe
cuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildA
ctionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
uousBuildActionExecuter.java:77)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
uousBuildActionExecuter.java:47)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.exe
cute(DaemonUsageSuggestingBuildActionExecuter.java:51)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.exe
cute(DaemonUsageSuggestingBuildActionExecuter.java:28)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.jav
a:170)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
meValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
meValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
trap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
ava:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: : JiBXException in JiBX binding compilation
at org.jibx.binding.ant.CompileTask.execute(CompileTask.java:252)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(Bas
icAntBuilder.java:78)
at org.gradle.api.internal.project.ant.BasicAntBuilder.doInvokeMethod(Ba
sicAntBuilder.java:93)
at jibx_50hfomxu8u1392vt31qdevxoj$_compileJibx_closure5.doCall(C:\sandee
p\JavaUpgrade\DI-services\war\jibx.gradle:32)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedActi
on.java:67)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
at org.gradle.api.internal.project.AbstractProject.ant(AbstractProject.j
ava:816)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMeth
od(BeanDynamicObject.java:235)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObj
ect.java:130)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(Composite
DynamicObject.java:150)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:
79)
at jibx_50hfomxu8u1392vt31qdevxoj.compileJibx(C:\sandeep\JavaUpgrade\DI-
services\war\jibx.gradle:27)
at jibx_50hfomxu8u1392vt31qdevxoj$_run_closure4.doCall(C:\sandeep\JavaUp
grade\DI-services\war\jibx.gradle:42)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(Abstra
ctTask.java:554)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(Abstra
ctTask.java:535)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:61)
... 57 more
Caused by: org.jibx.runtime.JiBXException: Error running binding compiler
at org.jibx.binding.Compile.compile(Compile.java:318)
at org.jibx.binding.ant.CompileTask.execute(CompileTask.java:248)
... 76 more
Caused by: java.lang.IllegalStateException: Error loading class java.lang.CharSe
quence: Error reading path java/lang/CharSequence.class for class java.lang.Char
Sequence
at org.jibx.binding.classes.ClassCache$ClassCacheLocator.getClassInfo(Cl
assCache.java:291)
at org.jibx.binding.model.ClassHierarchyContext.accumulateInterfaces(Cla
ssHierarchyContext.java:95)
at org.jibx.binding.model.ClassHierarchyContext.addTypedComponent(ClassH
ierarchyContext.java:121)
at org.jibx.binding.model.DefinitionContext.addFormat(DefinitionContext.
java:527)
at org.jibx.binding.model.BindingElement.defineBaseFormat(BindingElement
.java:843)
at org.jibx.binding.model.BindingElement.runValidation(BindingElement.ja
va:865)
at org.jibx.binding.model.BindingElement.runValidation(BindingElement.ja
va:899)
at org.jibx.binding.model.BindingElement.validateBinding(BindingElement.
java:969)
at org.jibx.binding.Utility.validateBinding(Utility.java:226)
at org.jibx.binding.Utility.loadBinding(Utility.java:269)
at org.jibx.binding.Utility.loadFileBinding(Utility.java:420)
at org.jibx.binding.Compile.compile(Compile.java:217)
... 77 more
BUILD FAILED
請提供更多的信息,這樣的錯誤消息 – manniL
看來JiBX使用BCEL。您可能需要升級庫才能使用java編譯8 – Jayan
@manniL:我附加了完整的錯誤。你可以請看看它。 – Sachin