Tags: attempting, class, database, evermind, java, loadjava, mysql, oracle, procedure, procedures, program, rmi, rmiinitialcontextfactory, run, server, sql, stored
loadjava and Java Stored Procedures
I am attempting to run a java stored procedure that uses the com.evermind.server.rmi.RMIInitialContextFactory class. When I run my program as a stored procedure it attempts to instantiate this class, and throws me the following error:
javax.naming.NoInitialContextException: Cannot instantiate class:
com.evermind.server.rmi.RMIInitialContextFactory [Root exception is
I have determined that I need to load oc4jclient.jar into the database to take care of this dependency. I am using the loadjava utility to load the jar file. I am running the command like this:
call dbms_java.loadjava('-u user/pass.oracle.itags.org.126.96.36.199:1535:mysid -v -r -t C:\jdev1012\j2ee\home\oc4jclient.jar');
I am running this from Toad in a SQL editor window, but I don't think it is properly loading the jar file. Am I calling this correctly?
Leave a comment...
- 3 Comments
- Are you sure you want to load an OC4J client jar into a database?
Anyway, most likely your problem is this:
The JAR needs to be visible to the database, which means it needs to be on a directory on the database server. Furthermore the user running the loadjava script needs to be able to see that directory from the database. The easy way to acheive this is to run loadjava as SYS;
otherwise you need to read up on java security permissions.
Another thing you need to do is
SET serveroutput ON SIZE 1000000
in order to see your verbose output. Not sure how that works in TOAD.
Cheers, APC#1; Fri, 22 Feb 2008 21:44:00 GMT
- All I am trying to do is to have a Java Stored Procedure that enqueues a JMS message to a JMS queue on a different server than the database server. That is why I am using the RMI class (to access the remote server's JNDI tree to lookup to JMS queue). Maybe you have a better idea about the best way to do this. I want to avoid using AQ (I want to just use the OC4J/J2EE JMS).
On the remote machine I have a BPEL process waiting for the arrival of the JMS message.
I talked to someone who said that I needed the oc4jclient.jar to include the proper classes I am missing. But if there is a way to code a Java Stored procedure that can successfully enqueue the message without me having to load additional classes to the database, that would be great.
Thanks for your help#2; Fri, 22 Feb 2008 21:45:00 GMT
I got loadjava to work (see output below). However when I look at my database objects, I notice that there are now 246 invalid 'JAVA CLASS' database objects in the ALL_OBJECTS table. One of these rows has an OBJECT_NAME of '/c5b41e1_RMIInitialContextFact' which I believe is the RMI class I am intending to use. Does anyone have any idea why these objects might be invalid? Also I noticed that many of the 'VALID' objects don't have the garbage string (i.e. c5b41e1) in the OBJECT_NAME. What does this encoding represent?
SQL*Plus: Release 188.8.131.52.0 - Production on Fri May 20 13:22:27 2005 (c) Copyright 1999 Oracle Corporation. All rights reserved. Connected to:Oracle9i Enterprise Edition Release 184.108.40.206.0 - 64bit ProductionWith the Partitioning, OLAP and Oracle Data Mining optionsJServer Release 220.127.116.11.0 - Production PL/SQL procedure successfully completed. arguments: '-kprb''-u''user/pass.oracle.itags.org.18.104.22.168:1535:mysid''-v''-r''-t''/home/hollinsg/oc4jclient.jar'creating : resource META-INF/MANIFEST.MFcreating : class com/evermind/bytecode/Attributecreating : class com/evermind/bytecode/BasicAttributecreating : class com/evermind/bytecode/ClassDatacreating : class com/evermind/bytecode/ClassFormatExceptioncreating : class com/evermind/bytecode/ClassPoolEntrycreating : class com/evermind/bytecode/ClassSerializationcreating : class com/evermind/bytecode/CodeAttributecreating : class com/evermind/bytecode/CodeOutputStreamcreating : class com/evermind/bytecode/ConstructorCodeAttributecreating : class com/evermind/bytecode/ConstructorMethodDatacreating : class com/evermind/bytecode/DoublePoolEntrycreating : class com/evermind/bytecode/ExceptionRegioncreating : class com/evermind/bytecode/FieldDatacreating : class com/evermind/bytecode/FieldPoolEntrycreating : class com/evermind/bytecode/FloatPoolEntrycreating : class com/evermind/bytecode/IntegerPoolEntrycreating : class com/evermind/bytecode/InterfaceMethodPoolEntrycreating : class com/evermind/bytecode/LinkedClassDatacreating : class com/evermind/bytecode/LinkedMethodDatacreating : class com/evermind/bytecode/LongPoolEntrycreating : class com/evermind/bytecode/MethodDatacreating : class com/evermind/bytecode/MethodPoolEntrycreating : class com/evermind/bytecode/NameAndTypePoolEntrycreating : class com/evermind/bytecode/PoolEntrycreating : class com/evermind/bytecode/ProxyCodeAttributecreating : class com/evermind/bytecode/ProxyInitializationCodeAttributecreating : class com/evermind/bytecode/ProxyMethodDatacreating : class com/evermind/bytecode/StringPoolEntrycreating : class com/evermind/bytecode/UTF8PoolEntrycreating : class com/evermind/client/assembler/Assemblercreating : class com/evermind/compiler/Compilable PL/SQL procedure successfully completed.#3; Fri, 22 Feb 2008 21:46:00 GMT