7 Replies Latest reply on Oct 13, 2015 12:25 PM by handat

    Java URLConnection not authenticating

    Pedro F

      Hi everyone,


      I'm not sure if this is the correct forum to post this question but I believe it is. I'm trying to develop a simple java code that will connect to Oracle Business Intelligence Enterprise Edition 11g (OBIEE). What I'm trying to achieve is running some code that will open a dashboard page in OBIEE and then monitor (directly in OBIEE) which queries are triggered.


      The code I have right now is pretty basic and is the following:


      import java.io.BufferedReader;

      import java.io.IOException;

      import java.io.InputStreamReader;

      import java.net.MalformedURLException;

      import java.net.URL;

      import java.net.URLConnection;


      public class ConnectionTest {


          public static void main(String[] args) {



              try {

                  URL myURL =

                      new URL("http://server:port/analytics/saw.dll?Dashboard&PortalPath=%2Fshared%2FHE%20Analytics%2F_portal%2FHE%20Analytics&NQUser=weblogic&NQPassword=welcome1");

                  URLConnection myURLConnection = myURL.openConnection();


                                                     "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)");



                  BufferedReader in =

                      new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));

                  String inputLine;

                  while ((inputLine = in.readLine()) != null)





              } catch (MalformedURLException e) {

                  System.out.println("Exception " + e);

              } catch (IOException e) {

                  System.out.println("Exception " + e);





      What is strange about the behaviour of this code is that I'm able to see the user, apparently, logged in into OBIEE (the user is listed on the active sessions) but no queries are triggered and what is returned is in the BufferedReader actually shows that it's still trying to login (below just some pieces of the HTML returned)

      <title>Signing in...</title>

      <script type="text/javascript">window.onload=function(){onLoggingInPageLoad('saw.dll?Dashboard',{"page":"Student Withdrawal Profile","PortalPath":"/shared/HE Analytics/_portal/HE Analytics"});};</script>


      I've also tried add to my Java code the lines below but it didn't make any difference.


      String userpass = "weblogic" + ":" + "welcome1";

      String basicAuth = "Basic " + new String(new Base64().encode(userpass.getBytes()));

      myURLConnection.setRequestProperty ("Authorization", basicAuth);


      I'm aware that this may not be only a Java problem but also something related to OBIEE itself but I'm kind of stuck right now so any help will be much appreciated!




        • 1. Re: Java URLConnection not authenticating

          When you send POST request to HTTP server and received answer (as html, javascript and e.t.c). You have to process answer and then send next request!! you have to write html parser, which parses html ajax js and other.

          For example debug your Dashboard page in Mozilla or Explorer. You could see many queries,answers and scripts.

          You chose a wrong way for your task!

          Unfortunaly, I have never work with OBIEE... but have experience in other app (Hyperion Planning,Shared Services)


          I see three ways:

          1. Try monitor queries in RDBMS

          2. Use proxy server to catch queries between users and server than analyze it (for example little proxy)

          3. inject your code in OBIEE (look at license agreement)

          • 2. Re: Java URLConnection not authenticating
            Pedro F

            Hi rpc1,


            Thanks for your reply. I have to be honest and say I'm not aware of most things you mentioned and will need to read more about them.


            However, there's a detail I want to add just in case it makes any difference. I have tried using an HTPPUrlConnection and setting the request method to "GET" in my code, something like this:


            HttpURLConnection myURLConnection = (HttpURLConnection) myURL.open connection();





            • 3. Re: Java URLConnection not authenticating
              Pedro F

              One more thing that may be worth adding here. If I get the URL I pass to my URL object




              And put it directly into a browser or have this URL in a simple HTML page and click on it, I'm able to go to OBIEE and see the expected dashboard, the authentication process is done automatically since the credentials are passed on the URL itself.


              However, when running this from my Java code that doesn't happen and that's why I think my issue is related with something I'm not doing in the Java code.

              • 4. Re: Java URLConnection not authenticating

                You realy don't understand how HTTP works...

                1. You send request http://server:port/analytics/saw.dll?Dashboard&PortalPath=%2Fshared%2FHE%20Analytics%2F_portal%2FHE%20Analytics&NQUser=weblogic&NQPassword=welcome1

                2. Server returns answer:

                "<title>Signing in...</title>

                <script type="text/javascript">window.onload=function(){onLoggingInPageLoad('saw.dll?Dashboard',{"page":"Student Withdrawal Profile","PortalPath":"/shared/HE Analytics/_portal/HE Analytics"});};</script>"...

                (If you disable javascript in browser you'll see this page)

                3. You must execute script window.onload=function(){onLoggingInPageLoad('saw.dll?Dashboard',{"page":"Student Withdrawal Profile","PortalPath":"/shared/HE Analytics/_portal/HE Analytics"});};

                But you can't execute javascript script in your java program.

                4. Server returns answer: .......


                There are many iterations....

                Therefore I think it's a not good decision!

                I think you have to move your question in OBIEE workspace

                1 person found this helpful
                • 5. Re: Java URLConnection not authenticating

                  You really need to learn how http works first as rpc1 has pointed out. Your java code is not doing a lot and missing almost everything. If you use your browser as an example, it can handle javascript, redirects, cookies, none of which you are handling.

                  What you need to do first is understand the whole flow of how you login. If you use Firefox, you could install LiveHeaders to view all the requests being sent and responses being received back. Other browsers have similar plugins or extensions that will show you those.

                  Once you understand how a http post works for a login session, then you might consider using apache httpclient library instead.

                  1 person found this helpful
                  • 6. Re: Java URLConnection not authenticating
                    Pedro F

                    Hi rpc1, handat


                    Can't deny my lack of knowledge regarding http functionality in this context. I guess if I did know about it, I wouldn't have these questions to start with


                    However, your replies were useful and gave me something to carry on. I'll obviously need to read more about the subject to get a better understanding about it. The LiveHeaders tip will be particularly useful handat, thanks.


                    My initial hope was that I was just missing something quite obvious that could be easily spotted and fixed but I understand that isn't the case.


                    Once again, thanks for your replies!



                    • 7. Re: Java URLConnection not authenticating

                      It's actually Live HTTP Headers. Forgot the HTTP part