You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Arjan Tijms (JIRA)" <ji...@apache.org> on 2013/01/26 23:27:13 UTC
[jira] [Commented] (TOMEE-249) NPE on DatatypeConverter
[ https://issues.apache.org/jira/browse/TOMEE-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13563661#comment-13563661 ]
Arjan Tijms commented on TOMEE-249:
-----------------------------------
Encountered the same issue using OmniFaces on TomEE 1.5.1. Since this was fixed in 1.5.0 I tried that one too, but the same problem.
Stack:
Caused by: java.lang.NullPointerException
at javax.xml.bind.DatatypeConverter.printBase64Binary(DatatypeConverter.java:173)
at org.omnifaces.util.Utils.serializeURLSafe(Utils.java:375)
at org.omnifaces.resourcehandler.CombinedResourceInfo.toUniqueId(CombinedResourceInfo.java:304)
at org.omnifaces.resourcehandler.CombinedResourceInfo.access$000(CombinedResourceInfo.java:38)
at org.omnifaces.resourcehandler.CombinedResourceInfo$Builder.create(CombinedResourceInfo.java:118)
at org.omnifaces.resourcehandler.CombinedResourceHandler$CombinedResourceBuilder.create(CombinedResourceHandler.java:433)
at org.omnifaces.resourcehandler.CombinedResourceHandler$CombinedResourceBuilder.create(CombinedResourceHandler.java:381)
at org.omnifaces.resourcehandler.CombinedResourceHandler.processEvent(CombinedResourceHandler.java:227)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:43)
at org.apache.myfaces.application.ApplicationImpl._traverseListenerList(ApplicationImpl.java:2410)
at org.apache.myfaces.application.ApplicationImpl.access$000(ApplicationImpl.java:119)
at org.apache.myfaces.application.ApplicationImpl$SystemListenerEntry.publish(ApplicationImpl.java:2601)
at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:592)
at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:607)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:84)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
The code we're using:
InputStream raw = new ByteArrayInputStream(string.getBytes("UTF-8"));
ByteArrayOutputStream deflated = new ByteArrayOutputStream();
stream(raw, new DeflaterOutputStream(deflated, new Deflater(Deflater.BEST_COMPRESSION)));
String base64 = DatatypeConverter.printBase64Binary(deflated.toByteArray());
The problematic line in the DatatypeConverter that TomEE ships with javaee-api-6.0-1-tomcat.jar:
public static String printBase64Binary(byte val[]) {
return converter.printBase64Binary(val);
}
The Oracle JDK has this implementation:
public static String printBase64Binary( byte[] val ) {
if (theConverter == null) initConverter();
return theConverter.printBase64Binary( val );
}
> NPE on DatatypeConverter
> ------------------------
>
> Key: TOMEE-249
> URL: https://issues.apache.org/jira/browse/TOMEE-249
> Project: TomEE
> Issue Type: Bug
> Affects Versions: 1.0.0
> Environment: MacOS JDK 1.7.0_05 & Windows JDK 1.7.0_04
> Reporter: Harro Lissenberg
> Fix For: 1.5.0
>
>
> When using the method DatatypeConverter.printBase64Binary a NullPointerException occurs.
> java.lang.NullPointerException
> javax.xml.bind.DatatypeConverter.printBase64Binary(DatatypeConverter.java:173)
> Servlet.doGet(Servlet.java:17)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> The following example servlet will throw the NPE:
> @WebServlet("/npe")
> public class Servlet extends HttpServlet {
> @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
> String s = DatatypeConverter.printBase64Binary("TomEE & JAXB!".getBytes(StandardCharsets.UTF_8));
> resp.getWriter().write(s);
> }
> }
> A workaround is to remove the JAXB jars from the lib & endorsed directories. My application seems to work fine but I have no idea what (hidden) problems this might cause.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira