1

I'm building a batch with Pentaho Kettle to process some files. This batch is started by a servlet. However, when I try to start it, I get the following warn which actually block the process:

WARN  [org.jboss.modules] (Batch Thread - 2) Failed to define class org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore in Module "deployment.my-program-1.0.0.0-SNAPSHOT.war:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/pentaho/di/core/attributes/metastore/EmbeddedMetaStore (Module "deployment.my-program-1.0.0.0-SNAPSHOT.war:main" from Service Module Loader): org/pentaho/metastore/api/BaseMetaStore
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
at org.jboss.modules.Module.loadModuleClass(Module.java:605)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at org.pentaho.di.base.AbstractMeta.<init>(AbstractMeta.java:162)
at org.pentaho.di.job.JobMeta.<init>(JobMeta.java:201)
at org.pentaho.di.job.JobMeta.<init>(JobMeta.java:755)

However, when I look in my lib folder, the jar containing this class (kettle-engine-8.2.0.0-342.jar) is there and the class is also in it.

I'm using a JBoss EAP 7.0 with Java 1.8.0.161 on my computer for development. I start it with my IDE (Eclipse Photon). Here are my dependencies in the pom.xml:

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
    </dependency>
    <!-- vf2 debug -->
    <dependency>
         <groupId>org.apache.commons</groupId>
        <artifactId>commons-vfs2</artifactId>
        <version>2.2</version>
    </dependency>

    <!-- maven-war-plugin-->
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.2</version>
    </dependency>

    <!-- pentaho kettle -->
    <dependency>
        <groupId>pentaho-kettle</groupId>
        <artifactId>kettle-core</artifactId>
        <version>8.2.0.0-342</version>
    </dependency>
    <dependency>
        <groupId>pentaho-kettle</groupId>
        <artifactId>kettle-engine</artifactId>
        <version>8.2.0.0-342</version>
    </dependency>

    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.janino</groupId>
        <artifactId>janino</artifactId>
        <version>2.5.16</version>
    </dependency>       
    <dependency>
        <groupId>org.mozilla</groupId>
        <artifactId>rhino</artifactId>
        <version>1.7R3</version>
    </dependency>
    <!-- this correct an error -->
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>

    <!-- netty version override to correct netty 3.7 bug / FYI, pentaho don't use netty anyway-->
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty</artifactId>
        <version>3.9.0.Final</version>
    </dependency>
</dependencies>

Important : this issue does not occur when using previous version of kettle-core and kettle-engine (tested with 7.0). It's an embedded call so I do not directly call this class in my code.

I do not have multiple versions of this jar in my classpath.

Eve
  • 59
  • 1
  • 10
  • Welcome to Stack Overflow! Mind sharing a bit of code, so we can get a better idea of what the imports and class definitions you have look like? – Docteur Jan 25 '19 at 14:15
  • Might also be worth your time to look at [this question](https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java), especially [this answer](https://stackoverflow.com/a/38614741/4377568). Might have a previous version of kettle-core around. Have you tried doing a mvn clean? – Docteur Jan 25 '19 at 14:20
  • @Docteur What do you mean by imports and class definitions? I tried to catch the error with the System.out.println(TheNoDefFoundClass.class.getProtectionDomain().getCodeSource().getLocation());, however I didn't succeed at actually catching them. :( – Eve Jan 25 '19 at 14:44
  • I assume you have some Java code where you use that class in your war; It could be good to have a look at how you declare the class, could be a clue as to how to fix this – Docteur Jan 25 '19 at 14:45
  • Actually it's an embedded call so I do not directly call this class in my code. – Eve Jan 25 '19 at 14:57
  • 1
    Please check if you have multiple versions of the jar in your classpath. Most of the time this is the reason. – suresh Jan 25 '19 at 15:35
  • I found this might be helpful for you. https://forums.pentaho.com/threads/149609-java-lang-ClassNotFoundException-org-pentaho-di-core-exception-KettleException/page2/?s=0e61151cdb88e74b4f320c987812dbb8 – suresh Jan 25 '19 at 15:40
  • @suresh the link is a ClassNotFoundException instead of a NoClassDefFoundError. Might still help, but just wanted to point it out in case you missed it – Docteur Jan 25 '19 at 15:42
  • What about org/pentaho/metastore/api/BaseMetaStore? Is this class also in the classpath? This class should be located in `pentahometastore8.2.0.0-342` – wirnse Jan 29 '19 at 04:30

1 Answers1

0

Another person in my company found out so i'll just answer here to close the topic. I didn't show it here but in my dependencies I had a dependency to some custom framework from work. This framework actually included pentaho, but the 7.0 version. Then, @suresh was right when he talk about multiple version jar.

So the answer is :

Check if any dependency actually contains duplicate dependency you're calling somewhere else. To avoid this issue, use the excluding syntax in the dependency calling the wrong versions :

        <exclusions>
            <exclusion>
                <groupId>pentaho-kettle</groupId>
                <artifactId>kettle-engine</artifactId>
            </exclusion>
            <exclusion>
                <groupId>pentaho-kettle</groupId>
                <artifactId>kettle-core</artifactId>
            </exclusion>
        </exclusions>
Eve
  • 59
  • 1
  • 10