Skip to content
Advertisement

Spring boot app cannot get connection via jndi in weblogic

We have spring boot application (version => 2.4.3) that needs to run in weblogic 12.2.1.4.0. When we give url, name and password like below, it successfully deploy and can get connection, but when we deploy via jndi like below. It is getting error. How can we fix this? We already tried these links, but it is not solved our problem.

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 errror=>

  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)

Working properties =>

# 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

not working properties =>

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

Error occur in this code ‘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;

    }
}

Advertisement

Answer

After removing ‘Locale.setDefault(new Locale(“tr”, “TR”));’ in ContextListener, it can get connection. I don’t understand why it gets faults from weblogic datasource. Secondly, when we deploy our war package to local weblogic. It is also gets datasource error and after logging off console, we cannot log in. Admin console also affected. We tried correct username and password, but it gives error like this ‘Access denied’. All these has solved with removing default locale.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement