Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassNotFoundException occurred although that class is successfully compiled into a JAX-RS app #1056

Open
divq opened this issue Mar 27, 2024 · 0 comments

Comments

@divq
Copy link

divq commented Mar 27, 2024

My project structure: (Project is attached as a zip: JaxRsTest.zip)

JaxRsTest
|-lib
|-src/main/java/com/example/jaxrstest/MyModel.java
|-pom.xml

In lib folder there is a jar file that contains a POJO: com.example.SomeModel.

src/main/java/com/example/jaxrstest/MyModel extends this SomeModel

In pom.xml I use the following configuration to include the jars in lib into the final package.

         <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
                <configuration>
                    <compilerArguments>
                        <extdirs>lib</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>

This compiles ( by executing mvn package) successfully into a war file, meaning the MyModel extends SomeModel mentioned above had no problem locating SomeModel. However the when I configure the generator to generate ts for SomeModel or MyModel(by running mvn process-classes -X), it cannot find the class:

Caused by: java.lang.ClassNotFoundException: org.example.SomeModel

Full error log is as follows:

realm =    plugin>cz.habarta.typescript-generator:typescript-generator-maven-plugin:3.2.1263
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/Users/imac/.m2/repository/cz/habarta/typescript-generator/typescript-generator-maven-plugin/3.2.1263/typescript-generator-maven-plugin-3.2.1263.jar
urls[1] = file:/Users/imac/.m2/repository/cz/habarta/typescript-generator/typescript-generator-core/3.2.1263/typescript-generator-core-3.2.1263.jar
urls[2] = file:/Users/imac/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.14.2/jackson-databind-2.14.2.jar
urls[3] = file:/Users/imac/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.14.2/jackson-annotations-2.14.2.jar
urls[4] = file:/Users/imac/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.14.2/jackson-core-2.14.2.jar
urls[5] = file:/Users/imac/.m2/repository/com/fasterxml/jackson/module/jackson-module-jakarta-xmlbind-annotations/2.14.2/jackson-module-jakarta-xmlbind-annotations-2.14.2.jar
urls[6] = file:/Users/imac/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/4.0.0/jakarta.xml.bind-api-4.0.0.jar
urls[7] = file:/Users/imac/.m2/repository/jakarta/activation/jakarta.activation-api/2.1.1/jakarta.activation-api-2.1.1.jar
urls[8] = file:/Users/imac/.m2/repository/com/fasterxml/jackson/module/jackson-module-jaxb-annotations/2.14.2/jackson-module-jaxb-annotations-2.14.2.jar
urls[9] = file:/Users/imac/.m2/repository/org/glassfish/jaxb/jaxb-runtime/4.0.1/jaxb-runtime-4.0.1.jar
urls[10] = file:/Users/imac/.m2/repository/org/glassfish/jaxb/jaxb-core/4.0.1/jaxb-core-4.0.1.jar
urls[11] = file:/Users/imac/.m2/repository/org/eclipse/angus/angus-activation/1.0.0/angus-activation-1.0.0.jar
urls[12] = file:/Users/imac/.m2/repository/org/glassfish/jaxb/txw2/4.0.1/txw2-4.0.1.jar
urls[13] = file:/Users/imac/.m2/repository/com/sun/istack/istack-commons-runtime/4.1.1/istack-commons-runtime-4.1.1.jar
urls[14] = file:/Users/imac/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar
urls[15] = file:/Users/imac/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar
urls[16] = file:/Users/imac/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.1.1/javax.ws.rs-api-2.1.1.jar
urls[17] = file:/Users/imac/.m2/repository/jakarta/ws/rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs-api-3.1.0.jar
urls[18] = file:/Users/imac/.m2/repository/io/github/classgraph/classgraph/4.8.157/classgraph-4.8.157.jar
urls[19] = file:/Users/imac/.m2/repository/com/google/code/gson/gson/2.9.1/gson-2.9.1.jar
urls[20] = file:/Users/imac/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.8.10/kotlin-stdlib-1.8.10.jar
urls[21] = file:/Users/imac/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.8.10/kotlin-stdlib-common-1.8.10.jar
urls[22] = file:/Users/imac/.m2/repository/org/jetbrains/annotations/24.0.1/annotations-24.0.1.jar
urls[23] = file:/Users/imac/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.8.10/kotlin-reflect-1.8.10.jar
urls[24] = file:/Users/imac/.m2/repository/javax/json/javax.json-api/1.1.4/javax.json-api-1.1.4.jar
urls[25] = file:/Users/imac/.m2/repository/jakarta/json/jakarta.json-api/2.0.1/jakarta.json-api-2.0.1.jar
urls[26] = file:/Users/imac/.m2/repository/javax/json/bind/javax.json.bind-api/1.0/javax.json.bind-api-1.0.jar
urls[27] = file:/Users/imac/.m2/repository/jakarta/json/bind/jakarta.json.bind-api/3.0.0/jakarta.json.bind-api-3.0.0.jar
urls[28] = file:/Users/imac/.m2/repository/org/graalvm/js/js/22.3.1/js-22.3.1.jar
urls[29] = file:/Users/imac/.m2/repository/org/graalvm/regex/regex/22.3.1/regex-22.3.1.jar
urls[30] = file:/Users/imac/.m2/repository/org/graalvm/truffle/truffle-api/22.3.1/truffle-api-22.3.1.jar
urls[31] = file:/Users/imac/.m2/repository/org/graalvm/sdk/graal-sdk/22.3.1/graal-sdk-22.3.1.jar
urls[32] = file:/Users/imac/.m2/repository/com/ibm/icu/icu4j/71.1/icu4j-71.1.jar
urls[33] = file:/Users/imac/.m2/repository/org/graalvm/js/js-scriptengine/22.3.1/js-scriptengine-22.3.1.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:150)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: java.lang.NoClassDefFoundError: org/example/SomeModel
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:1027)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:150)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:524)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:427)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:421)
    at java.security.AccessController.doPrivileged (AccessController.java:714)
    at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:593)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at cz.habarta.typescript.generator.Input.loadClasses (Input.java:189)
    at cz.habarta.typescript.generator.Input.fromClassNames (Input.java:175)
    at cz.habarta.typescript.generator.Input.from (Input.java:65)
    at cz.habarta.typescript.generator.maven.GenerateMojo.execute (GenerateMojo.java:991)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: java.lang.ClassNotFoundException: org.example.SomeModel
    at java.net.URLClassLoader.findClass (URLClassLoader.java:445)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:593)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:1027)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:150)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:524)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:427)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:421)
    at java.security.AccessController.doPrivileged (AccessController.java:714)
    at java.net.URLClassLoader.findClass (URLClassLoader.java:420)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:593)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at cz.habarta.typescript.generator.Input.loadClasses (Input.java:189)
    at cz.habarta.typescript.generator.Input.fromClassNames (Input.java:175)
    at cz.habarta.typescript.generator.Input.from (Input.java:65)
    at cz.habarta.typescript.generator.maven.GenerateMojo.execute (GenerateMojo.java:991)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
[DEBUG] Shutting down adapter factory; available factories [file-lock, rwlock-local, semaphore-local, noop]; available name mappers [discriminating, file-gav, file-hgav, file-static, gav, static]
[DEBUG] Shutting down 'file-lock' factory
[DEBUG] Shutting down 'rwlock-local' factory
[DEBUG] Shutting down 'semaphore-local' factory
[DEBUG] Shutting down 'noop' factory

Process finished with exit code 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant