-3

so I been working with this project for a while now, and I recently came across with this problem.

Everytime the app compiles just fine, but when the app its going to launch it gives me this when i press the details button:

java.lang.NumberFormatException: For input string: "\ProyectoOUMA\ouma.administracfdi.Reader\dist"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:580)
    at java.lang.Integer.parseInt(Integer.java:615)
    at com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx(Unknown Source)
    at com.sun.deploy.security.DeployManifestChecker.verifyCodebase(Unknown Source)
    at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
    at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
    at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Source)
    at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
    at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.launch(Unknown Source)
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main.access$000(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)

Here is the code I'm working with:

   `package ouma.administracfdi.reader;

    import java.io.File;
    import java.io.IOException;
    import java.nio.file.Files;
    import java.util.ArrayList;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import jxl.read.biff.BiffException;
    import jxl.write.WriteException;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;

   public class OumaAdministracfdiReader {

public static ArrayList<DatosCfdi> arraydatoscfdi = new ArrayList<>();

DatosCfdi leerXml(File file, String ruta) throws ParserConfigurationException, SAXException, IOException{
    DatosCfdi cfdi = new DatosCfdi();
    NodeList list;
    Node node;
    Element element;
    String naturaleza = null;

    try {
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
        list = (NodeList)  documentBuilder.parse(file).getElementsByTagName("cfdi:Comprobante"); //VALIDADA
        NodeList sublista, subsublista;
        Node subnodo, subsubnodo;

        for (int i = 0; i < list.getLength(); i++){
            node = list.item(i);
            try {
                 cfdi.setSubt(Double.parseDouble(node.getAttributes().getNamedItem("subTotal").getNodeValue()));
                 cfdi.setTotal(Double.parseDouble(node.getAttributes().getNamedItem("total").getNodeValue()));
                 cfdi.setTipo(node.getAttributes().getNamedItem("tipoDeComprobante").getNodeValue());
                 cfdi.setMotdes(node.getAttributes().getNamedItem("motivoDescuento").getNodeValue());      
            } catch (NullPointerException | NumberFormatException numex) { }//CATCH
                 cfdi.setFecha(node.getAttributes().getNamedItem("fecha").getNodeValue());
                cfdi.setRuta(ruta);

            sublista = node.getChildNodes();
                for (int a = 0; a < sublista.getLength(); a++){
                    subnodo = sublista.item(a);
                    try {
                    switch(subnodo.getNodeName()){
                        case "cfdi:Emisor": cfdi.setRfce(subnodo.getAttributes().getNamedItem("rfc").getNodeValue());
                            cfdi.setNome(subnodo.getAttributes().getNamedItem("nombre").getNodeValue()); break;
                        case "cfdi:Receptor": cfdi.setRfcr(subnodo.getAttributes().getNamedItem("rfc").getNodeValue());
                            cfdi.setNomr(subnodo.getAttributes().getNamedItem("nombre").getNodeValue()); break;
                        case "cfdi:Impuestos": 
                            try {
                            cfdi.setImpTra(Double.parseDouble(subnodo.getAttributes().getNamedItem("totalImpuestosTrasladados").getNodeValue()));
                            cfdi.setImpRet(Double.parseDouble(subnodo.getAttributes().getNamedItem("totalImpuestosRetenidos").getNodeValue()));
                        } catch (NullPointerException nullex) {}
                            subsublista = subnodo.getChildNodes();
                            //System.out.println("Tamaño sublista: " + subsublista.getLength());
                            for (int e = 0; e < subsublista.getLength(); e++){
                               // System.out.println("Valor de e: " + e);
                                subsubnodo = subsublista.item(e);
                                //System.out.println("NOMBRE DEL SUB SUB NODO: " + subsubnodo.getNodeName());
                                    if (subsubnodo.getNodeName().equalsIgnoreCase("cfdi:Retenciones")){
                                        NodeList ssubsubnodo;
                                        ssubsubnodo = subsubnodo.getChildNodes();                   
                                        for (int u = 0; u < ssubsubnodo.getLength(); u++){
                                            //System.out.println("Valor de U: " + u);
                                            if (ssubsubnodo.item(u).getNodeName().equalsIgnoreCase("cfdi:Retencion")){
                                                //System.out.println("NOMBRE DEL SSSUBNODO: " + ssubsubnodo.item(u).getNodeName());
                                                //System.out.println(ssubsubnodo.item(u).getAttributes().getNamedItem("impuesto").getNodeValue() + " " + ssubsubnodo.item(u).getAttributes().getNamedItem("importe").getNodeValue());
                                                           if (ssubsubnodo.item(u).getAttributes().getNamedItem("impuesto").getNodeValue().equalsIgnoreCase("ISR")) {
                                                                cfdi.setImpRetIsr(Double.parseDouble(ssubsubnodo.item(u).getAttributes().getNamedItem("importe").getNodeValue()));}
                                                            if (ssubsubnodo.item(u).getAttributes().getNamedItem("impuesto").getNodeValue().equalsIgnoreCase("IVA")) {
                                                                cfdi.setImpRetIva(Double.parseDouble(ssubsubnodo.item(u).getAttributes().getNamedItem("importe").getNodeValue()));}
                                            }
                                        }//FOR
                                        }//IF
                            } break;
                        case "cfdi:Complemento": subsublista = subnodo.getChildNodes();
                            for (int e=0; e < subsublista.getLength(); e++){
                                subsubnodo = subsublista.item(e);
                                    if (subsubnodo.getNodeName().matches("tfd:TimbreFiscalDigital")){
                                        cfdi.setUuid(subsubnodo.getAttributes().getNamedItem("UUID").getNodeValue());}
                            } break;
                        default : break;
                }} catch(NullPointerException nullex) {}
                }             
         }//FOR 
    } catch (SAXParseException saxe) {cfdi.setRuta(saxe.getMessage() + " " + ruta);}
return cfdi;}

public void recorrerCarpetas(String ruta, CfdiReader f) throws ParserConfigurationException, SAXException, IOException {
    DatosCfdi cfdi = new DatosCfdi();
    File folder = new File(ruta);
    File[] xmlFiles = folder.listFiles();
    String filetype;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    //NodeList list, listemisor, listreceptor, listtfd;
  for (int a = 0; a < xmlFiles.length; a++) {
      filetype = Files.probeContentType(xmlFiles[a].toPath()); 
        if (xmlFiles[a].isFile()  && filetype.contains("xml") && !(xmlFiles[a].getName().equals(".xml"))){
            //System.out.println(xmlFiles[a].getPath() + " " + xmlFiles[a].getName());
            System.out.println(xmlFiles[a].getPath());
              f.archivosenprocesoText.setText(Integer.toString(a));
              f.salidaTextArea.setText(xmlFiles[a].getPath());
              cfdi = this.leerXml(xmlFiles[a], ruta + "\\" + xmlFiles[a].getName());
                arraydatoscfdi.add(cfdi);
                }//IS FILE?
        else { if (xmlFiles[a].isDirectory()) {
                    this.recorrerCarpetas(ruta + "\\"+xmlFiles[a].getName(), f);}}

    }
  }

public static void main(String[] args) throws ParserConfigurationException, IOException, SAXException, BiffException, WriteException, Exception {
    OumaAdministracfdiReader a = new OumaAdministracfdiReader();
    //a.ejecuta(args);
}

public void ejecuta(String[] args, CfdiReader f) throws Exception {
    OumaAdministracfdiReader lee = new OumaAdministracfdiReader();
    GuardarDatosExcelApache aexcel = new GuardarDatosExcelApache();
    String carpetaactual, carpetaguardar, nombrearchivo;
        carpetaactual = f.directorioTextField.getText();
        carpetaguardar = f.directorioguardarText.getText();
        nombrearchivo = f.nombrearchivoText.getText();   
        lee.recorrerCarpetas(carpetaactual, f);
        f.archivosenprocesoText.setText(String.valueOf(arraydatoscfdi.size()));
        //System.out.println(arraydatoscfdi.size());
       aexcel.guardarEnExcel(arraydatoscfdi, nombrearchivo, carpetaguardar);
    }

public static final String NEWLINE = "\n";

}`

