Spring 启动应用无法通过 weblogic 中的 jndi 获取连接

Spring boot app cannot get connection via jndi in weblogic

我们有 spring 引导应用程序(版本 => 2.4.3)需要在 weblogic 12.2.1.4.0 中 运行。当我们像下面这样输入 url、名称和密码时,它成功部署并可以连接,但是当我们像下面这样通过 jndi 部署时。它越来越错误。我们如何解决这个问题?我们已经尝试了这些链接,但并没有解决我们的问题。

https://weblogic.developer.interest.jdbc.narkive.com/2JvpDwJc/weblogic-jdbc-extensions-poolpermissionssqlexception

https://groups.google.com/g/weblogic.developer.interest.jdbc/c/SobQpZNwrfM?pli=1

https://groups.google.com/g/weblogic.developer.interest.jdbc/c/lkTGus61SNE

Weblogic 错误=>

  weblogic.common.resourcepool.ResourcePermissionsException: User "<anonymous>" does not have permission to perform operation "reserve" on resource "myusername" of module "none" of application "none" of type "ConnectionPool" 
weblogic.jdbc.extensions.PoolPermissionsSQLException: weblogic.common.resourcepool.ResourcePermissionsException: User "<anonymous>" does not have permission to perform operation "reserve" on resource "myusername" of module "none" of application "none" of type "ConnectionPool"
               at weblogic.jdbc.common.internal.JDBCUtil.wrapAndThrowResourceException(JDBCUtil.java:281)
               at weblogic.jdbc.common.internal.WLDataSourceImpl.getPoolConnection(WLDataSourceImpl.java:563)
               at weblogic.jdbc.common.internal.WLDataSourceImpl.getConnectionInternal(WLDataSourceImpl.java:660)

工作性质=>

# Oracle settings
spring.datasource.url=jdbc:oracle:thin:@10.10.10.10:1521:MYDB
spring.datasource.username=myusername
spring.datasource.password=userpassword
spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver

无效属性 =>

spring.datasource.jndi-name=jdbc/ABC
spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver

此代码出现错误'dataSource.getConnection()'

     @Component
    @Slf4j
    public class SysUrlLinkDao {
    @Autowired
    private DataSource dataSource;

    public ImagePojo loadImgPathLink(String value) {

        ImagePojo generic = new ImagePojo();
        String query = " SELECT * FROM IMG_PATH WHERE PARAM_VALUE =?";
        try (Connection connection = dataSource.getConnection();
             PreparedStatement preStatement = connection.prepareStatement(query)) {
            preStatement.setString(1, value);
            try (ResultSet rset = preStatement.executeQuery()) {
                while (rset.next()) {
                    generic = new ImagePojo();
                    generic.setImagePath(rset.getString("PATH"));
                    generic.setLinkPath(rset.getString("LINK"));

                }
            }

        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        return generic;

    }
}

去掉ContextListener中的'Locale.setDefault(new Locale("tr", "TR"));'后,就可以连接了。我不明白为什么它会从 weblogic 数据源中出错。其次,当我们将 war 包部署到本地 weblogic 时。它还会出现数据源错误,并且在注销控制台后,我们无法登录。管理控制台也受到影响。我们尝试了正确的用户名和密码,但它给出了这样的错误 'Access denied'。所有这些都已通过删除默认语言环境解决。