Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docx4j doesn't work on Google App Engine #98

Closed
ehinter opened this issue Dec 28, 2013 · 3 comments
Closed

docx4j doesn't work on Google App Engine #98

ehinter opened this issue Dec 28, 2013 · 3 comments

Comments

@ehinter
Copy link

ehinter commented Dec 28, 2013

It will run locally, but when you deploy it and try to run it there's this error:

Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
at java.security.AccessController.checkPermission(AccessController.java:565)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.apphosting.runtime.security.CustomSecurityManager.checkPermission(CustomSecurityManager.java:56)
at java.lang.ClassLoader.checkClassLoaderPermission(ClassLoader.java:1556)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1475)
at org.docx4j.jaxb.Context.(Context.java:69)
... 67 more

I'm using version 3.0.0. Is there a workaround for this?

@plutext
Copy link
Owner

plutext commented Dec 28, 2013

By way of general background, you may have seen http://www.docx4java.org/forums/docx-java-f6/docx4j-and-google-app-engine-gae-t775.html
and more importantly https://code.google.com/p/googleappengine/issues/detail?id=1267

But for your specific error, which relates to the getSystemClassLoader call at line 69, you should be able to simply delete the following lines from org.docx4j.jaxb.Context (or catch the AccessControlException)

    // This stuff is just debugging diagnostics
    searchManifestsForJAXBImplementationInfo( ClassLoader.getSystemClassLoader());
    if (Thread.currentThread().getContextClassLoader()==null) {
        log.warn("ContextClassLoader is null for current thread");
        // Happens with IKVM 
    } else if (ClassLoader.getSystemClassLoader()!=Thread.currentThread().getContextClassLoader()) {
        searchManifestsForJAXBImplementationInfo(Thread.currentThread().getContextClassLoader());
    }

@ehinter
Copy link
Author

ehinter commented Dec 28, 2013

Hi,

Thanks for the reply. Yes, I found both of those other links but their issues were a bit different and neither really had a solution. I'll try commenting out the above lines but I was worried there would be other places that use the class loader that might cause a similar problem (e.g., line 122). I think ideally docx4j code should be modified to work on GAE out of the box if possible, but I'll see if commenting out the above lines works.

@ehinter
Copy link
Author

ehinter commented Dec 30, 2013

Commenting out those lines fixed it, thanks.

@plutext plutext closed this as completed Jun 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants