ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » 2059 - Applet works OK from IDE, but not the browser

Post new topic  Reply to topic
 2059 - Applet works OK from IDE, but not the browser « View previous topic :: View next topic » 
Author Message
PeterPotkay
PostPosted: Fri Jan 10, 2003 11:23 am    Post subject: 2059 - Applet works OK from IDE, but not the browser Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

The below applet connects to a QM on another machine, and opens a queue to check its depth. It works just fine when I execute the project from within Visual Cafe, but when I try to insert the applet into an HTML file it throws a 2059 error on the connect.

I get the same errors when using the Applet Viewer window. From the Applet Viewer window, I did go to Applet...Properties and set the Class Access to Unrestricted.

Any idea why a browser is affecting the connection? ( Be gentle, this is my 1st attempt at coding in JAVA)





Code:

import java.awt.*;
import java.applet.*;
import javax.swing.JTextPane;
import javax.swing.JButton;
import com.ibm.mq.*;

public class Applet5 extends Applet
{
  String theQueue1 = "HIG.PC.PL.TEST";
   MQQueue myQueueObjectA1 = null;
   
   String theQueueManagerA = "KWELCH";
   //String theHostnameA = "plcadctd0255";   
   String theHostnameA = "157.209.105.95"; //this is the IP address for plcadctd0255
  int thePortA = 1414;
  String theChannelNameA = "KWELCH.CLIENT";
  MQQueueManager myQueueManagerObjectA = null;
   
   public void init()
   {
      // Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
      //symantec.itools.lang.Context.setApplet(this);
   
      // This code is automatically generated by Visual Cafe when you add
      // components to the visual environment. It instantiates and initializes
      // the components. To modify the code, only use code syntax that matches
      // what Visual Cafe can generate, or Visual Cafe may be unable to back
      // parse your Java file into its visual environment.
      //{{INIT_CONTROLS
      setLayout(null);
      setBackground(java.awt.Color.lightGray);
      setSize(639,162);
      JTextPane1.setText(theQueueManagerA);
      add(JTextPane1);
      JTextPane1.setBounds(24,12,396,24);
      JTextPane2.setText(theQueue1);
      add(JTextPane2);
      JTextPane2.setBounds(24,48,396,24);
      //JTextPane3.setText("999");
      add(JTextPane3);
      JTextPane3.setBounds(456,48,108,24);
      JButton1.setText("Refresh");
      add(JButton1);
      JButton1.setBounds(468,84,84,24);
      //}}
   
      //{{REGISTER_LISTENERS
      SymMouse aSymMouse = new SymMouse();
      JButton1.addMouseListener(aSymMouse);
      SymContainer aSymContainer = new SymContainer();
      this.addContainerListener(aSymContainer);
      //}}
   }
   
   public void start()
   {
      openConnection();
      System.out.println("openConnection done");
      
      refreshDepths();
      System.out.println("refreshDepths done");
      
   }
   
   public void destroy()
   {
     System.out.println("closeConnection about to start");
    
     closeConnection();
    
     System.out.println("closeConnection done");    
   }
   
   
   private void openConnection()         
   {
      try
      {
      //Create a connection to the first queue manager;
     MQEnvironment.hostname = theHostnameA;
    //MQEnvironment.port = thePortA;
     MQEnvironment.channel = theChannelNameA;
     MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,//Set TCP/IP or server
                                  MQC.TRANSPORT_MQSERIES);//Connection

     myQueueManagerObjectA = new MQQueueManager(theQueueManagerA);
   
     //Set up the options for doing the MQOPEN on the queue for MQINQ;
     int myOpenOptions = MQC.MQOO_INQUIRE;

     //Create my queue objects ("open" the queues);
     myQueueObjectA1 = myQueueManagerObjectA.accessQueue(theQueue1,myOpenOptions);
     }
    
