Solved

balloon message wont display after i send XMLRPC request

Posted on 2007-11-14
14
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

705 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