Menu

Canot compile java 5 generated code

Help
rjemmons
2008-05-01
2013-04-25
  • rjemmons

    rjemmons - 2008-05-01

    I just installed Sql2Java-2-6-6, and I can generate, compile and run the sample with this line in sql2java.properties:

    template.folder.include=java cache factory db

    However, if I change the line to use Java 5:

    template.folder.include = java5

    I can generate code, but I get the errors below when I compile.  I have JDK jdk1.6.0_03 installed.

    Why won't the code compile?

    Buildfile: C:\document\eclipse\java\sql2java-2-6-6\build.xml
    prepare:
        [mkdir] Created dir: C:\document\eclipse\java\sql2java-2-6-6\build\classes
        [mkdir] Created dir: C:\document\eclipse\java\sql2java-2-6-6\build\javadoc
    compile:
        [javac] Compiling 29 source files to C:\document\eclipse\java\sql2java-2-6-6\build\classes
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\catalog\CategoryBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\catalog\CategoryBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\catalog\CategoryManager.java:223: ';' expected
        [javac] public List<ProductBean> getProductBeans(CategoryBean bean)AsList throws DAOException
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\catalog\InventoryBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\catalog\InventoryBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\catalog\ItemBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\catalog\ItemBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\order\LineitemBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\order\LineitemBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\order\OrdersBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\order\OrdersBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\order\OrderstatusBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\order\OrderstatusBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\products\product\ProductBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\products\product\ProductBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\products\product\ProductManager.java:234: ';' expected
        [javac] public List<ItemBean> getItemBeans(ProductBean bean)AsList throws DAOException
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\AccountBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\AccountBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\ProfileBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\ProfileBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\SignonBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\SignonBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\SupplierBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\SupplierBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\SupplierManager.java:277: ';' expected
        [javac] public List<ItemBean> getItemBeans(SupplierBean bean)AsList throws DAOException
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\utils\BannerdataBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\utils\BannerdataBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\utils\SequenceBean.java:15: ';' expected
        [javac] import java.util.Map<String,String>;
        [javac] ^
        [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\utils\SequenceBean.java:16: ';' expected
        [javac] import java.util.HashMap<String,String>;
        [javac] ^
        [javac] 29 errors

    BUILD FAILED
    C:\document\eclipse\java\sql2java-2-6-6\build.xml:230: Compile failed; see the compiler error output for details.

    Total time: 2 seconds

     
    • Alain Fagot Béarez

      Up to the 2.6.6 release it was expected to use the template.folder.include as follows:

      template.folder.include = java java5

      Since many of the classes generated by the java folder are also valid in Java 5 and later.

      As you are not the first one to be "surprised" by this (undocumented) feature, the next release will generate all the necessary classes by only applying java5 instead of java.

      Hope this helps,
      Alain

       
    • rjemmons

      rjemmons - 2008-05-03

      Thanks for the info, but I still get 3 compile errors.

      By the way, I think you folks are doing a great job with Sql2Java.  I tried using Hibernate, but it seems to require a truck-load of runtime jars.  I can't see how they can refer to it as "light weight."

      Without the fix I was getting 29 errors.  I think one of the problems is that the following class is not being generated:

      org.acme.sample.exception

      Here are my compile errors.

      Buildfile: C:\document\eclipse\java\sql2java-2-6-6\build.xml
      prepare:
          [mkdir] Created dir: C:\document\eclipse\java\sql2java-2-6-6\build
          [mkdir] Created dir: C:\document\eclipse\java\sql2java-2-6-6\build\classes
          [mkdir] Created dir: C:\document\eclipse\java\sql2java-2-6-6\build\javadoc
           [copy] Copying 1 file to C:\document\eclipse\java\sql2java-2-6-6\build\classes
      compile:
          [javac] Compiling 60 source files to C:\document\eclipse\java\sql2java-2-6-6\build\classes
          [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\catalog\CategoryManager.java:223: ';' expected
          [javac] public List<ProductBean> getProductBeans(CategoryBean bean)AsList throws DAOException
          [javac] ^
          [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\products\product\ProductManager.java:234: ';' expected
          [javac] public List<ItemBean> getItemBeans(ProductBean bean)AsList throws DAOException
          [javac] ^
          [javac] C:\document\eclipse\java\sql2java-2-6-6\src\java\org\acme\sample\users\SupplierManager.java:277: ';' expected
          [javac] public List<ItemBean> getItemBeans(SupplierBean bean)AsList throws DAOException
          [javac] ^
          [javac] 3 errors

      BUILD FAILED
      C:\document\eclipse\java\sql2java-2-6-6\build.xml:230: Compile failed; see the compiler error output for details.

      Total time: 2 seconds

       
      • Alain Fagot Béarez

        Sorry for this error.  It looks like we are missing some automated tests for QA...

        The manager.java.vm template's line that reads

            public List<$importedClass> get${importedClass}s($beanClass bean)AsList throws DAOException

        should read

            public List<$importedClass> get${importedClass}sAsList($beanClass bean) throws DAOException

        It looks like at some point in the template editing the "AsList" part of the method name was moved in the wrong place.

        You may want to replace your version of the template by the current one:

        http://sql2java.cvs.sourceforge.net/sql2java/sql2java/src/templates/velocity/java5/pertable/manager.java.vm?view=markup

        Many thanks for reporting.

        Alain

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.