Bug 1125077 - A project which contains interface java classes fails to build with "JAXB can't handle interfaces."
Summary: A project which contains interface java classes fails to build with "JAXB can...
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.0.2
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: DR1
: 6.3.0
Assignee: Shelly McGowan
QA Contact: Lukáš Petrovický
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-31 03:19 UTC by Toshiya Kobayashi
Modified: 2019-07-11 08:05 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Enhancement


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1125159 None None None Never

Internal Links: 1125159

Description Toshiya Kobayashi 2014-07-31 03:19:33 UTC
Description of problem:

If a project contains interface java classes, project build fails with the message like:

12:07:48,761 ERROR [org.jbpm.console.ng.bd.backend.server.DeploymentManagerEntryPointImpl] (http-localhost.localdomain/127.0.0.1:8080-6) Deployment of unit org.kie.example:project1:1.0.0-SNAPSHOT failed: Unable to instantiate JAXBContext for deployment 'org.kie.example:project1:1.0.0-SNAPSHOT'.: org.jbpm.console.ng.bd.exception.DeploymentException: Unable to instantiate JAXBContext for deployment 'org.kie.example:project1:1.0.0-SNAPSHOT'.
	at org.jbpm.console.ng.bd.backend.server.DeploymentManagerEntryPointImpl.deploy(DeploymentManagerEntryPointImpl.java:119) [jbpm-console-ng-business-domain-backend-6.0.3-redhat-4.jar:6.0.3-redhat-4]
	at org.jbpm.console.ng.bd.backend.server.DeploymentManagerEntryPointImpl.deploy(DeploymentManagerEntryPointImpl.java:103) [jbpm-console-ng-business-domain-backend-6.0.3-redhat-4.jar:6.0.3-redhat-4]
	at org.jbpm.console.ng.bd.backend.server.DeploymentManagerEntryPointImpl.process(DeploymentManagerEntryPointImpl.java:245) [jbpm-console-ng-business-domain-backend-6.0.3-redhat-4.jar:6.0.3-redhat-4]
	at org.jbpm.console.ng.bd.backend.server.DeploymentManagerEntryPointImpl$Proxy$_$$_WeldClientProxy.process(DeploymentManagerEntryPointImpl$Proxy$_$$_WeldClientProxy.java) [jbpm-console-ng-business-domain-backend-6.0.3-redhat-4.jar:6.0.3-redhat-4]
	at org.guvnor.common.services.builder.BuildServiceImpl.buildAndDeploy(BuildServiceImpl.java:108) [guvnor-project-builder-6.0.3-redhat-4.jar:6.0.3-redhat-4]
...
Caused by: java.lang.IllegalStateException: Unable to instantiate JAXBContext for deployment 'org.kie.example:project1:1.0.0-SNAPSHOT'.
	at org.kie.remote.services.rest.jaxb.DynamicJaxbContext.setupDeploymentJaxbContext(DynamicJaxbContext.java:225) [kie-services-remote-6.0.3-redhat-4.jar:6.0.3-redhat-4]
	at org.kie.remote.services.rest.jaxb.DynamicJaxbContext.setupDeploymentJaxbContext(DynamicJaxbContext.java:152) [kie-services-remote-6.0.3-redhat-4.jar:6.0.3-redhat-4]
...
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.kie.example.project1.MyInterface is an interface, and JAXB can't handle interfaces.
	this problem is related to the following location:
		at org.kie.example.project1.MyInterface

	at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106) [jaxb-impl-2.2.5-redhat-5.jar:2.2.5-redhat-5]
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:466) [jaxb-impl-2.2.5-redhat-5.jar:2.2.5-redhat-5]
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:298) [jaxb-impl-2.2.5-redhat-5.jar:2.2.5-redhat-5]
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141) [jaxb-impl-2.2.5-redhat-5.jar:2.2.5-redhat-5]
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1163) [jaxb-impl-2.2.5-redhat-5.jar:2.2.5-redhat-5]
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145) [jaxb-impl-2.2.5-redhat-5.jar:2.2.5-redhat-5]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45]
	at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:211) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-2.jar:1.0.4.Final-redhat-2]
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:392) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-2.jar:1.0.4.Final-redhat-2]
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:618) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-2.jar:1.0.4.Final-redhat-2]
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:565) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-2.jar:1.0.4.Final-redhat-2]
	at org.kie.remote.services.rest.jaxb.DynamicJaxbContext.setupDeploymentJaxbContext(DynamicJaxbContext.java:221) [kie-services-remote-6.0.3-redhat-4.jar:6.0.3-redhat-4]
	... 96 more


Steps to Reproduce:
1. Create a new project in business-central
2. Clone the project to local filesystem
3. Add an interface java source to the project (e.g. ./project1/src/main/java/org/kie/example/project1/MyInterface.java)

===
package org.kie.example.project1;

public interface MyInterface {

}
===

4. Commit and push
5. Press "Build&Deploy"

Actual results:

Build fails with the message:

12:07:48,761 ERROR [org.jbpm.console.ng.bd.backend.server.DeploymentManagerEntryPointImpl] (http-localhost.localdomain/127.0.0.1:8080-6) Deployment of unit org.kie.example:project1:1.0.0-SNAPSHOT failed: Unable to instantiate JAXBContext for deployment 'org.kie.example:project1:1.0.0-SNAPSHOT'.: org.jbpm.console.ng.bd.exception.DeploymentException: Unable to instantiate JAXBContext for deployment 'org.kie.example:project1:1.0.0-SNAPSHOT'.
...
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.kie.example.project1.MyInterface is an interface, and JAXB can't handle interfaces.
	this problem is related to the following location:
		at org.kie.example.project1.MyInterface

Expected results:

Build successful

Comment 2 Marco Rietveld 2014-11-21 12:20:27 UTC
For those following the bugs: this is not a kie-wb/BPMS issue: this is a matter of adding documentation about JAXB usage: JAXB can not handle fields that are interfaces without adding specific JAXB annotations to the field.

Comment 3 Toshiya Kobayashi 2014-11-25 00:56:47 UTC
Yes... but does this mean that users have to add JAXB annotations to all interfaces in a project in business-cental? (Note that users may not use those interfaces for REST access)

Comment 5 Marco Rietveld 2015-02-06 12:47:31 UTC
Users need to do the following: 

- do not add JAXB annotations to interfaces
- do not use interfaces classes to define fields

Basically, they need to follow JAXB conventions when annotating classes with JAXB annotations.

Comment 6 Toshiya Kobayashi 2015-02-09 05:10:41 UTC
Ah, sorry, Marco. Please forget my stupid comment#3.

My main point is that users may want to add their own classes/interfaces to implement internal logic, not as data models. However, DynamicJaxbContext.setupDeploymentJaxbContext() picks up *all* classes/interfaces in a project to JAXBContext.newInstance() so results in the Exception. If it's expected, we would need to document guidance like:

"All Java sources in a project are considered as data models so need to follow JAXB conventions."

Is it fine?

Comment 8 Zuzana Krejčová 2016-03-02 09:18:10 UTC
Verified with DR2 - interface is automatically excluded from serialization.


Note You need to log in before you can comment on or make changes to this bug.