Here is the jnlp:

`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <jnlp codebase="file:/C:/ProyectoOUMA/ouma.administracfdi.Reader/dist/"               href="launch.jnlp" spec="1.0+">
<information>
    <title>ouma.administracfdi.Reader</title>
    <vendor>USUARIO</vendor>
    <homepage href=""/>
    <description>ouma.administracfdi.Reader</description>
    <description kind="short">ouma.administracfdi.Reader</description>
<offline-allowed/>
</information>
<update check="background"/>
<security>
<all-permissions/>
</security>
<resources>
    <j2se java-vm-args="-Xms2048m" version="1.8+"/>
    <jar href="ouma.administracfdi.Reader.jar" main="true"/>
 <jar href="lib/poi-ooxml-3.13-20150929.jar"/>
 <jar href="lib/poi-3.13-20150929.jar"/>
 <jar href="lib/xmlbeans-2.6.0.jar"/>
 <jar href="lib/poi-examples-3.13-20150929.jar"/>
 <jar href="lib/poi-excelant-3.13-20150929.jar"/>
 <jar href="lib/poi-ooxml-schemas-3.13-20150929.jar"/>
 <jar href="lib/jxl.jar"/>
 <extension href="jnlpcomponent1.jnlp"/>
 </resources>
<application-desc main-class="ouma.administracfdi.reader.CfdiReader">
</application-desc>
</jnlp>`

