0

I have a Spring web application deployed and running in WebLogic. It needs to connect to database through JNDI DataSource.

After following the post, my application is able to find the jndi data source. I tested with a single data source and it works fine. However, when the data source is a multi data source, once my application started, the two AdminServers are immediately in overloaded state.

Any idea what cause the overloaded state on AdminServer? The version of weblogic that I use is 12.2.1.2.0.

If I remove AdminServer from the data source, my application will fail to look up the data source.

The following is my code to look up the JNDI data source.

@Bean
public DataSource dataSource()  {
  String jndiDs = 
  dbProperties.getProperty(DB_DATASOURCE_JNDI_NAME_OPTION);
  LOGGER.info("Lookup jndi datasource {}", jndiDs);

  JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
  try {
    Properties jndiEnvironment = new Properties();
    jndiEnvironment.setProperty("lookupOnStartup", "false");
    jndiEnvironment.setProperty("proxyInterface", "javax.sql.DataSource");
    dsLookup.setJndiEnvironment(jndiEnvironment);

    JndiTemplate jndiTemplate = new JndiTemplate();
    Properties environment = new Properties();
    String namingProviderUrl = dbProperties.getProperty(DB_DATASOURCE_JNDI_NAMING_PROVIDER_URL, "t3://localhost:8301");
    environment.setProperty("java.naming.provider.url", namingProviderUrl);
    environment.setProperty("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
    jndiTemplate.setEnvironment(environment);
    dsLookup.setJndiTemplate(jndiTemplate);

    DataSource ds = dsLookup.getDataSource(jndiDs);
    LOGGER.info("Use jndi datasource {}", jndiDs);
    return ds;
  } catch (Exception e) {
    LOGGER.error("Failed to load jndi datasource {}", jndiDs, e);
    throw e;
  }
}

I still don't understand why AdminServer needs to be selected as one of the targets. What can do so AdminServer won't be as part of the data source targets?

P.S. (The multi data source is an abstraction around a group of data sources that provides load balancing and failover between data sources.)

1 Answers1

0

So, when you says the two AdminServers, I'm assuming, you mean two domains. Because, AFAIK, AdminServer represents a domain in WLS.

If I remove AdminServer from the data source, my application will fail to look up the data source.

Yes, that will fail. As your application would have deployed on same domain server and it would be looking for the datasource.

I still don't understand why AdminServer needs to be selected as one of the targets. What can do so AdminServer won't be as part of the data source targets?

So, when you define Target for any datasource, means you are deploying the datasource on that domain server and will be ONLY accessible to all applications deployed under the same domain server.

Ravi
  • 30,829
  • 42
  • 119
  • 173