OC4J License file load problem

Hi,

When I try to load license file I get the following exception.

java.io.IOException: code-source:/c:/oc4j/j2ee/home/config/…/applib/Aspose.Words.jdk14.jar/META-INF/MANIFEST.MF has no "!" suffix so does not name a path within the code-source.
at oracle.classloader.SharedCodeSourceSet.getResourceStream(SharedCodeSourceSet.java:482)
at oracle.classloader.SharedCodeSourceURL$Connection.getInputStream(SharedCodeSourceURL.java:93)
at java.net.URL.openStream(URL.java:1007)
at com.aspose.words.ew.b(Unknown Source)
at com.aspose.words.ew.a(Unknown Source)
at com.aspose.words.License.setLicense(Unknown Source)

A similar exception is stated on the following URL:
http://lists.jboss.org/pipermail/hibernate-issues/2006-August/000544.html

My configuration:

JDK 1.5.06
OC4J Standalone 10.1.3

Thanks.

Hi,
Afraid, I don’t understand your question. What overload of License.setLicense() are you using? Where you put the license file? Please, provide the code snippet that causes the exception.
Best reards,

Hi,
I use the following method to load license file.
I tried to put license file into web-inf directory as in samples, I tried to pass a String argument to setLicense method to no avail.

As far as I understood from the exception you try to open manifes.mf file in the jar. But you fail to provide a ! notation file name to call, and OC4J rejects it.

Thanks,
Ali

--------------------- 8< ----------------------------

import com.aspose.words.License;

public void loadLicense() throws LicenseNotFoundException {
    File licenseFile = new File("c:\\Aspose.Total.Java.lic");
    if (licenseFile.exists()) {
        try {
            License license = new License();
            InputStream in = new FileInputStream(licenseFile);
            license.setLicense(in);
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
            throw new LicenseNotFoundException(licenseFile.getAbsolutePath() + " not loaded. " + e.getMessage());
        }
    } else {
        throw new LicenseNotFoundException(licenseFile.getAbsolutePath() + " cannot be found.");
    }
}

Hi, Ali,
From link you provided I realize that this is a bug or a specific behavior of Oracle OC4J’s class loader. For some reasons it changes the protocol and strips ‘!’ after ‘jar’. Other class loaders leave ‘!’ in place so we successfully loading the manifest by url, something like: “jar: /X:/Aspose.Words.Java/lib/Aspose.Words.jdk15.jar!/META-INF/MANIFEST.MF”.
Afraid, we have to correct ours license code to please Oracle:) Before this, please, can you launch from your loadLicense() a simple code snippet and inform me what you see:

URL url = License.class.getResource("License.class");
System.out.println("url = " + url);//OC4J's classloader should strip ‘!’
InputStream inputStream = url.openStream();//OC4J should throw here

It’s just interesting…
Best Regards,

Hi,

Your code did not raise an exception and the output was:

url = code-source:/c:/Borland/oc4j_yeni/j2ee/home/config/…/applib/Aspose.Words.jdk14.jar!com/aspose/words/License.class

If is there is anything else I can do to assist you please do tell.

Thanks
Ali

Hi,

I have managed to get the following code working.

Hope this helps,

Ali

URL url = License.class.getResource("License.class");
System.out.println("class url = " + url);
String[] s = url.toString().split("!");
String manifest = s[0] + "!META-INF/MANIFEST.MF";
System.out.println("manifest  = " + manifest);
URL manifestUrl = new URL(manifest);
System.out.println("manifest url = " + manifestUrl);
InputStream inputStream = manifestUrl.openStream();
InputStreamReader isr = new InputStreamReader(inputStream);
BufferedReader r = new BufferedReader(isr);
while (true) {
    String line = r.readLine();
    if (line==null) {
        break;
    }
    System.out.println(line);
}

And here is the output.

class url = code-source:/c:/Borland/oc4j_yeni/j2ee/home/config/../applib/Aspose.Words.jdk14.jar!com/aspose/words/License.class
manifest  = code-source:/c:/Borland/oc4j_yeni/j2ee/home/config/../applib/Aspose.Words.jdk14.jar!META-INF/MANIFEST.MF

