Skip to Main Content
  • Questions
  • Error while loading Activation8i.jar using loadjava

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Sridevi.

Asked: February 28, 2001 - 9:46 am UTC

Last updated: December 23, 2004 - 9:07 am UTC

Version: Oracle 8.1.7

Viewed 1000+ times

You Asked

Hi,
I am trying to send email from a form by using java with
PL/SQL. I have installed Javamail and Javabeans from Sun.
But I was having problems as I was not able to load class
'javax\mail\internet\MimeBodyPart'.

I read an article that you had written and I uploaded the same
jar files form your article.
I am trying to load activation8i.jar in to the database from
the command line using
loadjava -u sys/psswd@db -o -r -v -g (user name)
c:\invfax\activation8i.jar.
I get this error:
'SQL error while connecting with oci8 driver to db: ORA-01031:
insufficient privileges.
Could not open connection.
loadjava: 2 errors'.

I can see the jar file being executed and when it comes to resolving the above mentioned class it says that it has already been resolved and hence it is skipping it.

When I try doing this using 'System' it works fine with out any
errors. But I am not able to load the above class . I need this as my java code is not compiling as it can not find a method that is in this class.

Also I noticed that I do have a class MimeBodyPart but that has a number_ before its name and not 'javax'.

Could you please help me troubleshoot this error?

I am new to Java and I am trying to learn and troubleshoot at the same time.

Thank You..

and Tom said...

If you goto </code> http://java.sun.com/products/javamail/index.html, <code>you¡¦ll be able to download their Java Mail API. The download you get will consist of a couple of hundred files ¡V only one of which we are interested in. After you download the Java mail API ¡V make sure also to get their the JavaBeansTM Activation Framework extension or JAF (javax.activation). This is needed to run the Java mailapi package.

After you have downloaded these two sets of files ¡V you will need to extract mail.jar from the Java mailapi download and activation.jar from the JAF download. This is all you will need from this ¡V feel free to read through the documentation, there is a lot of functionality in there we are not using, we are just using the ¡§send an email¡¨ part of the API. The API includes functions for receiving mail as well from IMAP, POP and other sources.

We will need to load the mail.jar and activation.jar into the database using loadjava but before we can do that we must repackage them. These jar files are compressed in a format that is not understood by the database byte code interpreter. You need to ¡§unjar¡¨ and ¡§rejar¡¨ them without compression OR use a tool such as WinZip to ¡§rejar¡¨ them into a zip file. What I did on Windows 2000 was:

1. Used WinZip to extract the contents of mail.jar into my c:\temp\mail directory
2. Used WinZip to create a new archive c:\temp\mail8i.zip
3. Put the contents of c:\temp\mail\*.* including subdirectories into this new archive

I did the same thing for activation.jar ¡V only replacing mail with activation in the above steps. Now we are ready to load these zip (or jar files, whatever you named them) into the database. These need to be loaded using the SYS user since they have 'protected' Java packages that regular users cannot upload. We will use the commands:

loadjava -u sys/manager -o -r -v -f -noverify -synonym -g public mail8i.zip
loadjava -u sys/manager -o -r -v -f -noverify -synonym -g public activation8i.zip

Where:

ć -u sys/manager: is the userid and password for your SYS account. As stated previously, some of the packages are protected and must be loaded as SYS

ƒá -o: is shorthand for -oci8, I am using the oci8 driver. You could use the thin driver as well but you¡¦ll need to modify the the command to do so

ƒá -r: is short for ¡Vresolve. This will resolve all external references in the loaded classes helping to verify that the loaded java classes will be able to function after we load them

ƒá -v: is short for ¡Vverbose. This gives us something to do while loadjava is running. We can see it work through each step of its process.

ƒá -f: is short for ¡Vforce. This isn¡¦t necessary on the first load but is OK to use. If you try a load and hit and error, correct it and reload ¡V then you would either need to dropjava the jar file or use ¡Vforce. Using ¡Vforce just makes it easier for us.

