ClassNotFound Exceptions in Maven-based Java Web Application

I’m working on a legacy Maven-based project. It uses an old version of Datanucleus and (the legacy) Google App Engine SDK. It’s a web application and I can’t (and don’t) see what is wrong with my configuration.

The project is plagued with several “Class was not found in the CLASSPATH” errors such as:

  • Class "org.datanucleus.enhancer.asm.ASMClassEnhancer" was not found in the CLASSPATH.
  • org.datanucleus.exceptions.ClassNotResolvedException: Class "com.element84.goodeatin.RestaurantMakerServlet" was not found in the CLASSPATH. Please check your specification and your CLASSPATH. (and many more other servlet not found in class path errors)

Downloading from central:
https://repo1.maven.org/maven2/org/datanucleus/datanucleus-rdbms/maven-metadata.xml
Exception in thread “Thread-2” Class
“org.datanucleus.enhancer.asm.ASMClassEnhancer” was not found in the
CLASSPATH. Please check your specification and your CLASSPATH.
org.datanucleus.exceptions.ClassNotResolvedException: Class
“org.datanucleus.enhancer.asm.ASMClassEnhancer” was not found in the
CLASSPATH. Please check your specification and your CLASSPATH. at
org.datanucleus.JDOClassLoaderResolver.classForName(JDOClassLoaderResolver.java:250)
at
org.datanucleus.enhancer.DataNucleusEnhancer.init(DataNucleusEnhancer.java:219)
at
org.datanucleus.enhancer.DataNucleusEnhancer.addClasses(DataNucleusEnhancer.java:370)
at
org.datanucleus.enhancer.EnhancerProcessor$EnhanceRunnable.run(EnhancerProcessor.java:163)
at java.lang.Thread.run(Thread.java:750) Downloaded from central:
https://repo1.maven.org/maven2/org/datanucleus/datanucleus-rdbms/maven-metadata.xml
(6.4 kB at 26 kB/s) Downloading from central:
https://repo1.maven.org/maven2/org/datanucleus/datanucleus-jpa/maven-metadata.xml
Downloading from DN_M2_Repo:
https://www.datanucleus.org/downloads/maven2/org/datanucleus/datanucleus-jpa/maven-metadata.xml
Downloaded from central:
https://repo1.maven.org/maven2/org/datanucleus/datanucleus-jpa/maven-metadata.xml
(1.2 kB at 6.5 kB/s) [INFO] DataNucleus Enhancer (version 1.1.4) :
Enhancement of classes DataNucleus Enhancer completed with success for
2 classes. Timings : input=396 ms, enhance=208 ms, total=604 ms.
Consult the log for full details

