2016-02-15 181 views
0

我想將我的項目從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 
+2

請提供更多的信息,這樣的錯誤消息 – manniL

+0

看來JiBX使用BCEL。您可能需要升級庫才能使用java編譯8 – Jayan

+0

@manniL:我附加了完整的錯誤。你可以請看看它。 – Sachin

回答

1

我正面臨類似的Jibx和java 8兼容問題。

好消息:Jibx與Java 8一起工作!

我檢查了依賴關係樹,並且bcel 5.0仍然存在(甚至在排除其中一個依賴關係之後)。使用maven中的mvn dependency:tree命令檢查依賴關係樹。

在gradle gradle dependencies應該有希望工作(不確定)。

這裏是我做了什麼來解決這個問題:

在我的pom.xml

1.增加了對BCEL-6.0快照依賴以下庫

<repositories> 
     <repository> 
      <id>apache.snapshots</id> 
      <url>https://repository.apache.org/content/repositories/snapshots</url> 
      <snapshots> 
       <enabled>true</enabled> 
       <updatePolicy>always</updatePolicy> 
      </snapshots> 
      <releases> 
       <enabled>false</enabled> 
      </releases> 
     </repository> 
    </repositories> 

2.從所有相關性中排除默認包:

<!-- JiBX --> 
     <dependency> 
      <groupId>org.jibx</groupId> 
      <artifactId>jibx-run</artifactId> 
      <version>${jibx.version}</version> 
      <exclusions> 
       <exclusion> 
        <artifactId>bcel</artifactId> 
        <groupId>bcel</groupId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.jibx</groupId> 
      <artifactId>jibx-extras</artifactId> 
      <version>${jibx.version}</version> 
      <exclusions> 
       <exclusion> 
        <artifactId>bcel</artifactId> 
        <groupId>bcel</groupId> 
       </exclusion> 
      </exclusions> 
      <optional>true</optional> 
     </dependency> 
     <dependency> 
      <groupId>org.jibx</groupId> 
      <artifactId>jibx-bind</artifactId> 
      <version>${jibx.version}</version> 
      <exclusions> 
       <exclusion> 
        <artifactId>bcel</artifactId> 
        <groupId>bcel</groupId> 
       </exclusion> 
      </exclusions> 
     </dependency> 

3.在需要的地方添加了BCEL 6.0快照依賴關係。

<plugin> 
      <groupId>org.apache.cxf</groupId> 
      <artifactId>cxf-codegen-plugin</artifactId> 
      <version>${cxf.version}</version> 
      <executions> 
       <execution> 
        <phase>generate-sources</phase> 
        <configuration> 
         <sourceRoot>${project.build.directory}/generated-sources</sourceRoot> 
         <wsdlOptions> 
          <wsdlOption> 
           <wsdl>${project.basedir}/src/main/resources/abc.wsdl</wsdl> 
           <dataBinding>jibx</dataBinding> 
           <extraargs> 
            <extraarg>-nexclude</extraarg> 
            <extraarg>http://cs.xyz.abc.com/ws</extraarg> 
           </extraargs> 
          </wsdlOption> 
         </wsdlOptions> 
        </configuration> 
        <goals> 
         <goal>wsdl2java</goal> 
        </goals> 
       </execution> 
      </executions> 
      <!-- added dependency to avoid jibx-java8 compatibility issues --> 
      <dependencies> 
       <dependency> 
        <groupId>org.apache.bcel</groupId> 
        <artifactId>bcel</artifactId> 
        <version>6.0-SNAPSHOT</version> 
       </dependency> 
      </dependencies> 
     </plugin> 

 <plugin> 
       <groupId>org.jibx</groupId> 
       <artifactId>jibx-maven-plugin</artifactId> 
       <version>${jibx.version}</version> 
       <executions> 
        <!-- generate code from schema using JiBX with customization --> 
        <!-- This process will generate the 'cs.abc.axy.com.types' source 
         classes and the JiBX binding definition file at the default location: ${project.build.directory}/generated-sources/binding.xml --> 
        <execution> 
         <id>generate-java-code-from-schema</id> 
         <phase>generate-sources</phase> 
         <goals> 
          <goal>schema-codegen</goal> 
         </goals> 
         <configuration> 
          <schemaLocation>${project.basedir}/src/main/resources</schemaLocation> 
          <customizations> 
           <customization>${project.basedir}/src/main/config/custom-jibx-codegen.xml</customization> 
          </customizations> 
         </configuration> 
        </execution> 
        <!-- run the JiBX binding compiler --> 
        <!-- The binding.xml file at the default location will be used here. --> 
        <execution> 
         <id>compile-binding</id> 
         <goals> 
          <goal>bind</goal> 
         </goals> 
         <configuration> 
          <schemaBindingDirectory>${project.build.directory}/generated-sources</schemaBindingDirectory> 
          <includeSchemaBindings> 
           <includeSchemaBinding>binding.xml</includeSchemaBinding> 
          </includeSchemaBindings> 
         </configuration> 
        </execution> 
       </executions> 
       <!-- added dependency to avoid jibx-java8 compatibility issues --> 
       <dependencies> 
        <dependency> 
         <groupId>org.apache.bcel</groupId> 
         <artifactId>bcel</artifactId> 
         <version>6.0-SNAPSHOT</version> 
        </dependency> 
       </dependencies> 
     </plugin> 

4.刪除/刷新我的.m2目錄directory.You可能需要進行重新編制或類似的老倉庫的東西刪除。

我希望這有助於..

+0

這幫助我解決了我的問題,但是我相信你只需要將bcel從jibx-bind作爲插件部分的一部分排除,因爲jibx-bind引入了bcel依賴關係,並且jibx-run和jibx-extras都不依賴於jibx-綁定。 – Omaha

0

我有一個類似的錯誤。只需更新JIBX依賴1.3.1

<!-- Jibx run --> 
<dependency> 
    <groupId>org.jibx</groupId> 
    <artifactId>jibx-run</artifactId> 
    <version>1.3.1</version> 
</dependency>