ć -noverify: does not attempt to verify the bytecode. You must be grantedoracle.aurora.security.JServerPermission(Verifier) to execute this option. In addition, this option must be used in conjunction with -r. SYS has this privilege. This is needed because the bytecode verifier will flag some issues with the mail.jar file and this works around that issue.

ƒá -synonym: creates public synonyms for these classes. Since we will NOT install the mail java code we write as SYS, this allows us to ¡§see¡¨ the SYS loaded java classes.

ƒá -g public: grants execute on these loaded classes to PUBLIC. If this is not desirable, change the ¡Vg to be just the user you want to create the ¡§send mail¡¨ routines in, for example ¡§-g UTILITY_ACCT¡¨.



Rating

  (6 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

But is this always the result of the archive format?

Daryl, December 10, 2001 - 3:36 pm UTC

I'm having a similar problem. I've repackaged all the Sun stuff into their own ZIP archives, without compression. They load fine on my Windows NT and Solaris boxes. But at another site, running Oracle 8.1.7 under HP-UX, I get this error
--------------------------------
could not open connection
loadjava: 2 errors
SQL Error while connecting with oci8 driver to my_db_name:
ORA-01031: insufficient privileges
--------------------------------

I'm able to connect as sys to the my_db_name databases,
so I'm really puzzled as to what's going on here. All the Metalink docs (searching on "ORA-01031" and "loadjava") point to some kind of permissions problem, but everything in the HP-UX database looks the same as my Windows databases.
(e.g., DBA_JAVA_POLCY and DBA_SYS_PRIVS return the same data for the SYS user).

Other ideas?


Tom Kyte
December 10, 2001 - 4:26 pm UTC

can you give me an example? (i've personally loaded the stuff above into 817 HP/UX) tell me where to get the jar and I'll try loading it myself.

Here's what you want

Daryl, December 10, 2001 - 4:52 pm UTC

I've put activation.zip (no compression) at
</code> http://www.superserve.com/~darylb/pics/activation.zip <code>

TNS is the problem

Daryl, December 11, 2001 - 2:04 pm UTC

It turns out that the problem had to do with the TNS connection string. If the person doing the install specifies "loadjava -user sys/sys_password@my_db.company.com ...", it doesn't work.
Doing the operation from the server machine itself (via
telnet/ssh), setting the ORACLE_SID (and friends) and
doing "loadjava -user sys/syspassword ... " it DOES work.
loadjava simply isn't conveying the REAL information as to what happened.

Can't install mail8i.zip

Ricardo Patrocinio, August 19, 2004 - 1:09 pm UTC

I downloaded JavaMail and JAF form java.sun.com, but when I try to install the java8i.zip (after making it) with the loadjava command I get the folowing error:

The following operations failed
    class com/sun/mail/imap/protocol/IMAPSaslAuthenticator$1: resolution
    class com/sun/mail/imap/protocol/IMAPSaslAuthenticator: resolution
exiting  : Failures occurred during processing

And then, when I go to Sql+ and do desc send, I get this response:

SQL> desc send
ERROR:
ORA-04043: object send does not exist

How can I solve this problem?

Thank you
R.P. 

SASL-related problems

Vladimir M. Zakharychev, December 23, 2004 - 9:07 am UTC

Ricardo, check out the JavaMail notes in your download - seems you have downloaded JavaMail 1.3.2 and SSL/TLS and SASL support in this release is only available with J2SE 1.4 and 1.5. Oracle 8i has VM version 1.2, and 9i has 1.3 - both lack support for SSL/TLS out of the box. Worse yet, if you will try to load JCE and JSSE packages into the database, they probably won't work - they try to read their encryption strengh policies from a hard-coded JAR file, which cannot be loaded into the db as is (I believe I saw a bug posted in this regard on Oracle MetaLink.) However, you can safely ignore these classes if you do not intend to use secure transports (or you can download some earlier JavaMail release, for example 1.3.1, which doesn't have these classes and does not depend on them.)
As of the "send" object - you probably simply didn't create it.

Great Help

KB Singh, May 12, 2020 - 7:49 am UTC

Meanwhile check the precise and simple java mail coding at https://www.projectsforeveryone.com/java-mailing.php

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library