Here’s the complete project structure for reference:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>goodeatin-appengine
├── src
│ ├── main
│ ├── java
│ │ └── com
│ │ └── element84
│ │ └── goodeatin
│ │ ├── AsynchronousCommentMakerServlet.java
│ │ ├── Comment.java
│ │ ├── CommentMakerServlet.java
│ │ ├── DefaultTaskQueueServlet.java
│ │ ├── EMF.java
│ │ ├── GoodEatinServlet.java
│ │ ├── MailHandlerServlet.java
│ │ ├── Restaurant.java
│ │ ├── RestaurantInfoRefresherServlet.java
│ │ ├── RestaurantMakerServlet.java
│ │ └── XMPPServlet.java
│ │
│ ├── resources
│ │ └── META-INF
│ │ ├── jdoconfig.xml
│ │ └── persistence.xml
│ │
│ └── webapp
│ ├── images
│ ├── stylesheets
│ └── WEB-INF
│ ├── appengine-web.xml
│ ├── cron.xml
│ ├── logging.properties
│ ├── web.xml
│ ├── header.jsp
│ ├── index.html
│ ├── listView.jsp
│ ├── newComment.jsp
│ ├── newRestaurant.jsp
│ └── tickle.html
├── pom.xml
└── README
</code>
<code>goodeatin-appengine │ │ ├── src │ ├── main │ ├── java │ │ └── com │ │ └── element84 │ │ └── goodeatin │ │ ├── AsynchronousCommentMakerServlet.java │ │ ├── Comment.java │ │ ├── CommentMakerServlet.java │ │ ├── DefaultTaskQueueServlet.java │ │ ├── EMF.java │ │ ├── GoodEatinServlet.java │ │ ├── MailHandlerServlet.java │ │ ├── Restaurant.java │ │ ├── RestaurantInfoRefresherServlet.java │ │ ├── RestaurantMakerServlet.java │ │ └── XMPPServlet.java │ │ │ ├── resources │ │ └── META-INF │ │ ├── jdoconfig.xml │ │ └── persistence.xml │ │ │ └── webapp │ ├── images │ ├── stylesheets │ └── WEB-INF │ ├── appengine-web.xml │ ├── cron.xml │ ├── logging.properties │ ├── web.xml │ ├── header.jsp │ ├── index.html │ ├── listView.jsp │ ├── newComment.jsp │ ├── newRestaurant.jsp │ └── tickle.html │ ├── pom.xml └── README </code>
goodeatin-appengine
│
│
├── src
│   ├── main
│       ├── java
│       │   └── com
│       │       └── element84
│       │           └── goodeatin
│       │               ├── AsynchronousCommentMakerServlet.java
│       │               ├── Comment.java
│       │               ├── CommentMakerServlet.java
│       │               ├── DefaultTaskQueueServlet.java
│       │               ├── EMF.java
│       │               ├── GoodEatinServlet.java
│       │               ├── MailHandlerServlet.java
│       │               ├── Restaurant.java
│       │               ├── RestaurantInfoRefresherServlet.java
│       │               ├── RestaurantMakerServlet.java
│       │               └── XMPPServlet.java
│       │
│       ├── resources
│       │   └── META-INF
│       │       ├── jdoconfig.xml
│       │       └── persistence.xml
│       │
│       └── webapp
│           ├── images
│           ├── stylesheets
│           └── WEB-INF
│               ├── appengine-web.xml
│               ├── cron.xml
│               ├── logging.properties
│               ├── web.xml
│               ├── header.jsp
│               ├── index.html
│               ├── listView.jsp
│               ├── newComment.jsp
│               ├── newRestaurant.jsp
│               └── tickle.html
│
├── pom.xml
└── README

