在安装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,但以下是确切的声明):
已安装Oracle数据库12.2
Java:
环境变量:
为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;
为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;
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。我添加了这一点,重新启动了服务器并收到了完全相同的结果。