4 Replies Latest reply on Feb 11, 2015 11:41 AM by Martin Volbers

    keyword DECIMAL provokes error

    Martin Volbers Newbie



      I tried to fix my bug for a few days now, reading books and blogs. The fact that this question is posted here may be regarded as a result of upright desperation. Sorry to all, who read this and roll eyes.


      I use the org.modeshape.sequencer.ddl.DdlParsers class. When reaching the keyword DECIMAL in my ddl, I get this:


      Usage: de.gad.seu.rme.scanner.ddl.Parser filename



      filename is the name of the DDL file to be parsed


      Error: java.lang.Integer cannot be cast to java.lang.Long


      INTEGER works fine. To help me it might be helpful to regard the sipmple things...


      Thanxxx a lot for yout answers!

        • 1. Re: keyword DECIMAL provokes error
          Randall Hauch Master

          Parsing DDL is very context-sensitive, so we'd need to see some sample DDL with information about the type of DDL (what DBMS is it for, and is it one of the grammars that ModeShape supports) and where in the DDL file the parser is failing. A more complete stack trace would be nice so we could help isolate the problem (if there is one).


          Of course, our community's code is open source, so you could always step through the parsing code and try to find the problem and suggest a fix.

          1 of 1 people found this helpful
          • 2. Re: Re: keyword DECIMAL provokes error
            Martin Volbers Newbie

            Yes, I'll get and debug the sources.


            The input file contains

            --- First line follows:


                                                      ,FIELD_2  DECIMAL(9,2)  NOT NULL

                                                      ,FIELD_3 CHAR(3) NOT NULL

                                                      ,PRIMARY KEY (FIELD1


                                                      ) IN Tablespace;


            --- first line not in file

            If it is a bug in the parser it should occur with this statement. The critical literal ist coloured red in line 2


            The error

            Error: java.lang.Integer cannot be cast to java.lang.Long


            is printed by


            protected static void printError(int exitCode, String message) {
               System.err.println("Error: " + message);



            which is part of the parser. The parser itself is copied from an example parser where literals were translated.


            I'll keep you up to date about my debugging results.

            • 3. Re: Re: keyword DECIMAL provokes error
              Randall Hauch Master

              We have quite a few unit tests for various parsers in our codebase. You may find it pretty easy to create a new test method (or multiple ones) in the class for the appropriate dialect (e.g., PostgresDdlParserTest.java for the PostgreSQL parser, etc.); it might be easy to debug when just running the parser. Doing this also makes it very easy for you to create a pull-request with your additions, allowing us to directly re-use your tests and incorporate them into our codebase. And, if it turns out there is a bug in the code, then these tests would likely be either sufficient to prevent regressions or at the very least a great start.


              BTW, if you happen to find a bug and fix it locally, then log an issue in our JIRA and include the fix in your pull-request. We'll review and, if we have no questions or concerns, merge it into the codebase.

              • 4. Re: keyword DECIMAL provokes error
                Martin Volbers Newbie

                I got it.


                In the parser sample I copied was code like


                Object prop = node.getProperty(DATATYPE_LENGTH);

                if (prop != null)

                     column.length = (int) number(prop);


                where number was a "if value != null return (Long) value;"


                This worked fine a few times and threw an exception.


                I changed it to

                     coloumn.length = Integer.valueof(prop.toString());

                and it works fine now.


                Thank you for your patience. If a noob diploma confirms beeing a noob this may be one.