Java works in Oracle - imported banks

I am trying to get a small java class to load in Oracle 11g, so I can run it and call it from PL / SQL. I coded and compiled the class on my local machine in eclipse and it compiles fine. I packed it in a jar (with other jar files it depends on in the jar). They tried to upload my jar to Oracle 11g. Everything loads, unfortunately, when it loads my custom java class, it remains invalid, and when I try to compile it in Oracle, it says that it cannot find class references (the ones I packed in my bank with my class) .

Is there any other configuration method that I need to configure?

This is what my custom class code looks like:

import com.flashline.registry.openapi.base.OpenAPIException; import com.flashline.registry.openapi.entity.*; import com.flashline.registry.openapi.service.v300.FlashlineRegistry; import com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator; import javax.xml.rpc.ServiceException; import java.net.URL; import java.rmi.RemoteException; import org.apache.log4j.Logger; import java.net.MalformedURLException; public class AssetExtractor { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } static Logger LOG; static AuthToken authToken = null; static FlashlineRegistry repository = null; static URL repoURL; public static FlashlineRegistry getRepository() { if(repository == null) try { try{ repoURL = new URL("https://myserver/oer/services/FlashlineRegistry"); }catch(MalformedURLException mue) { LOG.error(mue); } repository = (new FlashlineRegistryServiceLocator()).getFlashlineRegistry(repoURL); LOG.debug((new StringBuilder()).append("Created repository at URL=").append(repoURL.toString()).toString()); } catch(ServiceException e) { LOG.error(e, e); } return repository; } public static AuthToken getAuthToken() { if(authToken == null) try { authToken = getRepository().authTokenCreate("user", "password"); LOG.debug("Created auth token."); } catch(OpenAPIException e) { LOG.error(e, e); } catch(RemoteException e) { LOG.error(e, e); } else try { getRepository().authTokenValidate(authToken); } catch(OpenAPIException e) { LOG.info("Auth token was invalid. Recreating auth token"); authToken = null; return getAuthToken(); } catch(RemoteException re) { LOG.error("Remote exception occured during creation of suth token after determined to be invalid", re); re.printStackTrace(); authToken = null; } return authToken; } public static String getAssetXML(String strAssetID) { String strAsset = null; try { strAsset = getRepository().assetReadXml(getAuthToken(), Long.parseLong(strAssetID)); } catch(OpenAPIException e) { e.printStackTrace(); } catch(RemoteException e) { e.printStackTrace(); } return strAsset; } } 

And all the * .jar files for import are inside my AssetExtractor.jar object

The command I used to load jar in oracle is:

 loadjava -v -f -resolve -resolver "((* OER) (* PUBLIC))" -user oer/***** AssetExtractor.jar 

Any ideas would be helpful!

+4
source share
1 answer

So it seems that if I do the following, it solves almost all my problems:

Edit the .profile file of Oracle users to install and export CLASSPATH, PATH, LD_LIBRARY_PATH, ORACLE_HOME, JAVA_HOME with the correct paths

SQLPlus as sys as sysdba

 EXEC dbms_java.grant_permission( 'OER', 'SYS:java.util.PropertyPermission', 'java.class.path', 'write' ); 

OS Commandline as an oracle user:

 loadjava –v –grant PUBLIC <jar> -user oer/****** for all jars 

SQLPlus as an OER user

 DECLARE v_classpath VARCHAR2(4000); v_path VARCHAR2(4000); BEGIN v_classpath := DBMS_JAVA.set_property('java.class.path', '/opt/oracle/102/jdk/lib:/mnt/hgfs/vmshare/rex_lib/aler-axis- 1.2.1.jar:/mnt/hgfs/vmshare/rex_lib/aler-axis-jaxrpc-1.2.1.jar:/mnt/hgfs/vmshare/rex_lib/client.rex- 11.1.1.5.0.jar:/mnt/hgfs/vmshare/rex_lib/commons-httpclient-3.0rc2- flashline.jar:/mnt/hgfs/vmshare/rex_lib/log4j-1.2.8.jar'); v_path := DBMS_JAVA.set_property('java.path', '/opt/oracle/102/jdk/bin'); END; / alter java source "AssetExtractor" compile; show errors 

The only incomprehensible problem is that for some reason it still cannot find / resolve some of the Oracle OER classes (which should all be in the client.rex * .jar file, I opened it and saw them there. Solve this part, then I will be glad.

+3
source

Source: https://habr.com/ru/post/1416472/


All Articles