I'm developing an Java application( J2SE ). In my application, I should send a message via a queue( using JDNI of Weblogic ) and then should interact with HTTP web url ( using an URLConnection ).
If I try to interact with HTTP web using URLConnection, it is succeed. But, after a message is sending by a Queue, interaction with HTTP web(using URLConnection) is always failed. After I extremely reduce source code, finally I found that code for setting JDNI impacted on making UrlConnection object.
Below is source code for explanation.
private void test() throws IOException, NamingExcpetion {
HttpUrlConnection c1 = getConnection();
System.out.println(c1);
initContext();
HttpUrlConnection c2 = getConnection();
System.out.println(c2);
}
public void initContext() throws ... {
Properties prop = new Properties();
Prop.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
Prop.put(Context.PROVIDER_URL, "t3://111.111.111.111:7100"); // my target weblogic server having queues.
new InitialContext(prop);
System.out.println("InitialContext() finished!!");
}
public HttpURLConnection getConnection() throws .... {
URL url = new URL("http://222.222.222.222:8100/login"); // My target server to be interacting via URLConnection; I'm using java.net.URL
return (HttpURLConnection) url.openConnection();
}
And below is the result.
sun.net.www.protocol.http.HttpURLConnection:http://222.222.222.222:8100/login
InitialContext() finished!!
weblogic.net.http.SOAPHttpURLConnection:http://222.222.222.222:8100/login
Even though InitialContext() method call finished, I expect to return HttpURLConnection, but actually SOAPHttpURLConnection has returned by url.openConnction(); So, I can not interact with web page using that.
Why does the SOAPHttpURLConnection has returned ?? And How can I resolve this problem??