简体   繁体   English

密封违规:包oracle.jdbc.pool被密封oracle UCP连接池

[英]sealing violation: package oracle.jdbc.pool is sealed oracle UCP connection pooling

My project was using ojdbc6 with c3p0 connection pooling .我的项目使用ojdbc6c3p0连接池。 This i moved to ojdbc8 and UCP(Oracle's universal connection pooling) .我转移到ojdbc8UCP(Oracle's universal connection pooling) But i am getting below error:但我收到以下错误:

UCP Config used: UCP Config

try
                {
                    //Creating a pool-enabled data source
                    pds= PoolDataSourceFactory.getPoolDataSource();

                    String dbURL="jdbc:oracle:thin:@(DESCRIPTION = (CONNECT_TIMEOUT= 15)(RETRY_COUNT=20)(RETRY_DELAY=3) (ADDRESS_LIST =(LOAD_BALANCE=on)(ADDRESS = (PROTOCOL = TCP) (HOST = vm-host-101) (PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = S1NAME)))";

          //this is where am using that package 
                    pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
                    pds.setURL(dbURL);
                    pds.setUser("username");
                    pds.setPassword("password");
                    pds.setInitialPoolSize(5);
                    pds.setMinPoolSize(5);
                    pds.setMaxPoolSize(10);
                    pds.setFastConnectionFailoverEnabled(false);
                    return pds;
                }
                catch(SQLException e)
                {
                    e.printStackTrace();
                }
                return pds;

            }

Error:错误:

Caused by: java.sql.SQLException: Unable to create factory class instance with provided factory class name: java.lang.SecurityException: sealing violation: package oracle.jdbc.pool is sealed
    at oracle.ucp.util.UCPErrorHandler.newSQLException(UCPErrorHandler.java:456) ~[ucp-12.2.0.1.jar:12.2.0.1.0]
    at oracle.ucp.util.UCPErrorHandler.throwSQLException(UCPErrorHandler.java:133) ~[ucp-12.2.0.1.jar:12.2.0.1.0]
    at oracle.ucp.jdbc.PoolDataSourceImpl.initConnectionFactory(PoolDataSourceImpl.java:3243) ~[ucp-12.2.0.1.jar:12.2.0.1.0]
    at oracle.ucp.jdbc.PoolDataSourceImpl.createUniversalConnectionPool(PoolDataSourceImpl.java:1105) ~[ucp-12.2.0.1.jar:12.2.0.1.0]
    ... 61 common frames omitted
Caused by: java.lang.SecurityException: sealing violation: package oracle.jdbc.pool is sealed

I understand the error will come when we have 2 class loaded from same package .我知道当我们从同一个package加载 2 个class时会出现错误。 But i checked in external dependencies in intellij and also tried mvn dependency:tree command of maven .但是我在intellij检查了外部依赖项,并且还尝试了mvn dependency:tree命令的maven I couldn't find duplicate OJDBC jars in classpath .我在classpath找不到重复的OJDBC jars

Is there any other reason for this?还有其他原因吗?

This typically happens when you have more than one ojdbc*.jar in your classpath .当您的classpath多个ojdbc*.jar时,通常会发生这种情况。

In your question you clearly state you have verified that there was no duplicate but there must be one.在您的问题中,您明确表示您已确认没有重复,但必须有一个。 If you load ojdbc8 from Maven then you need to make sure that it's not manually added from the local filesystem .如果您从Maven加载ojdbc8 ,那么您需要确保它不是从本地filesystem手动添加的。

Same thing for ucp.jar . ucp.jar You may want to scan your filesystem for ojdbc6.jar or ojdbc6dms.jar (or ojdbc8.jar and ojdbc8dms.jar or ojdbc10 - just scan for ojdbc*) and rename the jars to something else (or remove them).您可能想要扫描filesystem中的ojdbc6.jar or ojdbc6dms.jar (or ojdbc8.jar and ojdbc8dms.jar or ojdbc10 - just scan for ojdbc*)并将 jar 重命名为其他名称(或删除它们)。

It's sometimes cryptic - depending on your framework - to see your full classpath.有时会很神秘——取决于你的框架——要查看完整的类路径。 On linux a "ps -af" command will display the full command line that was used to launch java and these sometimes provides useful information about the classpath .linux a "ps -af" command将显示用于启动 java 的完整命令行,这些有时会提供有关classpath有用信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM