java-extensions icon indicating copy to clipboard operation
java-extensions copied to clipboard

Exception in thread "main" java.lang.NoClassDefFoundError: javassist/ClassPath

Open kjellmoens opened this issue 4 years ago • 1 comments

Hi,

When trying to plugin the structurizr module into an existing project, I get the following error but can not resolve it. Exception in thread "main" java.lang.NoClassDefFoundError: javassist/ClassPath at com.structurizr.analysis.ComponentFinder.getTypeRepository(ComponentFinder.java:181) at com.structurizr.analysis.AbstractComponentFinderStrategy.getTypeRepository(AbstractComponentFinderStrategy.java:47) at com.structurizr.analysis.AbstractComponentFinderStrategy.lambda$beforeFindComponents$0(AbstractComponentFinderStrategy.java:52) at java.util.ArrayList.forEach(ArrayList.java:1259) at com.structurizr.analysis.AbstractComponentFinderStrategy.beforeFindComponents(AbstractComponentFinderStrategy.java:52) at com.structurizr.analysis.ComponentFinder.findComponents(ComponentFinder.java:73) at be.fgov.minfin.first.accounting.core.documenation.IIPR.findComponents(IIPR.java:283) at be.fgov.minfin.first.accounting.core.documenation.First.createFirstIntakeComponents(First.java:133) at be.fgov.minfin.first.accounting.core.documenation.First.<init>(First.java:16) at be.fgov.minfin.first.accounting.core.documenation.First.main(First.java:22) Caused by: java.lang.ClassNotFoundException: javassist.ClassPath at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 10 more

In a spring project, it works perfectly but now I am using

void findComponents(Container jvm) throws Exception {
    ComponentFinder componentFinder = new ComponentFinder(
            jvm,
            "be.fgov.minfin.first.accounting.core.services.interest.calculation",
            new StructurizrAnnotationsComponentFinderStrategy(),
            new SourceCodeComponentFinderStrategy(new File("."), 150));

    componentFinder.findComponents();

My pom.xml is the same as with other projects and contains the following dependencies.

<dependency>
    <groupId>com.structurizr</groupId>
    <artifactId>structurizr-core</artifactId>
    <version>${structurizr.version}</version>
</dependency>
<dependency>
    <groupId>com.structurizr</groupId>
    <artifactId>structurizr-client</artifactId>
    <version>${structurizr.version}</version>
</dependency>
<dependency>
    <groupId>com.structurizr</groupId>
    <artifactId>structurizr-analysis</artifactId>
    <version>1.3.5</version>
    <scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.structurizr/structurizr-annotations -->
<dependency>
    <groupId>com.structurizr</groupId>
    <artifactId>structurizr-annotations</artifactId>
    <version>1.3.5</version>
</dependency>

<dependency>
    <groupId>com.structurizr</groupId>
    <artifactId>structurizr-plantuml</artifactId>
    <version>1.6.2</version>
</dependency>

kjellmoens avatar Apr 22 '21 13:04 kjellmoens

What can help is that i get the error in a java 8 project ... In a java 11 project it seems to work perfectly.

kjellmoens avatar Apr 23 '21 09:04 kjellmoens