zkh152 / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

AppEngine restricted classes throwing exception #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
use of javax.imageio.spi.ServiceRegistry is restricted on AppEngine. So 
xdocreport immediately fails when trying to register in 
AbstractRegistry.initializeIfNeeded()

What is the expected output? What do you see instead?
expect report generation to work, but stack trace complains about restricted 
class javax.imageio.spi.ServiceRegistry

What version of the product are you using? On what operating system?
version 0.9.8

Please provide any additional information below.

I managed to generate a DOCX from a DOCX template using Velocity by removing 
the javax.imageio.spi.ServiceRegistry and replacing with 
java.util.ServiceLoader.

This is a working implementation for appengine :

    protected void initializeIfNeeded() {
        if (!initialized) {
            onStartInitialization();
            // getClass().getClassLoader() to work under OSGi context

            ServiceLoader<Discovery> serviceLoader = ServiceLoader.load(registryType, getClass().getClassLoader());
            if (log.isLoggable(Level.FINE)) {
                log.fine("discoveries found ? " + serviceLoader.iterator().hasNext());
            }

            for (Iterator<Discovery> iterator = serviceLoader.iterator(); iterator.hasNext();) {
                Discovery instance = iterator.next();
                boolean result = registerInstance(instance);
                log.info("XDoc report registering discovered instance  " + instance + " " + result);
            }
            initialized = true;
        }
    }

Original issue reported on code.google.com by k...@koma.be on 16 Jul 2012 at 8:32

GoogleCodeExporter commented 9 years ago
Hi,

At first what do you mean with AppEngine?

We have used javax.imageio.spi.ServiceRegistry because we wish not depends on 
Java6 (which provides java.util.ServiceLoader).

But we could try to manage an abstraction of service loader for our discovery 
loader like this:

1) use java.util.ServiceLoader at first
2) if ClassNotFoundException found (Java5), use 
javax.imageio.spi.ServiceRegistry

Regards Angelo

Original comment by angelo.z...@gmail.com on 16 Jul 2012 at 1:10

GoogleCodeExporter commented 9 years ago
Hi Angelo

thx for the followup.

This is AppEngine : https://developers.google.com/appengine/
a very popuplar cloud platform by Google.

AppEngine restricts the usage of some packages, like fileoutputstream and the 
likes... a complete list is available here : 
https://developers.google.com/appengine/docs/java/jrewhitelist

With the advent of Java 7 and 8 in the making, is Java 5 a necessity ?
Ok for the workaround of course :)

Koen

Original comment by k...@koma.be on 16 Jul 2012 at 1:14

GoogleCodeExporter commented 9 years ago
To be honest I would prefer to drop down JDK5 compatibility.

As Koen mention JDK7 already exists and JDK8 is on Its way.

Maybe we should ask users who wants to keep JDK5 compat.

Original comment by pascal.leclercq on 16 Jul 2012 at 9:05

GoogleCodeExporter commented 9 years ago
Hi Pascal, Koen,

I have created a new post at 
https://groups.google.com/forum/?fromgroups#!topic/xdocreport/4DNLRyrEemo to 
see if XDocReport user is OK to use Java6.

@Pascal: if Java6 is not a problem, could you change the Java code please (I 
suppose pom maven too). Many thank's.

Regards Angelo

Original comment by angelo.z...@gmail.com on 17 Jul 2012 at 5:03

GoogleCodeExporter commented 9 years ago
great 8-)

Original comment by k...@koma.be on 17 Jul 2012 at 5:54

GoogleCodeExporter commented 9 years ago
Changes has been commited. We now use JDK6 ServiceRegistry. Can you try the 
latest snapshot  and give us some feedback ?

We use http://oss.sonatype.org to deploy ur latest (maven) snapshots. Or you 
can build from source...

Original comment by pascal.leclercq on 19 Jul 2012 at 2:52

GoogleCodeExporter commented 9 years ago
tried with fr.opensagres.xdocreport.core-1.0.0-20120719.131751-1.jar
and works fine !! thx a lot

I've only come to replace form fields in a word doc with text. Moving to images 
soon, I will report back if issues. thx again.

Original comment by k...@koma.be on 19 Jul 2012 at 3:06

GoogleCodeExporter commented 9 years ago
@Pascal: Many thank's Pascal for your work.

I have updated the home page http://code.google.com/p/xdocreport/ by adding:

Since XDocReport 1.0.0, XDocReport requires Java 6.

Regards Angelo

Original comment by angelo.z...@gmail.com on 19 Jul 2012 at 7:04

GoogleCodeExporter commented 9 years ago
Bad info about java6.

XDocReport supports now Java5 and Java6 by using 
http://code.google.com/p/xdocreport/source/browse/core/fr.opensagres.xdocreport.
core/src/main/java/fr/opensagres/xdocreport/core/internal/JDKServiceLoader.java

Original comment by angelo.z...@gmail.com on 22 Nov 2012 at 2:46