'Error when looking up data source name when deploying httpServlet to weblogic 12 server
I am trying to deploy an ear file to a Weblogic 12 server. The ear file contains a HttpServlet. During deployment, the HttpServlet is trying to initialize and fails with this error:
Target state: deploy failed on Cluster javax.naming.NameNotFoundException: While trying to lookup 'jdbc.' didn't find subcontext 'jdbc'. Resolved '' at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1180)
I tested the data source connection on the weblogic servers and it is successful.
The data source is defined in a properties file that is being accessed because the datasource name is correct. The webserver URL is also correct.
This is the init() method:
public void init(ServletConfig config) throws ServletException
{
super.init(config);
Context jndiContext = null;
Hashtable ht = new Hashtable();
try
{
PropertyManager.getInstance(PROPS_FILE);
PropertyManager.getInstance();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, PropertyManager.getProperty("WL_WEBSERVER_URL"));
jndiContext = new InitialContext(ht);
ds = (javax.sql.DataSource) jndiContext.lookup(PropertyManager.getProperty("SEC_DATASOURCE"));
}
}
I don't understand why it does not recognize the subcontext of jdbc
.
I tried removing jdbc
. But the error is a NameNotFoundException without jdbc
.
UPDATE
I tried changing the data source name to java:jdbc/scantDS
. I received a different NameNotFoundException:
". javax.naming.NameNotFoundException: While trying to look up /jdbc/scantDS in /app/webapp/Load/421643657.; remaining name '/jdbc/scantDS' at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1180)
Solution 1:[1]
The problem was that I was trying to deploy using the wrong port number. I was using the port number that the console application was using and I needed a specific port that has the JNDI.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gloria Santin |