Lym
Lym

Reputation: 326

java.lang.IllegalArgumentException, yet argument appears to be of valid type

I have a jax-ws web service class with a web operation written as:

public String processIncomingMsg(int msgType, String senderCB, int receiveCB,
                int ussdOpType, String msIsdn, String serviceCode,
                int codeScheme, String ussdString,
                NamedParameterList extenionInfo) {

the service is deployed in the glassfish webserver so I have access to http://localhost:8080/AppName/ReceiveUSSDNotifications?Tester which is a form that is used to invoke the web service operation. When I enter receiveCB, one of the method parameters, as 0XFFFFFF. I see "Cannot convert 0xFFFFFFFF in int" in the glassfish server logs and

WS00041: Service invocation threw an exception with message : null; Refer to the server log for more details
Exceptions details : java.lang.IllegalArgumentException
javax.servlet.ServletException: java.lang.IllegalArgumentException at org.glassfish.webservices.monitoring.WebServiceTesterServlet.doPost(WebServiceTesterServlet.java:342) 
at org.glassfish.webservices.monitoring.WebServiceTesterServlet.invoke(WebServiceTesterServlet.java:106) 
at org.glassfish.webservices.JAXWSServlet.doPost(JAXWSServlet.java:157) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)  
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 
at ...

As the response (error log) from the browser. I wonder what could be going wrong because 0xffffff is just a hex representation of an integer and so there shouldn't be a conversion problem.

Upvotes: 0

Views: 2556

Answers (1)

kolossus
kolossus

Reputation: 20691

You should post your full stacktrace here.

At face value, I would say your expectation is not realistic:

  1. What you've supplied, for all intents and purposes is a String and by your operation definition, it's supposed to be converted to an int. The only way this could possibly happen is using some variant of Integer.parseInt, specifically the variant that converts hex to decimal,Integer.parseInt(int, 16). Any other incarnation of that method will blow up with a NumberFormatException. How would the testing tool or JAXB know you're not providing a Base-10 format, to be using the right variant of parseInt? Not to mention the preceeding "0x" would make it nonconvertible anyway

  2. Even if it somehow got converted, you'll find that Integer.MAX_VALUE== 2147483647, which is less than FFFFFF==4294967295. Another NumberFormatException. What you should have there is a long

Upvotes: 1

Related Questions