Re: [PR] CXF will only accept org.glassfish.jaxb.runtime.v2.ContextFactory [cxf]
reta commented on code in PR #1989: URL: https://github.com/apache/cxf/pull/1989#discussion_r1712666554 ## core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java: ## @@ -1176,18 +1179,48 @@ private static Object createEscapeHandler(Class cls, String simpleClassName) } return null; } + +@SuppressWarnings({ "deprecation", "removal" }) public static JAXBContext createContext(final Set> classes, final Map map) throws JAXBException { JAXBContext ctx = null; try { ctx = AccessController.doPrivileged(new PrivilegedExceptionAction() { public JAXBContext run() throws Exception { -//This is a workaround for CXF-8675 -Class factoryClass = ClassLoaderUtils.loadClass("org.glassfish.jaxb.runtime.v2.ContextFactory", -JAXBContextCache.class); -Method m = factoryClass.getMethod("createContext", Class[].class, Map.class); -Object context = m.invoke(null, classes.toArray(new Class[0]), map); -return (JAXBContext) context; +final String factoryClassName = System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY); Review Comment: @rmannibucau would appreciate if you validate the approach here, I think that would solve the underlying issue and properly instantiate the JAXB provider of choice, thanks in advance! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] CXF-9041: CXF will only accept org.glassfish.jaxb.runtime.v2.ContextFactory [cxf]
rmannibucau commented on code in PR #1989: URL: https://github.com/apache/cxf/pull/1989#discussion_r1712671129 ## core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java: ## @@ -1176,18 +1179,48 @@ private static Object createEscapeHandler(Class cls, String simpleClassName) } return null; } + +@SuppressWarnings({ "deprecation", "removal" }) public static JAXBContext createContext(final Set> classes, final Map map) throws JAXBException { JAXBContext ctx = null; try { ctx = AccessController.doPrivileged(new PrivilegedExceptionAction() { public JAXBContext run() throws Exception { -//This is a workaround for CXF-8675 -Class factoryClass = ClassLoaderUtils.loadClass("org.glassfish.jaxb.runtime.v2.ContextFactory", -JAXBContextCache.class); -Method m = factoryClass.getMethod("createContext", Class[].class, Map.class); -Object context = m.invoke(null, classes.toArray(new Class[0]), map); -return (JAXBContext) context; +final String factoryClassName = System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY); Review Comment: Why not using first JAXBContext factory methods, now it is on jakarta they are there so reflection is not needed and all the new logic looks like the factoryfinder of the jaxb so can be worth avoiding to duplicate for cases it will be different (thinking to OSGi quite loud but I have other cases in mind like some tweaks in EE servers). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] CXF-9041: CXF will only accept org.glassfish.jaxb.runtime.v2.ContextFactory [cxf]
reta commented on code in PR #1989: URL: https://github.com/apache/cxf/pull/1989#discussion_r1712672085 ## core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java: ## @@ -1176,18 +1179,48 @@ private static Object createEscapeHandler(Class cls, String simpleClassName) } return null; } + +@SuppressWarnings({ "deprecation", "removal" }) public static JAXBContext createContext(final Set> classes, final Map map) throws JAXBException { JAXBContext ctx = null; try { ctx = AccessController.doPrivileged(new PrivilegedExceptionAction() { public JAXBContext run() throws Exception { -//This is a workaround for CXF-8675 -Class factoryClass = ClassLoaderUtils.loadClass("org.glassfish.jaxb.runtime.v2.ContextFactory", -JAXBContextCache.class); -Method m = factoryClass.getMethod("createContext", Class[].class, Map.class); -Object context = m.invoke(null, classes.toArray(new Class[0]), map); -return (JAXBContext) context; +final String factoryClassName = System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY); Review Comment: Very valid point, it does look like factoryfinder, but something like should do it: ``` return JAXBContext.newInstance(classes.toArray(new Class[0]), map); ``` Is that what you had in mind? thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@cxf.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org