Solved

balloon message wont display after i send XMLRPC request

Posted on 2007-11-14
14
221 Views
Last Modified: 2012-08-14
When I run my application in Eclipse it works fine.  When I run it in Netbeans and it works fine.  However if i try running the executable JAR the system tray balloon messages in thie checkNow function wont work.  from trying to debug the problem ive noticed that if i place a test balloon message before my XMLRCP Request it displays and if after the request it doesnt...  i have also looked at my XMLRPCRequest class and I cant see any issues either...

can you please take a look for me.

SystemTrayTools class
----------------------------------

public void checkNow() {
       
        trayIcon.displayMessage(balloonMessageTitle,"Hi Sean - Im a balloon message!",TrayIcon.MessageType.INFO);   // displays fine
       
        XMLRPCRequest xmlRpcRequest = new XMLRPCRequest();
        xmlRpcRequest.sendRequest();
        Object response = xmlRpcRequest.getResponse();
       
        trayIcon.displayMessage(balloonMessageTitle,"Problems...",TrayIcon.MessageType.INFO);   // doesnt display regardless of what happens
       
         if(response == null) {
            propertyNotifier.stopPropertyNotifier();
        } else if(response != null) {
            if(response.toString().length() > 0) {
                String newReferenceNumber = response.toString();
                String currentReferenceNumber = readLatest(new File("latest.txt"));
                if(!currentReferenceNumber.equalsIgnoreCase(newReferenceNumber)) {
                    writeLatest(new File("latest.txt"),newReferenceNumber);
                    trayIcon.displayMessage(balloonMessageTitle,newPropertiesAdded,TrayIcon.MessageType.INFO);
                } else {
                    trayIcon.displayMessage(balloonMessageTitle,noNewPropertiesAdded,TrayIcon.MessageType.INFO);
                }
            } else {
                trayIcon.displayMessage(balloonMessageTitle,noNewPropertiesAdded,TrayIcon.MessageType.INFO);
            }
        } else if(!(response instanceof Boolean)) {
            propertyNotifier.stopPropertyNotifier();
        }
}


XMLRCPrequest class
--------------------------------------

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Vector;
import javax.swing.JOptionPane;
import org.apache.xmlrpc.XmlRpcClient;
import org.apache.xmlrpc.XmlRpcException;

public class XMLRPCRequest {
    XmlRpcClient xmlRpcClient;
    PropertyNotifier propertyNotifier;
    Vector requestParams;
    Object requestResult;
   
    public XMLRPCRequest() {
        try {
            xmlRpcClient = new XmlRpcClient("http://xmlrpc.private.com/");
            requestParams = new Vector();
        } catch (MalformedURLException e) {
            JOptionPane.showMessageDialog(null,"Malformed URL error");
        }
    }
   
    private void setResponse(Object requestResult) {
        this.requestResult = requestResult;
    }
   
    public void sendRequest() {
        try {
            requestParams.addElement("guest");
            requestResult = xmlRpcClient.execute("properties.getLatest",requestParams);
            this.setResponse(requestResult);
        } catch (XmlRpcException e) {
            JOptionPane.showMessageDialog(null,"XML-RPC Exception error");
        } catch(IOException ioe) {
            JOptionPane.showMessageDialog(null,"IO Exception error");
        }
    }
   
    public Object getResponse() {
        return this.requestResult;
    }
}
0
Comment
Question by:ellandrd
  • 7
  • 4
  • 3
14 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20278707
have u checked that the call is actually being made
0
 
LVL 16

Author Comment

by:ellandrd
ID: 20278720
yes i added a new property to test aswell.

if i place

JOptionPane.showMessageDialog(null,requestResult);

after i execute the  request, i get back the properties reference number which is what i want to get back...

i dont get any other error messages or dialogs displaying...   likei said within the IDE it works fine, but as soon as i run the JAR file, it stops
0
 
LVL 16

Author Comment

by:ellandrd
ID: 20278736
xmlRpcClient = new XmlRpcClient("http://xmlrpc.antons-law.com/");
requestParams = new Vector();
requestParams.addElement("guest");
requestResult = xmlRpcClient.execute("properties.getLatest",requestParams);
           
JOptionPane.showMessageDialog(null,requestResult);    // display R01 for example

my joptionpane message box appears if i run the application within eclipse or netbeans, but not if i run from the JAR file...  both IDE's create the JAr when i build and compile...

you can test the XMLRPC request by viewing:

http://xmlrpc.antons-law.com/test.php - you should see a reference number.  this is what i get back...

properties.getLatest maps to a PHP function that returns the latest property reference number...
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 23

Expert Comment

by:Siva Prasanna Kumar
ID: 20278749
How are you running the jar file? Please check your JRE version.  I some how feel its has some thing to do with run time settings.
0
 
LVL 92

Expert Comment

by:objects
ID: 20278750
> but not if i run from the JAR file...

that suggests the rpc call is either hung or thowing an exception (which is getting swallowed somewhere)
0
 
LVL 16

Author Comment

by:ellandrd
ID: 20278765
i using JRE 1.6.0_03
0
 
LVL 16

Author Comment

by:ellandrd
ID: 20278772
i have also set my console to show and no messages display in the console.

>>that suggests the rpc call is either hung or thowing an exception (

then shouldnt i get a JOptionPane message box ??  i dont.
0
 
LVL 16

Author Comment

by:ellandrd
ID: 20278855
ok i ran my JAR from the command line and i get this:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apach
e/xmlrpc/XmlRpcClient
        at XMLRPCRequest.<init>(XMLRPCRequest.java:19)
        at SystemTrayOptions.checkNow(SystemTrayOptions.java:84)
        at SystemTrayOptions$2.actionPerformed(SystemTrayOptions.java:50)
        at java.awt.MenuItem.processActionEvent(Unknown Source)
        at java.awt.MenuItem.processEvent(Unknown Source)
        at java.awt.MenuComponent.dispatchEventImpl(Unknown Source)
        at java.awt.MenuComponent.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)


do you think the issue with withmy XMLRPCClient JAR.  i downloaded it from  here:

http://ws.apache.org/xmlrpc/


heres the docs too: http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/client/XmlRpcClient.html#XmlRpcClient()

heres a simple example i found that i followed:  http://www.wordtracker.com/docs/api/ch03s02.html
0
 
LVL 23

Accepted Solution

by:
Siva Prasanna Kumar earned 250 total points
ID: 20278866
Yes your apache XMLRPC client  jar is not there in the classpath Please add it to classpath and execute the jar.
0
 
LVL 23

Expert Comment

by:Siva Prasanna Kumar
ID: 20278882
infact you need all the dependency jars of xml rpc project to be in the class path for successful running of your application.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 20278894
you need to specify all dependant jars in your manisfest using the ClassPath: attribute
0
 
LVL 16

Author Comment

by:ellandrd
ID: 20278901
there was only one JAR that i downloaded so i will add this to my classpath...
0
 
LVL 23

Expert Comment

by:Siva Prasanna Kumar
ID: 20278912
sure do that it must work :)
0
 
LVL 16

Author Comment

by:ellandrd
ID: 20278954
ok my problem was the path to the XMLRCPClient jar.  when i first downloaded it i save it in folder on c:\java\

i played about with examples and when i created my application i moved the JAr into another folder and didnt correct the path in eclipse so since the path was wrong, the jar was added to classpath during build...

thanks for your time and help guys...another lesson learnt!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now