NumberFormatException on inputTextArea?
sjmenden Sep 28, 2006 1:12 PMI am having a strange problem I am not sure how to fix, possibly a customer converter?
I have an inputTextArea which I allow the user to input any text, later to be parsed, the text can contain any characters necessarily:
<!-- Input the parameters for the Job --> <tr> <td width="20%" align="right" id="header-label"> Job Parameters: </td> <td width="80%" align="left"> <h:inputTextarea rows="25" cols="60" value="#{createPluginJob.parameterText}"/> </td> </tr>
The EJB looks like this:
@Name("createPluginJob") @Stateless public class CreatePluginJobBean implements CreatePluginJob { ... private String parameterText; public String getParameterText() {return parameterText;} public void setParameterText(String parameterText) {this.parameterText = parameterText;} ... public String create() { PluginCommand networkCommand = new PluginCommand(); networkCommand.setFqClassName(fqcn); StringReader stringReader = new StringReader(parameterText.trim()); BufferedReader reader = new BufferedReader(stringReader); String line = null; try { log.info("Parsing parameterText: \n" + parameterText); //NumberFormatException happening here while((line = reader.readLine()) != null) { log.info("extracted line: " + line); networkCommand.getParameters().put(StringUtils.substringBefore(line, "="), StringUtils.substringAfter(line, "=")); } } catch(IOException e) { log.error(e.getMessage()); } log.info("Extracted parameters: " + networkCommand.getParameters()); job.setNetworkCommand(networkCommand.buildCommand()); em.persist(job); FacesMessages.instance().add("Successfully created job"); return "createPluginJob"; } }
It seems as though the NumberFormatException is happening the first time I try to do anything with the parameterText value. The exception is as follows:
Caused by: javax.faces.el.EvaluationException: /createPluginJob.xhtml @50,93 action="#{createPluginJob.create}": javax.ejb.EJBTransactionRolledbackException: java.lang.NumberFormatException: For input string: "H" at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63) ... 27 more Caused by: javax.ejb.EJBTransactionRolledbackException: java.lang.NumberFormatException: For input string: "H" at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:93) at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:201) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181) at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79) at $Proxy104.create(Unknown Source) 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:589) at com.sun.el.parser.AstValue.invoke(AstValue.java:151) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283) at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68) at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69) ... 28 more
And the input I was providing
nmapOptions=#HOST# -T5 -O -oX #HOST#_#TIME#.xml HOST=localhost TIME=09-27-2006
So it seems as though something is choking on the pound signs or new lines, I'm not sure which. Is there anyway to circumvent this problem?