jakartaee / jakartaee/jaxb-api

JAXBContext.newInstance(Class..., ClassLoader) missing?

Open
#243 4 comments 0 reactions 1 assignee Claimed by @glassfishrobot View on GitHub
4.1 enhancement Major
Dominant language
Java
Stars
79
Forks
48
Avg merge
7h 12m
Merged PRs (30d)
2

Description

Hi folks,
I need to define my own Classloader, and because in the JAXB-API is no method like:
public static JAXBContext newInstance(Class..., ClassLoader)

and only one like:
public static JAXBContext newInstance(String, ClassLoader)

is it possible to add a newInstance(Class..., ClassLoader)-method
or could somebody explain me, what I have to do,
the following example code will run:

JAXBContext ctx;
//works perfectly for me!
ctx = JAXBContext.newInstance(HelloWorld.class);

//says: "package org.mypackage" doesnt contain ObjectFactory.class or jaxb.index"
ctx = JAXBContext.newInstance("org.mypackage");

//says: "package org.mypackage" doesnt contain ObjectFactory.class or jaxb.index"
ctx = JAXBContext.newInstance(HelloWorld.class.getPackage().toString());

//something like this would be nice
ctx = JAXBContext.newInstance(HelloWorld.class, this.getClass().getClassLoader());

is it possible to resolve the "package org.mypackage" doesnt contain
ObjectFactory.class or jaxb.index" automatically or to provide an
newInstance(Class..., ClassLoader)-method, because this would fit the best and
make the create the JAXBContext.newInstance()-process more chubbier.

regards
Flori
#### Environment
Operating System: All
Platform: All
#### Affected Versions
[2.2]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.