I am trying to upgrade my project from Java 1.6 to Java 1.8, While doing Gradle build am getting JIBX binding compilation Error.If I run using Java 1.6 it works fine.
I am using JIBX version 1.2.5, Gradle 2.9 version.JAVA 1.8.0_71, Groovy 2.4.4.
Attachning my jibx.gradle below
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()
}
I am getting error while executing the bind method
Attaching JIBX plugin that i am using in 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>
attaching the error
* 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
I was facing a similar issue of Jibx and java 8 compatibility.
Good news : Jibx does work with Java 8!!
I checked the dependency tree and bcel 5.0 still existed(even after excluding from one of the dependencies) .Check the dependency tree using mvn dependency:tree
command in maven.
In gradle gradle dependencies
should work hopefully(Not sure).
Here is what I have done to resolve the issue:
In my pom.xml:
1. Added the following repository for bcel-6.0 snapshot dependency
<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. Excluded the default bcel from all the dependencies:
<!-- 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. Added the BCEL 6.0 snapshot dependency where ever it was needed.
<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>
And
<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. Deleted/ Refreshed my .m2 directory.You may need to perform reindexing or something similar to deletion of old repositories.
I hope this helps..