5 Replies Latest reply: May 17, 2012 1:55 AM by Bshannon-Oracle RSS

    java.lang.NumberFormatException when sending mails

    in the line of fire
      Gurus,


      I am using java mail 1.4 to send mails from my application and the code to do so is
          public void postMail(String recipient, String message) {
              logger.fine("in postMail method..");
              boolean debug = true;
              Properties props = new Properties();
              props.put("mail.transport.protocol", "smtp");
              props.put("mail.smtp.host", ConfigProperty.getProperty("mail.smtp.host"));
              props.put("mail.smtp.auth","true"); 
              props.put("mail.smtp.port", ConfigProperty.getProperty("mail.smtp.port"));
              props.put("mail.smtp.from", ConfigProperty.getProperty("mail.from"));
              Session session = Session.getDefaultInstance(props, null);
              session.setDebug(debug);
              Message msg = new MimeMessage(session);
              try {
                  String from = ConfigProperty.getProperty("mail.from").trim();
                  InternetAddress addressFrom = new InternetAddress(from);
                  msg.setFrom(addressFrom);
                  InternetAddress addressTo = new InternetAddress(recipient);
                  msg.addRecipient(Message.RecipientType.TO, addressTo);
                  msg.setSubject(ConfigProperty.getProperty("mail.subject"));
                  msg.setContent(message, "text/plain");
                  logger.info("Sending mail now...............................");
                  Transport trans = session.getTransport("smtp");
                  trans.connect("casarray.arg.ae",username,password); 
                  trans.send(msg);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      However i am getting the strange error when sending mails. My email is is very simple abc.pqr@gmail.com

      Please help me understand the issue here

      java.lang.NumberFormatException: For input string: ""
           at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
           at java.lang.Integer.parseInt(Integer.java:470)
           at java.lang.Integer.parseInt(Integer.java:499)
           at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:398)
           at javax.mail.Service.connect(Service.java:288)
           at javax.mail.Service.connect(Service.java:169)
           at com.roadMiles.view.util.EmailNotification.postMail(EmailNotification.java:54)
           at com.roadMiles.view.unsecure.page.bean.LoginPageBean.forgotPassword(LoginPageBean.java:180)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at com.sun.el.parser.AstValue.invoke(Unknown Source)
           at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
           at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
           at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
           at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
           at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
           at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
           at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
           at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
           at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
           at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
           at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
           at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
           at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
           at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:788)
           at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:306)
           at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:186)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
           at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
           at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
           at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
           at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
           at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
           at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
           at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
           at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
           at java.security.AccessController.doPrivileged(Native Method)
           at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
           at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
           at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
           at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
           at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
           at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
           at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
           at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
           at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
           at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
           at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)