Alexey Vysotsky
Alexey Vysotsky

Reputation: 51

Add all dependencies, but NoClassDefFoundError com/intellij/uiDesigner/core/GridLayoutManager

I using Swing GUI Form in my program. In IntelliJ IDEA all work fine, but after packaging via Maven I get the error:

C:\Work\Idea\XLSConfigurdator\target>java -jar xlsconfigurdator-parent-1.0.jar. Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/uiDesign er/core/GridLayoutManager at XLSCreator.$$$setupUI$$$(XLSCreator.java) at XLSCreator.(XLSCreator.java:24) at XLSCreator.main(XLSCreator.java:73) Caused by: java.lang.ClassNotFoundException: com.intellij.uiDesigner.core.GridLa youtManager at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more

C:\Work\Idea\XLSConfigurdator\target>java -jar xlsconfigurdator-parent-1.0.jar Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/uiDesign er/core/GridLayoutManager at XLSCreator.$$$setupUI$$$(XLSCreator.java) at XLSCreator.(XLSCreator.java:24) at XLSCreator.main(XLSCreator.java:73) Caused by: java.lang.ClassNotFoundException: com.intellij.uiDesigner.core.GridLa youtManager at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more

"main" method only run constructor of class, constructor configured GUI Form via $$$setupUI$$$() method (File - Settings - Generate GUI into: Java source code).

public static void main(String[] args) {
    new XLSCreator();

    sourceClass sc = new sourceClass();
    array = sc.readFromExcel(fileName);
}

public XLSCreator() {
    $$$setupUI$$$();
    setContentPane(rootPanel);
    setVisible(true);
    setSize(500, 200);
    setTitle("I'll save your mistakes");

    aceptButton.addActionListener(this);
**etc**
...
}

I read all topics about this error, I added all dependencies into pom.xml (poi, poi-ooxml, swingx, forms_rt, ideauidesigner-maven-plugin, junit, forms, javac2), all needed plugins (maven-jar-plugin, ideauidesigner-maven-plugin) but still have problem with GridLayoutManager after packagin.

Upvotes: 1

Views: 2296

Answers (2)

Adir Dayan
Adir Dayan

Reputation: 1627

With Gradle

For me the issue solved after I packed the jar including all dependencies by customizing the "jar" task (pay attention also to the guidance in the comments)

see guidance in this answer

Upvotes: 0

Alexey Vysotsky
Alexey Vysotsky

Reputation: 51

Thanks for all, you are best.

But I forgot paste into pom.xml maven-compiler-plugin and configure it

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.0.2</version>
            <configuration>
                <archive>      
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>XLSCreator</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>

Upvotes: 0

Related Questions