Solved

balloon message wont display after i send XMLRPC request

Posted on 2007-11-14
14
217 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countAbc challenge 9 49
word0 challenge 4 53
Java Jpanels and Jframe 8 20
Java JRE greater than 1.6 5 21
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…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

706 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

18 Experts available now in Live!

Get 1:1 Help Now