     catch (MQException ex)
     {
        System.out.println("It didn't work 100 percent: CC=" + ex.completionCode + " RC=" +ex.reasonCode);
     }
     catch (Exception ex)
     {
        System.out.println("GENERAL EXCEPTION=" + ex.getMessage());
     }
   }//end of openConnection method
   
   
   private void refreshDepths()
   {
     try
     {
     int theActualDepth = 0;
    theActualDepth = myQueueObjectA1.getCurrentDepth();
    JTextPane3.setText(String.valueOf(theActualDepth));
    }
   
    catch (MQException ex)
     {
        System.out.println("It didn't work 100 percent: CC=" + ex.completionCode + " RC=" +ex.reasonCode);
     }
     catch (Exception ex)
     {
        System.out.println("GENERAL EXCEPTION=" + ex.getMessage());
     }
   }//end of refreshDepths method
   
   
   private void closeConnection()
   {
         
     try
     {
     //Close the queues;
     myQueueObjectA1.close();
     //Disconnect from the queue managers;
     myQueueManagerObjectA.disconnect();
     System.out.println("All the Queue Managers are now disconnected.");
     }
     catch (MQException ex)
     {
        System.out.println("It didn't work 100 percent: CC=" + ex.completionCode + " RC=" +ex.reasonCode);
     }
     catch (Exception ex)
     {
        System.out.println("GENERAL EXCEPTION=" + ex.getMessage());
     }
   }// end of closeConnections method
   
   
   
   
   //{{DECLARE_CONTROLS
   javax.swing.JTextPane JTextPane1 = new javax.swing.JTextPane();
   javax.swing.JTextPane JTextPane2 = new javax.swing.JTextPane();
   javax.swing.JTextPane JTextPane3 = new javax.swing.JTextPane();
   javax.swing.JButton JButton1 = new javax.swing.JButton();
   //}}

   class SymMouse extends java.awt.event.MouseAdapter
   {
      public void mouseClicked(java.awt.event.MouseEvent event)
      {
         Object object = event.getSource();
         if (object == JButton1)
            JButton1_mouseClicked(event);
      }
   }

   void JButton1_mouseClicked(java.awt.event.MouseEvent event)
   {
      // to do: code goes here.
      refreshDepths();
      System.out.println("refreshDepths done");
   }


   class SymContainer extends java.awt.event.ContainerAdapter
   {
      public void componentAdded(java.awt.event.ContainerEvent event)
      {
         Object object = event.getSource();
         if (object == Applet5.this)
            Applet5_ComponentAdded(event);
      }
   }


   void Applet5_ComponentAdded(java.awt.event.ContainerEvent event)
   {
      // to do: code goes here.
   }
}

_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
bower5932
PostPosted: Fri Jan 10, 2003 12:45 pm    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

There is a comment at the top of the MQSample.java
Quote:

// Note. If you receive MQ error 2 reason 2059 and you are sure your MQ and TCPIP
// setup is correct,
// you should click on the "Applet" selection in the Applet viewer window
// select properties, and change "Network access" to unrestricted.

You mentioned changin the class access. Is this the same as the network access?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
PeterPotkay
PostPosted: Fri Jan 10, 2003 7:04 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

bower,
That's what I was wondering. There was no Network Access setting, just Class Access, but flipping that setting either way makes no diff.

It is weird that it works from the IDE, but not from a browser or from the appletviewer. Does the browser invoke the applet viewer when the applet is started from within an html page? If so, then it would seem the common denominator is some security? setting in the applet viewer, but I just don't see anything else to change.

Now when I run the applet from the IDE (and unselect the option for the IDE to start up the applet in a browser), the applet works fine. When I click on the applet viewer properties from here, the class access is again unrestricted, but the Http proxy port # is blank. In the applet viewer, I can't change the Http proxy port# from the prefilled 80. I space it out and it reverts back to port 80. Is that a clue?


I also don't see any errors being generated on the box with the queue manager. Should there be? Maybe something more detailed as to why the 2059 is being thrown?

The following error is being thrown to the JAVA console on the client machine.

Code:


MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE012: Security error - cannot connect to host 157.209.105.95
MQJE001: Completion Code 2, Reason 2059
com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2059    at
com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:172)
at
com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQCl
ientManagedConnectionFactoryJ11.java:270)    at
com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQCli
entManagedConnectionFactoryJ11.java:290)    at
com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:80)
at
com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionMa
nager.java:150)    at
com.ibm.mq.MQQueueManager.obtainBaseMQQueueManager(MQQueueManager.java:682)
at com.ibm.mq.MQQueueManager.construct(MQQueueManager.java:620)    at
com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:393)    at
Applet5.openConnection(Applet5.java:90)    at
Applet5.start(Applet5.java:61)    at sun.applet.AppletPanel.run(Unknown
Source)    at java.lang.Thread.run(Unknown Source) getcause=null
openConnection It didn't work 100 percent: CC=2 RC=2059 openConnection done
GENERAL EXCEPTION=null refreshDepths done


_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Tue Jan 14, 2003 5:44 am    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

I guess there is no way for this to work. By design, applets loaded in a browser cannot make a network connection to another computer.
http://java.sun.com/sfaq/#socket


I think I will have to try this idea by using a JSP page that refreshes itself every 5 seconds or so to give updated queue info.


Still curious why the applet run from the applet viewer in IDE works but not from the applet viewer from the command prompt.
And why does IBM put that note about 2059 errors and security settings in the sample applet code? Is there a way to override the applets inability to connect to a remote computer?
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Tue Jan 14, 2003 11:37 am    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722



I got the applet to connect to a remote queue manager through the browser or thru the applet viewer.

The answer is in Appendix F of the Using Java manual for IBM.
http://publibfp.boulder.ibm.com/epubs/html/csqzaw09/csqzaw09tfrm.htm

THANK YOU JAMES KINGDON FROM HURSLEY for pointing me in this direction.


In your browser, go to Tools...Internet Options...Advanced and see what Java Plug-In your browser is using (Under JAVA SUN).
On your PC, in the directory that has that plug in, find the java.policy file and make the changes specified under Appendix F in the manual.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » 2059 - Applet works OK from IDE, but not the browser
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.