when execute BusinessArchiveFactory.readBusinessArchive , it throws error :
java.lang.ExceptionInInitializerError: Exception javax.xml.bind.DataBindingException: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
the Java version is 17.0.11 and the Bonita Client version is 10.1.0
how can i fixed this bug or is there a workaround?
1 Like
the pom.xml is like this
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.test</groupId>
<artifactId>test-bonita</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>test-bonita</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bonita.bpm.version>10.1.0</bonita.bpm.version>
</properties>
<dependencies>
<dependency>
<groupId>org.bonitasoft.engine</groupId>
<artifactId>bonita-client</artifactId>
<version>${bonita.bpm.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
1 Like
Hi @scottyang
Could you please give a bit more context?
For example are you doing this from a Bonita Studio? If yes, which version?
Thanks!
1 Like
I did it with Bonita -Studio 2024.2 and bonita-client-10.1.0 and jdk17.0.12.
here is part of the code
package com.example.test;
import com.example.Start;
import com.example.util.BonitaBaseUtil;
import org.bonitasoft.engine.api.APIClient;
import org.bonitasoft.engine.api.MaintenanceAPI;
import org.bonitasoft.engine.bpm.bar.BusinessArchive;
import org.bonitasoft.engine.bpm.bar.BusinessArchiveFactory;
import org.bonitasoft.engine.bpm.bar.InvalidBusinessArchiveFormatException;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.Assert;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@SpringBootTest(classes={Start.class })
public class BonitaTest {
@Autowired
public BonitaBaseUtil bonitaUtil;
@Test
public void bonitaMaintenanceTest(){
try {
APIClient apiClient = bonitaUtil.getApiClient();
File bar = new File("D:\\test.bar");
BusinessArchive businessArchive = BusinessArchiveFactory.readBusinessArchive(bar);
Assert.notNull(businessArchive, "get business archive failed");
} catch (FileNotFoundException e) {
System.out.println("please ensure the bar file exists.");
throw new RuntimeException(e);
} catch (InvalidBusinessArchiveFormatException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
and here is the test result
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.198 s <<< FAILURE! - in com.example.test.BonitaTest
[ERROR] com.example.test.BonitaTest.bonitaMaintenanceTest Time elapsed: 1.306 s <<< ERROR!
java.lang.ExceptionInInitializerError
at com.example.test.BonitaTest.bonitaMaintenanceTest(BonitaTest.java:30)
Caused by: javax.xml.bind.DataBindingException:
javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
at com.example.test.BonitaTest.bonitaMaintenanceTest(BonitaTest.java:30)
Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
at com.example.test.BonitaTest.bonitaMaintenanceTest(BonitaTest.java:30)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
at com.example.test.BonitaTest.bonitaMaintenanceTest(BonitaTest.java:30)
1 Like
Can you check that your are not overriding the jaxb version in your project.
Executing a mvn dependency:tree
can give you some hints on how Maven handle versions conflicts.
Note that if you are integrating bonita-client into a spring application make sure to be in version 2.x of springboot or 5.x of springframework.
1 Like
To complete @romain.bioteau 's answer, bonita-client pulls the following dependencies, so you SHOULD have jaxb-api transitively:
------------------------------------------------------------
Project ':bpm:bonita-client'
------------------------------------------------------------
runtimeClasspath - Runtime classpath of source set 'main'.
+--- project :bpm:bonita-common
| +--- com.fasterxml.jackson:jackson-bom:2.18.2
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.18.2 (c)
| | +--- com.fasterxml.jackson.core:jackson-databind:2.18.2 (c)
| | \--- com.fasterxml.jackson.core:jackson-core:2.18.2 (c)
| +--- org.bonitasoft.engine:bonita-artifacts-model-dependencies:1.1.2
| | +--- org.bonitasoft.engine:bonita-business-archive:1.1.2 (c)
| | +--- org.bonitasoft.engine:bonita-business-object-model:1.1.2 (c)
| | +--- org.bonitasoft.engine:bonita-profile-model:1.1.2 (c)
| | +--- org.bonitasoft.engine:bonita-organization-model:1.1.2 (c)
| | +--- org.bonitasoft.engine:bonita-application-model:1.1.2 (c)
| | +--- com.sun.activation:jakarta.activation:1.2.2 (c)
| | +--- org.bonitasoft.engine:bonita-process-definition-model:1.1.2 (c)
| | +--- org.bonitasoft.engine:bonita-form-mapping-model:1.1.2 (c)
| | +--- javax.xml.bind:jaxb-api:2.3.1 (c)
| | +--- org.glassfish.jaxb:jaxb-runtime:2.3.1 (c)
| | +--- org.glassfish.hk2:osgi-resource-locator:2.4.0 (c)
| | \--- org.bonitasoft.engine:bonita-common-artifacts-model:1.1.2 (c)
| +--- org.bonitasoft.engine:bonita-business-archive -> 1.1.2
| | +--- org.bonitasoft.engine:bonita-process-definition-model:1.1.2
| | | +--- org.bonitasoft.engine:bonita-common-artifacts-model:1.1.2
| | | | +--- javax.xml.bind:jaxb-api:2.3.1
| | | | +--- org.glassfish.jaxb:jaxb-runtime:2.3.1
| | | | | +--- javax.xml.bind:jaxb-api:2.3.1
| | | | | +--- org.glassfish.jaxb:txw2:2.3.1
| | | | | +--- com.sun.istack:istack-commons-runtime:3.0.7
| | | | | +--- org.jvnet.staxex:stax-ex:1.8
| | | | | \--- com.sun.xml.fastinfoset:FastInfoset:1.2.15
| | | | \--- com.sun.activation:jakarta.activation:1.2.2
| | | +--- javax.xml.bind:jaxb-api:2.3.1
| | | \--- com.sun.activation:jakarta.activation:1.2.2
| | +--- org.bonitasoft.engine:bonita-form-mapping-model:1.1.2
| | | +--- javax.xml.bind:jaxb-api:2.3.1
| | | +--- org.glassfish.jaxb:jaxb-runtime:2.3.1 (*)
| | | +--- com.sun.activation:jakarta.activation:1.2.2
| | | \--- org.glassfish.hk2:osgi-resource-locator:2.4.0
| | +--- javax.xml.bind:jaxb-api:2.3.1
| | +--- org.glassfish.jaxb:jaxb-runtime:2.3.1 (*)
| | +--- com.sun.activation:jakarta.activation:1.2.2
| | \--- org.glassfish.hk2:osgi-resource-locator:2.4.0
| +--- org.bonitasoft.engine:bonita-business-object-model -> 1.1.2
| | +--- javax.xml.bind:jaxb-api:2.3.1
| | +--- org.glassfish.jaxb:jaxb-runtime:2.3.1 (*)
| | +--- com.sun.activation:jakarta.activation:1.2.2
| | +--- org.glassfish.hk2:osgi-resource-locator:2.4.0
| | \--- org.slf4j:slf4j-api:1.7.36
| +--- org.bonitasoft.engine:bonita-profile-model -> 1.1.2
| | +--- org.bonitasoft.engine:bonita-common-artifacts-model:1.1.2 (*)
| | +--- javax.xml.bind:jaxb-api:2.3.1
| | +--- org.glassfish.jaxb:jaxb-runtime:2.3.1 (*)
| | +--- com.sun.activation:jakarta.activation:1.2.2
| | \--- org.glassfish.hk2:osgi-resource-locator:2.4.0
| +--- org.bonitasoft.engine:bonita-organization-model -> 1.1.2
| | +--- org.bonitasoft.engine:bonita-common-artifacts-model:1.1.2 (*)
| | +--- javax.xml.bind:jaxb-api:2.3.1
| | +--- org.glassfish.jaxb:jaxb-runtime:2.3.1 (*)
| | +--- com.sun.activation:jakarta.activation:1.2.2
| | \--- org.glassfish.hk2:osgi-resource-locator:2.4.0
| +--- org.bonitasoft.engine:bonita-application-model -> 1.1.2
| | +--- org.bonitasoft.engine:bonita-common-artifacts-model:1.1.2 (*)
| | +--- javax.xml.bind:jaxb-api:2.3.1
| | +--- org.glassfish.jaxb:jaxb-runtime:2.3.1 (*)
| | +--- com.sun.activation:jakarta.activation:1.2.2
| | \--- org.glassfish.hk2:osgi-resource-locator:2.4.0
| +--- com.fasterxml.jackson.core:jackson-databind -> 2.18.2
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.18.2
| | | \--- com.fasterxml.jackson:jackson-bom:2.18.2 (*)
| | +--- com.fasterxml.jackson.core:jackson-core:2.18.2
| | | \--- com.fasterxml.jackson:jackson-bom:2.18.2 (*)
| | \--- com.fasterxml.jackson:jackson-bom:2.18.2 (*)
| +--- org.slf4j:slf4j-api:1.7.36
| +--- com.fasterxml.jackson.core:jackson-annotations -> 2.18.2 (*)
| \--- com.sun.activation:jakarta.activation -> 1.2.2
+--- org.apache.httpcomponents:httpclient:4.5.14
| +--- org.apache.httpcomponents:httpcore:4.4.16
| +--- commons-logging:commons-logging:1.2
| \--- commons-codec:commons-codec:1.11
+--- com.thoughtworks.xstream:xstream:1.4.21
| \--- io.github.x-stream:mxparser:1.2.2
| \--- xmlpull:xmlpull:1.1.3.1
\--- org.apache.httpcomponents:httpmime:4.5.14
\--- org.apache.httpcomponents:httpclient:4.5.14 (*)
1 Like