I'm working in NetBeans.

Thanks for the answers!

Juan Carlos
  • 19
  • 1
  • 9
  • 3
    Where is the code and the input? – VatsalSura Aug 09 '16 at 17:43
  • 2
    You are probably not going to get a lot of help without posting an [mcve] (See [ask]). That being said, you're passing a string to whatever number parsing method you're using that's not a number and not handling the exception when you do it. – Tibrogargan Aug 09 '16 at 17:45
  • Looks like you are trying to parse `\ProyectoOUMA\ouma.administracfdi.Reader\dist` as a number. Seems like a difficult task. – bradimus Aug 09 '16 at 17:46
  • 1
    It is trying to convert this `"\ProyectoOUMA\ouma.administracfdi.Reader\dist"` string to a number. As it is not a number, Java throws that Exception. – ericbn Aug 09 '16 at 17:47
  • `com.sun.javaws` This is webstart - please post the jnlp. – copeg Aug 09 '16 at 17:47
  • Can you show the constructor for `OumaAdministracfdiReader`? – κροκς Aug 09 '16 at 17:56
  • 1
    reolace empty catch clauses like `catch (NullPointerException nullex) {}` with `catch (NullPointerException nullex) {nullex.printStackTrace() }` to get some useful information about caught exceptions. – c0der Aug 09 '16 at 18:00
  • 1
    The issue is most likely the jnlp and/or application signing - see some suggestions [here](http://stackoverflow.com/questions/24828641/java-web-start-numberformatexception-while-running-jar-application) and [here](http://stackoverflow.com/questions/29201661/netbeans-jnlp-webstart-error) – copeg Aug 09 '16 at 18:08
  • what is the version of your JDK JRE? also so many discussion have been done for this topic on SO. also check this [https://netbeans.org/bugzilla/show_bug.cgi?id=236765](https://netbeans.org/bugzilla/show_bug.cgi?id=236765) – Rishal Aug 09 '16 at 18:08
  • @Rishaldevsingh JRE and JDK are both up to date – Juan Carlos Aug 09 '16 at 18:10
  • @Juan_Carlos as suggested by copeg check this one also[http://stackoverflow.com/questions/2032491/local-alternative-to-jnlp-file/2417010#2417010](http://stackoverflow.com/questions/2032491/local-alternative-to-jnlp-file/2417010#2417010) – Rishal Aug 09 '16 at 18:20
  • I'll check them out thanks guys! @Rishaldevsingh – Juan Carlos Aug 09 '16 at 18:29
  • @Rishaldevsingh I haven't found a solution to the problem, does anybody have more ideas? – Juan Carlos Aug 12 '16 at 17:55

1 Answers1

-1

Since you don't have any code, I can't say for certain, but I assume the problem is that you pass in a String somewhere and not a file. For example, you may have:

("\ProyectoOUMA\ouma.administracfdi.Reader\dist");

when you should have:

(new File("\ProyectoOUMA\ouma.administracfdi.Reader\dist"));

If this doesn't help, I'd be happy to take another look if I can see your code.

RobotKarel314
  • 417
  • 3
  • 14
  • To whoever downvoted this answer, may I please have an explanation as to why it was downvoted? You obviously didn't bother to leave anything constructive... – RobotKarel314 Aug 09 '16 at 17:50
  • 1
    Not the downvoter, but it is unclear how passing a String rather than File will result in a `NumberFormatException` (or the stack trace posted, which hints at this being an issue with the javaws jnlp file) – copeg Aug 09 '16 at 17:53
  • I'm not the downvoter, but I'd guess their reason was something along the the lines of "Post an answer, not a guess". – bradimus Aug 09 '16 at 17:53
  • I suppose that's fair. – RobotKarel314 Aug 09 '16 at 17:58
  • By looking at the stack trace, one can notice that the error occurs inside com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx, which is responsible for checking the jar's signature. – Haroldo_OK Oct 25 '16 at 10:34