简体   繁体   English

java.lang.NoClassDefFoundError:无法初始化类x

[英]java.lang.NoClassDefFoundError: Could not initialize class x

I'm new to tomcat and maven both, I created a project using IntelliJ IDEA. 我是tomcat和maven的新手,我使用IntelliJ IDEA创建了一个项目。 there are some java classes in src directory, and the .class files is stored in target directory after building the project. src目录中有一些Java类,构建项目后,.class文件存储在目标目录中。 It seems that tomcat cannot find where are the .class files to initialize classes. 似乎tomcat无法找到.class文件在哪里初始化类。 here is the directory tree: 这是目录树:

在此处输入图片说明

here is my pom.xml contetnt: 这是我的pom.xml内容:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>IE</groupId>
  <artifactId>IE</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>IE Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>javax.servlet.jsp-api</artifactId>
      <version>2.3.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>4.0.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.json</groupId>
      <artifactId>org.json</artifactId>
      <version>chargebee-1.0</version>
    </dependency>
  </dependencies>
  <build>
    <sourceDirectory>src/main/javaClasses</sourceDirectory>
    <finalName>IE</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <url>http://localhost:8080/manager/text</url>
          <server>TomcatServer</server>
          <path>/projectName</path>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

can anybody help how can I tell the path of target file to find classes please? 有人可以帮助我告诉目标文件的路径来查找类吗? Now I can't instantiate any of my classes in my jsp files. 现在,我无法在jsp文件中实例化任何类。

You haven't customized the configuration of the compiler plugin, therefore, it's incorrect to put your source files under src/main/javaClasses . 您尚未自定义编译器插件的配置,因此,将源文件放在src/main/javaClasses下是不正确的。

You should move your source packages/classes to src/main/java , and Maven should pick it up. 您应该将源包/类移至src/main/java ,而Maven应该将其选中。 This is where Maven expects them by default. 这是Maven默认期望它们的地方。

For more info, check standard directory layout page . 有关更多信息,请检查标准目录布局页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError:无法初始化类 - java.lang.NoClassDefFoundError: Could not initialize class java.lang.NoClassDefFoundError:无法初始化类 - java.lang.NoClassDefFoundError: Could not initialize class ECLIPSE:java.lang.NoClassDefFoundError:无法初始化类**** - ECLIPSE: java.lang.NoClassDefFoundError: Could not initialize class **** Tomcat java.lang.NoClassDefFoundError:无法初始化类 - Tomcat java.lang.NoClassDefFoundError: Could not initialize class java.lang.NoClassDefFoundError:无法初始化类DataLayer.HibernateAdapter - java.lang.NoClassDefFoundError: Could not initialize class DataLayer.HibernateAdapter java.lang.NoClassDefFoundError:无法初始化类business.HibernateUtil - java.lang.NoClassDefFoundError: Could not initialize class business.HibernateUtil Spring:java.lang.NoClassDefFoundError:无法初始化类 - Spring: java.lang.NoClassDefFoundError: Could not initialize class java.lang.NoClassDefFoundError:无法初始化类 XXX - java.lang.NoClassDefFoundError: Could not initialize class XXX java.lang.NoClassDefFoundError: 无法初始化类 | 静态块 - java.lang.NoClassDefFoundError: Could not initialize class | static block java.lang.NoClassDefFoundError: 无法初始化 class - Kotlin Object - java.lang.NoClassDefFoundError: Could not initialize class - Kotlin Object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM