0 Replies Latest reply on Dec 12, 2019 3:58 PM by saranyachaaru500

    java.lang.UnsupportedOperationException

    saranyachaaru500

      Hi,

      I'am using wildfly-14.0.1.Final. My application have a facility to send sms automatically to the users when they submit an application. At a time,large number of

      users are accessing the site. But in some times, the sms sending process will fail and i get a java.lang.UnsupportedOperationException without any further information on it. At that time, we have to restart the server for avoiding the continuous situation.Sending messages from server to client is done via code.

       

      My code is as below:

       

      private String sndsmsAutomatic(String postingUrl, String username, String password, String senderId,

      String mobileNo, String message, String serviceType){

      String statusCode = "0";

      try {

      String encryptedPassword = (new Utils()).MD5(password), genratedHashKey = (new Utils()).hashGenerator(username, senderId, message, secureKey);

      serviceType = (serviceType == null || serviceType.trim().length() == 0 ? "singlemsg" : serviceType);

      if(postingUrl.startsWith("https:")){

      String urlParameters = "mobileno=" + mobileNo + "&bulkmobno=" + mobileNo + "&senderid=" + senderId + "&content=" +

      URLEncoder.encode(message, "UTF-8") + "&smsservicetype=" + serviceType + "&username=" +

      username + "&password=" + encryptedPassword + "&key=" + genratedHashKey;

      URL myurl = new URL(postingUrl);

      HttpsURLConnection con;

      con = (HttpsURLConnection )myurl.openConnection();

      con.setSSLSocketFactory(new TSLSocketConnectionFactory());

      con.setRequestMethod("POST");

      con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

      con.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));

      logger.info("length=====" +urlParameters.getBytes().length);//it will get correct out

      //the errors are started from below

      con.setRequestProperty("Content-Language", "en-US"); 

      con.setUseCaches (false);

      con.setDoInput(true);

      con.setDoOutput(true);

      //Send request

          DataOutputStream wr = new DataOutputStream (con.getOutputStream ());

          wr.writeBytes (urlParameters);

          wr.flush (); wr.close ();

          //Get Response

          InputStream is = con.getInputStream();

          System.out.println("input string" +is);

          BufferedReader rd = new BufferedReader(new InputStreamReader(is));

          StringBuffer response = new StringBuffer();

          while((statusCode = rd.readLine()) != null) {

          System.out.println("while==");response.append(statusCode);}

      rd.close();

      statusCode = response.toString();

      con.disconnect();

      }else{

      logger.info("Posting to MSDP via HTTP(old)...");

      HttpClient client = new HttpClient();

      PostMethod method = new PostMethod(postingUrl);

      method.getParams().setContentCharset("UTF-8");

      method.addParameter(new NameValuePair("mobileno", mobileNo));

      method.addParameter(new NameValuePair("bulkmobno", mobileNo));

      method.addParameter(new NameValuePair("senderid", senderId));

      method.addParameter(new NameValuePair("content", message));

      method.addParameter(new NameValuePair("smsservicetype", serviceType));

      method.addParameter(new NameValuePair("username", username));

      method.addParameter(new NameValuePair("password", encryptedPassword));

      method.addParameter(new NameValuePair("key", genratedHashKey));

      if(scheduledTime != null && scheduledTime.trim().length() > 0)

      method.addParameter(new NameValuePair("time", scheduledTime));

      client.executeMethod(method);

      }

      } catch (Exception e) {

      logger.fatal(e); logger.debug("SMS Sending Failed(Secured)", e);

      e.printStackTrace();

      return statusCode;

      }

       

       

      //////////////////////LOG Files are:

      server log:

      2019-12-12 06:50:00,292 INFO  [stdout] (Thread-412) sndsmsAutomatic

      2019-12-12 06:50:00,473 ERROR [stderr] (Thread-412) java.lang.UnsupportedOperationException

      2019-12-12 06:50:00,473 ERROR [stderr] (Thread-412) at abc.efg.communication.TSLSocketConnectionFactory$1$1.getCipherSuite(TSLSocketConnectionFactory.java:93)

      2019-12-12 06:50:00,473 ERROR [stderr] (Thread-412) at sun.net.www.protocol.https.HttpsClient.checkURLSpoofing(HttpsClient.java:598)

      2019-12-12 06:50:00,473 ERROR [stderr] (Thread-412) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:573)

      2019-12-12 06:50:00,473 ERROR [stderr] (Thread-412) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)

      2019-12-12 06:50:00,473 ERROR [stderr] (Thread-412) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1334)

      2019-12-12 06:50:00,474 ERROR [stderr] (Thread-412) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1309)

      2019-12-12 06:50:00,474 ERROR [stderr] (Thread-412) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:259)

      2019-12-12 06:50:00,474 ERROR [stderr] (Thread-412) at  abc.efg.communication.SendingSms.sndsmsAutomatic(AutoSendingSms.java:189)

      2019-12-12 06:50:00,474 ERROR [stderr] (Thread-412) at abc.efg.communication.SendingSms.run(AutoSendingSms.java:145)

      2019-12-12 06:50:00,474 ERROR [stderr] (Thread-412) at java.lang.Thread.run(Thread.java:748)

      2019-12-12 06:50:00,515 INFO  [stdout] (Thread-412) respCode===0

       

       

      info.log:

      10:30:00,807 [INFO](SendingSms-sndsmsAutomatic):> success TSL Connection

      10:30:00,807 [INFO](SendingSms-sndsmsAutomatic):> length=====111

      10:30:01,055 [INFO](Utils-getServerIp):> Server IP: 11.1.1.11

      10:30:01,084 [INFO](SendingSms-run):> SendingSms:[singlemsg]: (9999999999) Status= 0 - Undefined Response Code by ESMS Gateway: 0