Menu

NoClassDefFoundError: Could not initialize class

Help
2021-10-29
2021-11-24
  • Amaury Attig

    Amaury Attig - 2021-10-29

    Hello, I have a TBasic Table that calls a service in a .java file located in a jar that is deployed in the project as a jar in ...user-workspace/DEFAULT/projectABC/lib/ specified in rules.xml and imported in the xls file as needed with an Environment table -> import | com.......service.ServiceImpl.

    In the table , I create a VAR | service | new ServiceImpl() ,
    then a VAR | myPolicy | service.convertPolicy(policy) on the next row.

    The code works perfectly in version 5.22.7 and below but not from 5.23.0 forward.

    It now gives the error
    NoClassDefFoundError: Could not initialize class com.......service.ServiceImpl
    when I test the TBasic with a working (policy) input.

    I run the project locally in a tomcat 9.0.52

    I have tried many ways to write the TBasic, I tried to create a Spreadsheet working the same way and it doesn't work either and I tried many different configurations/maven dependencies versions/jdk versions and nothing works.

    I would like some help with this issue please.

    Amaury

     
  • Elena Kosolapova

    Hello Amaury,
    OpenL 5.23.0 includes a number of libraries that was deleted, such as commons-configuration, dom4j, jettison, Apache JCL, JCR. Could it be that your class has a dependency on one of these libraries?
    Is it possible to share the imports in your ServiceImpl, that are not specific to your company?

    Best Regards,
    Alena.

     
    • Amaury Attig

      Amaury Attig - 2021-11-03

      Hello,
      Thank you for you advice, I tried adding the mentionned libraries in my pom.xml with no results, but if there was a way to debug or see the detailed log of what happens behind webstudio 5.23.0++ I might get a better idea of why my serviceImpl() cannot be reached at runtime. I also have a theory that you might confirm or not : My project contains a lib folder with a jar that weights 100Mb and that contains the java method called in my TBasic. Do you think that from 5.22.7 to 5.23.0, there is a point where big jars cannot be read because they are too big?

      Best Regards,
      Amaury.

       
  • OpenL Tablets

    OpenL Tablets - 2021-11-04

    Hell Amaury.

    The size of the lib folder should not affect compilation of rules. We had a project with much more size of the lib folder than 100MBytes and it was worked.

    OpenL has own classloader implementation to support multiple projects in isolated scope, like it does in Apache Tomcat application server. And it has not any limitation on the size.

    NoCLassDefFoundError exactly says that some class is absent in the classloader. It may be some annotation or a class in the parent, like JPA.

    1. Webstudio has a feature to display a stacktrace of an error. it can be helpful.
    2. Could you also try to open your project on another version 5.23.13 or 5.24.7 ? OpenL improves error handling and modern versions of WebStudio can provide more information about what happened.

    Regards,
    Yury.

     
    • Amaury Attig

      Amaury Attig - 2021-11-04

      Hello,
      The error apprears in a red square when I run the test and is displayed in the result section, so there is no little triangle to see the stackTrace and when I use Trace, it just stops at the TBasic step VAR new ServiceImpl(). So it is hard to debug or get a log of what is happening when my TBasic calls the method in my jar.
      I forgot to add a behavior that might help investigating the issue. Every time I reload the project in EDITOR with the little turning arrows button, the error is not the same the first time I Test the TBasic, it gives me :
      AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
      So it looks like the root of the problem is getting to the classLoader in the new versions (I tried 5.23.0 and many others until 5.25.1).
      I also tried putting the jar with my ServiceImpl() method in a new WEB-INF/lib folder in the tomcat/..../DEFAULT/projectABC/ and in the existing WEB-INF/lib in tomcat/webApps/webstudio and /webservice just in case it was not visible from the TBasic and it still cannot find my jar, but it finds the google gson library without problem in the TBasic. Very weird!
      Do you have another idea considering this info?
      Thanks
      Amaury

       
  • Amaury Attig

    Amaury Attig - 2021-11-24

    I finally made it work by putting the right few .jars in the apache-tomcat-9.0.52\webapps\webstudio\WEB-INF\lib\ folder. It seems the classLoader ignores some of the .jars in the ...user-workspace\DEFAULT\projectABC\lib\

    Best regards,
    Amaury

     

Log in to post a comment.