tags:

views:

365

answers:

2

I have simple java class that calculates SHA1 and I want to use it from PLSQL procedures in Oracle. Following advises from : SHA1, SHA256, SHA512 in Oracle for free without using DBMS_CRYPTO (my simple case use unly SHA1 and do not need any jars and consist of only sha1.class that imports java.security and java.io)

I compiled sha1.java with:

javac -target 1.2 -source 1.2 sha1.java

and installed this sha1.class on my Windows test environment:

Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

Unfortunately I have to install it on Solaris with:

Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

I tried but those attempts fails with:

c:\test>loadjava -thin -user ***** -resolve sha1.class
Error while creating class sha1
    ORA-29545: badly formed class:: User has attempted to load a class (sha1) into a restricted package. Permission can be granted using  dbms_java
.grant_permission(<user>, LoadClassInPackage...

The following operations failed
    class sha1: creation
exiting  : Failures occurred during processing


EDITED:

I tried with .java source instead of .class and I got (translated from Polish)::

c:\mn>loadjava -thin -user ****** -resolve sha1.java
Error while creating sha1
    ORA-06576: not a valid function or procedure name

Error while computing shortname of sha1
    ORA-06550: line 1, column 13:
PLS-00201: must be declared 'DBMS_JAVA.SHORTNAME' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

The following operations failed
    source sha1: creation
exiting  : Failures occurred during processing

What should I do to load this class or source to Oracle on Solaris?

+1  A: 

You must run the DBMS_JAVA.grant_permission package (the details should be in your error message, and in some cases also show up in a trace file on the database server filesystem).

Connect as SYS and from a SQL interface:

begin
 dbms_java.grant_permission(........);
end;
dpbradley
+1  A: 

If you have the permissions, my hunch is that you either need to have your class in a java package OR the lower case class name is confusing the verifier on Solaris (a case sensitive environment in which class names should start with a capital letter).

Instead of

public class shai{

}

Try it with a package and valid class Name.

package com.company.Util
public class Shai{

}
Brian
I tried it on Linux as well, and it worked. I also tried with .java source: worked on Linux, but failed on Solaris.
Michał Niklas