manifest url = code-source:/c:/Borland/oc4j_yeni/j2ee/home/config/../applib/Aspose.Words.jdk14.jar!META-INF/MANIFEST.MF
Manifest-Version: 1.0
Specification-Title: Aspose.Words for Java
AssemblyProduct: Aspose.Words for Java
Implementation-Title: Aspose.Words for Java
Specification-Vendor: Aspose Pty Ltd
Specification-Version: 2.0.2.0
Implementation-Version: 2.0.2.0
AssemblyInformationalVersion: 2006.12.13
Implementation-Vendor: Aspose Pty Ltd
Copyright: Copyright 2006 Aspose Pty Ltd

Name: com/aspose/words/h.class
SHA1-Digest: B5POX4lvm+gZhC3AoN0X/FbP10k=

Hi, Ali,
It’s interesting. I see, your class loader doesn’t strip ‘!’ when makes an URL from a string, it only changes the protocol to “code-source:/”…
We do something similar to what you figured out. But. We using “**!/META-INF/MANIFEST.MF" instead of yours "!META-INF/MANIFEST.MF" (‘!/’ instead of ‘!’). When I launching your code I get “java.net.MalformedURLException: no !/ in spec”.
Please, try "
!/**META-INF/MANIFEST.MF” in your test unit. May be Oracle prefer ‘!’ instead of ‘!/’ and strips ‘!’ before ‘/’?
Regards,

Hi Konstantin,
I have changed code to include / character:

String manifest = s[0] + "!/META-INF/MANIFEST.MF";

And I got an FileNotFoundException

class url = code-source:/c:/Borland/oc4j_yeni/j2ee/home/config/../applib/Aspose.Words.jdk14.jar!com/aspose/words/License.class
manifest  = code-source:/c:/Borland/oc4j_yeni/j2ee/home/config/../applib/Aspose.Words.jdk14.jar!/META-INF/MANIFEST.MF
manifest url = code-source:/c:/Borland/oc4j_yeni/j2ee/home/config/../applib/Aspose.Words.jdk14.jar!/META-INF/MANIFEST.MF
java.io.FileNotFoundException: /META-INF/MANIFEST.MF not found
in file:/c:/Borland/oc4j_yeni/j2ee/home/config/../applib/Aspose.Words.jdk14.jar
      at oracle.classloader.SharedJar.doGetStream(SharedJar.java:308)
       at oracle.classloader.SharedCodeSource.getStream(SharedCodeSource.java:1007)
       at oracle.classloader.SharedCodeSourceSet.getResourceStream(SharedCodeSourceSet.java:479)
       at oracle.classloader.SharedCodeSourceURL$Connection.getInputStream(SharedCodeSourceURL.java:93)
       at java.net.URL.openStream(URL.java:1007)
       at mil.tsk.base.aspose.WordUtil.loadLicense(WordUtil.java:36)
       ... and so on

Ok, we catch up it.
Can you send me your e-mail (Contact—Send an email) so I can send you corrected jar?
Regards,

Hi Konstantin,

I have got the new library and tried it.

Unfortunately the problem continues. The exception message is as follows:

Thanks,
Ali

java.io.IOException: code-source:/C:/Borland/oc4j_yeni/j2ee/home/applications/akss/lib/Aspose.Words.jdk14.jarMETA-INF/MANIFES.MF has no "!" suffix so does not name a path within the code-source.
	at oracle.classloader.SharedCodeSourceSet.getResourceStream(SharedCodeSourceSet.java:482)
	at oracle.classloader.SharedCodeSourceURL$Connection.getInputStream(SharedCodeSourceURL.java:93)
	at java.net.URL.openStream(URL.java:1007)
	at com.aspose.words.nonpublic.ge.b(Unknown Source)
	at com.aspose.words.nonpublic.ge.a(Unknown Source)
	at com.aspose.words.License.setLicense(Unknown Source)
	at mil.tsk.base.aspose.WordUtil.loadLicense(WordUtil.java:59)
	at mil.tsk.beyanname.client.GCServlet.loadAsposeLicense(GCServlet.java:100)

Sorry, it’s my ‘mind typo’ – I was thinking in terms that Oracle strips ‘/’ from the URL but it just using ‘!’ instead of ‘!/’.
I found a new topic about this Oracle bug: http://mail-archives.apache.org/mod_mbox/hivemind-dev/200601.mbox/%3C1675266867.1138127830897.JavaMail.jira@ajax.apache.org%3E . They talking that this bug is already fixed in the latest developer preview of OC4J. So we will continue ours conversation after that OC4J release:)
Please, inform me how the newest library works.
Regards,

Hi Konstantin,

The latest library you sent loaded the license file without an exception.

Thanks,
Ali KOKSAL