Oracle 12.2数据库上的JavaMail无法加载提供程序

时间:2018-08-20 21:54:50

标签: java windows oracle javamail tls1.2

在安装Oracle Database 12.2之后,我尝试安装最新的JavaMail。 JavaMail在以前的数据库服务器上运行良好。它不起作用,我快要死了。这是错误跟踪:

DEBUG: not loading system providers in <java.home>/lib
DEBUG: not loading optional custom providers file: /META-INF/javamail.providers
DEBUG: can't load default providers file/META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {}
DEBUG: Providers Listed By Protocol: {}
DEBUG: not loading optional address map file: /META-INF/javamail.address.map
Exception in thread "Root Thread" javax.mail.NoSuchProviderException: No
provider for imap
        at javax.mail.Session.getProvider(Session.java:289)
        at javax.mail.Session.getStore(Session.java:363)
        at javax.mail.Session.getStore(Session.java:343)
        at javax.mail.Session.getStore(Session.java:329)
        at MailHandlerImpl.connectToServerSSL(MailHandler:453)

如您所见,它无法加载提供程序。我确定JavaMail文件夹中的javax.mail.jar文件确实包含提供程序文件。

这就是我所做的(我将公司名称更改为CUSTOMER,将Oracle用户名更改为OracleUser,但以下是确切的声明):

步骤1:安装软件

  1. 已安装Oracle数据库12.2

  2. Java:

    • 在C:\ Program Files \ Java \ jdk1.8.0_181中安装了jdk1.8.0_181
    • 下载的Javamail 1.6.1
    • 将Javax.mail.jar复制到c:\ JavaMail
    • 下载的jaf-1.1.1
    • 将其安装在c:\ jaf-1.1.1中
  3. 环境变量:

    • CLASSPATH。; C:\ JavaMail \ javax.mail.jar
    • JAVA_HOME C:\ Progra〜1 \ Java \ jdk1.8.0_181
    • JAVAMAIL_JAR C:\ JavaMail \ javax.mail.jar
    • LD_LIBRARY_PATH%JAVA_HOME%\ lib
    • ORACLE_HOME D:\ app \ Oracle \ product \ 12.2.0 \ dbhome_1
    • PATH。; C:\ JavaMail; C:\ Progra〜1 \ Java \ jdk1.8.0_181 \ bin; D:\ app \ Oracle \ product \ 12.2.0 \ dbhome_1 \ bin; D:\ app \ Oracle \ product \ 12.2.0 \ dbhome_1 \ opatch; D:\ app \ Oracle \ product \ 12.2.0 \ dbhome_1 \ perl \ bin;%SystemRoot%\ system32; ...以及其余路径

步骤2:创建ACL

  1. 为SMTP创建ACL:

    BEGIN
      DBMS_NETWORK_ACL_ADMIN.create_acl (
        acl          => 'mail_for_oracleuser.xml', 
        description  => 'Oracle User access to Customer email', 
        principal    => 'ORACLEUSER',
        is_grant     => TRUE, 
        privilege    => 'connect',
        start_date   => SYSTIMESTAMP,
        end_date     => NULL);
    END;
    
    BEGIN
      DBMS_NETWORK_ACL_ADMIN.assign_acl (
        acl => 'mail_for_oracleuser.xml',
        host => 'MAILSERVER.CUSTOMER.LOCAL', 
        lower_port => 25,
        upper_port => NULL); 
    END;
    
  2. 为IMAP创建ACL

    BEGIN
      DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
            acl => 'mail.xml',
            description => 'MAIL ACL',
            principal   => 'ORACLEUSER',
            is_grant    => true,
            privilege   => 'connect');
    
      DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
            acl => 'mail.xml',
            principal => 'ORACLEUSER',
            is_grant  => true,
            privilege => 'resolve');
    
      DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
            acl  => 'mail.xml',
            host => 'mail.customer.org');
    END;
    
    BEGIN
      DBMS_NETWORK_ACL_ADMIN.DROP_ACL(
         acl => '/sys/acls/customer_email_server_wallet.xml');
    END;
    
    BEGIN
      dbms_network_acl_admin.create_acl(
            'customer_email_server_wallet.xml', 
            'Customer Email Server SSL Wallet ACL',
         'ORACLEUSER', 
             TRUE, 
             'use-client-certificates');
    
      dbms_network_acl_admin.assign_wallet_acl(
            'customer_email_server_wallet.xml', 
             'file:d:/wallet');
    END;
    

步骤3:授予权限

call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.net.SocketPermission', '10.10.80.10:143', 'connect,resolve' );
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.net.SocketPermission', '10.10.80.10:993', 'connect,resolve' );
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.net.SocketPermission', '10.10.80.21:143', 'connect,resolve');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.net.SocketPermission', '10.10.80.21:993', 'connect,resolve');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.net.SocketPermission', 'mail.customer.org', 'connect,resolve,send');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.net.SocketPermission', 'MAIL.CUSTOMER.ORG', 'connect,resolve,send');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.net.SocketPermission', 'mail.customer.org', 'resolve');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.net.SocketPermission', '[https://mail.customer.org]', 'connect, resolve');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.net.SocketPermission', '*', 'connect,resolve,send');

call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.util.PropertyPermission', '*', 'read,write');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.lang.RuntimePermission', 'getClassLoader','');

call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.io.FilePermission', '*', 'read,write');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.io.FilePermission', '*', 'execute');

call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.io.FilePermission', 'c:\javamail\javax.mail.jar', 'read');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.io.FilePermission', 'D:\app\Oracle\product\12.2.0\dbhome_1\lib\activation.jar', 'read');
call dbms_java.grant_permission('ORACLEUSER', 'SYS:java.io.FilePermission', 'C:\jaf-1.1.1\activation.jar', 'read');

call dbms_java.grant_permission('PUBLIC', 'SYS:java.io.FilePermission', 'c:\javamail\javax.mail.jar', 'read');
call dbms_java.grant_permission('PUBLIC', 'SYS:java.io.FilePermission', 'D:\app\Oracle\product\12.2.0\dbhome_1\lib\activation.jar', 'read');
call dbms_java.grant_permission('PUBLIC', 'SYS:java.io.FilePermission', 'C:\jaf-1.1.1\activation.jar', 'read');

编辑:我注意到在classpath中没有列出activation.jar。我添加了这一点,重新启动了服务器并收到了完全相同的结果。

0 个答案:

没有答案