The POM is quite long but the build is configured this way:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> <build>
<resources>
<resource>
<directory>src/main/resources</directory>
<!-- Include all files and directories under 'src/main/resources' -->
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
<plugins>
<!-- ... -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven.war.plugin.version}</version>
<configuration>
<!-- Ensure classes are packaged within the WAR file -->
<archiveClasses>true</archiveClasses>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/appengine-web.xml</include>
</includes>
</resource>
<!-- Define additional resources for inclusion in the WAR. -->
<resource>
<!-- Source directory for the web configuration files. -->
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<!-- Enables Maven to replace placeholders with POM values. -->
<filtering>true</filtering>
<!-- Destination within the WAR file for these resources. -->
<targetPath>WEB-INF</targetPath>
</resource>
<!-- Include the META-INF directory containing the persistence.xml file -->
<resource>
<directory>${project.build.outputDirectory}/META-INF</directory>
<targetPath>WEB-INF/classes/META-INF</targetPath>
<includes>
<include>persistence.xml</include>
<include>jdoconfig.xml</include>
</includes>
</resource>
<!-- Ensure that the compiled classes are included -->
<resource>
<directory>${project.build.outputDirectory}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${maven.gae.version}</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<jvmFlags>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmFlag>
</jvmFlags>
</configuration>
</plugin>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>${datanucleus.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.version}</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-enhancer</artifactId>
<version>${datanucleus.enhancer.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>enhance</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<api>JPA</api>
<enhancerName>ASM</enhancerName>
<persistenceUnit>transactions-optional</persistenceUnit>
<mappingIncludes>**/*.class</mappingIncludes>
</configuration>
</plugin>
<!-- ... --->
</plugins>
</build>
</code>
<code> <build> <resources> <resource> <directory>src/main/resources</directory> <!-- Include all files and directories under 'src/main/resources' --> <includes> <include>**/*</include> </includes> </resource> </resources> <plugins> <!-- ... --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>${maven.war.plugin.version}</version> <configuration> <!-- Ensure classes are packaged within the WAR file --> <archiveClasses>true</archiveClasses> <webResources> <resource> <directory>${basedir}/src/main/webapp</directory> <filtering>true</filtering> <includes> <include>**/appengine-web.xml</include> </includes> </resource> <!-- Define additional resources for inclusion in the WAR. --> <resource> <!-- Source directory for the web configuration files. --> <directory>${basedir}/src/main/webapp/WEB-INF</directory> <!-- Enables Maven to replace placeholders with POM values. --> <filtering>true</filtering> <!-- Destination within the WAR file for these resources. --> <targetPath>WEB-INF</targetPath> </resource> <!-- Include the META-INF directory containing the persistence.xml file --> <resource> <directory>${project.build.outputDirectory}/META-INF</directory> <targetPath>WEB-INF/classes/META-INF</targetPath> <includes> <include>persistence.xml</include> <include>jdoconfig.xml</include> </includes> </resource> <!-- Ensure that the compiled classes are included --> <resource> <directory>${project.build.outputDirectory}</directory> <targetPath>WEB-INF/classes</targetPath> </resource> </webResources> </configuration> </plugin> <plugin> <groupId>com.google.appengine</groupId> <artifactId>appengine-maven-plugin</artifactId> <version>${maven.gae.version}</version> <configuration> <enableJarClasses>false</enableJarClasses> <jvmFlags> <jvmFlag>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmFlag> </jvmFlags> </configuration> </plugin> <plugin> <groupId>org.datanucleus</groupId> <artifactId>maven-datanucleus-plugin</artifactId> <version>${datanucleus.plugin.version}</version> <dependencies> <dependency> <groupId>org.datanucleus</groupId> <artifactId>datanucleus-core</artifactId> <version>${datanucleus.version}</version> </dependency> <dependency> <groupId>org.datanucleus</groupId> <artifactId>datanucleus-enhancer</artifactId> <version>${datanucleus.enhancer.version}</version> </dependency> </dependencies> <executions> <execution> <goals> <goal>enhance</goal> </goals> <phase>process-classes</phase> </execution> </executions> <configuration> <api>JPA</api> <enhancerName>ASM</enhancerName> <persistenceUnit>transactions-optional</persistenceUnit> <mappingIncludes>**/*.class</mappingIncludes> </configuration> </plugin> <!-- ... ---> </plugins> </build> </code>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <!-- Include all files and directories under 'src/main/resources' -->
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>

        <plugins>
            <!-- ... --> 
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>${maven.war.plugin.version}</version>
                <configuration>
                    <!-- Ensure classes are packaged within the WAR file -->
                    <archiveClasses>true</archiveClasses>
                    <webResources>
                        <resource>
                            <directory>${basedir}/src/main/webapp</directory>
                            <filtering>true</filtering>
                            <includes>
                                <include>**/appengine-web.xml</include>
                            </includes>
                        </resource>
                        <!-- Define additional resources for inclusion in the WAR. -->
                        <resource>
                            <!-- Source directory for the web configuration files. -->
                            <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <!-- Enables Maven to replace placeholders with POM values. -->
                            <filtering>true</filtering>
                            <!-- Destination within the WAR file for these resources. -->
                            <targetPath>WEB-INF</targetPath>
                        </resource>
                        <!-- Include the META-INF directory containing the persistence.xml file -->
                        <resource>
                            <directory>${project.build.outputDirectory}/META-INF</directory>
                            <targetPath>WEB-INF/classes/META-INF</targetPath>
                            <includes>
                                <include>persistence.xml</include>
                                <include>jdoconfig.xml</include>
                            </includes>
                        </resource>
                        <!-- Ensure that the compiled classes are included -->
                        <resource>
                            <directory>${project.build.outputDirectory}</directory>
                            <targetPath>WEB-INF/classes</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${maven.gae.version}</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                    <jvmFlags>
                        <jvmFlag>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmFlag>
                    </jvmFlags>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>maven-datanucleus-plugin</artifactId>
                <version>${datanucleus.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.datanucleus</groupId>
                        <artifactId>datanucleus-core</artifactId>
                        <version>${datanucleus.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.datanucleus</groupId>
                        <artifactId>datanucleus-enhancer</artifactId>
                        <version>${datanucleus.enhancer.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <api>JPA</api>
                    <enhancerName>ASM</enhancerName>
                    <persistenceUnit>transactions-optional</persistenceUnit>
                    <mappingIncludes>**/*.class</mappingIncludes>
                </configuration>
            </plugin>
            <!-- ... --->
        </plugins>
    </build>

Running the project with mvn appengine:devserver what is wrong with how the project is structured and packaged that could cause these errors?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật