I am having problems using enum in my J2EE application. I use enumeration in case of switching inside my service without bean state.
At runtime, I see the following exception in the switch statement:
Caused by: java.lang.NoClassDefFoundError: com/comp/service/TestServiceImpl$1
This issue has been widely discussed in one of the threads at https://stackoverflow.com/a/3/2/2/ . But I do not see a solution to solve this problem.
In my case, I am using the JBOSS EAP6.1 server. The JDK version is 1.7. Code built using Maven in the Eclipse IDE. And the application is being deployed as an EAR archive. How to add this additional file of the generated class to the classpath in my EAR archive? Is there any other way to solve this problem?
Update June 29, 2014: I tried to create the application from the command line. Then this extra class file is created. And I can successfully and successfully use the application. Then it seems to be a bug with eclipse. Any idea how to solve it?
pom.xml from the EAR project:
<?xml version="1.0" encoding="UTF-8"?> <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> <parent> <artifactId>demo-maven</artifactId> <groupId>com.comp.demo</groupId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>demo-ear</artifactId> <packaging>ear</packaging> <name>demo - ear</name> <url>www.comp.com</url> <licenses> <license> <name>Apache License, Version 2.0</name> <distribution>repo</distribution> <url>http://www.apache.org/licenses/LICENSE-2.0.html</url> </license> </licenses> <dependencies> <dependency> <groupId>com.comp.demo</groupId> <artifactId>demo-web</artifactId> <type>war</type> </dependency> <dependency> <groupId>com.comp.demo</groupId> <artifactId>demo-service</artifactId> <type>ejb</type> </dependency> </dependencies> <build> <finalName>${project.parent.artifactId}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <version>${version.ear.plugin}</version> <configuration> <version>6</version> <defaultLibBundleDir>lib</defaultLibBundleDir> <modules></modules> <fileNameMapping>no-version</fileNameMapping> </configuration> </plugin> <plugin> <groupId>org.jboss.as.plugins</groupId> <artifactId>jboss-as-maven-plugin</artifactId> <configuration> <skip>false</skip> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>openshift</id> <build> <plugins> <plugin> <artifactId>maven-ear-plugin</artifactId> <version>${version.ear.plugin}</version> <configuration> <outputDirectory>deployments</outputDirectory> </configuration> </plugin> </plugins> </build> </profile> </profiles> </project>
pom.xml from ejb project:
<?xml version="1.0" encoding="UTF-8"?> <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> <parent> <artifactId>demo-maven</artifactId> <groupId>com.comp.demo</groupId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>demo-service</artifactId> <packaging>ejb</packaging> <name>demo - service</name> <url>www.comp.com</url> <licenses> <license> <name>Apache License, Version 2.0</name> <distribution>repo</distribution> <url>http://www.apache.org/licenses/LICENSE-2.0.html</url> </license> </licenses> <dependencies> <dependency> <groupId>org.jboss.spec.javax.ejb</groupId> <artifactId>jboss-ejb-api_3.1_spec</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.enterprise</groupId> <artifactId>cdi-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.ejb3</groupId> <artifactId>jboss-ejb3-ext-api</artifactId> <version>2.0.0-redhat-2</version> <type>jar</type> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.9.5</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>4.3.5.Final</version> <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.arquillian.junit</groupId> <artifactId>arquillian-junit-container</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.arquillian.protocol</groupId> <artifactId>arquillian-protocol-servlet</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <type>jar</type> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <artifactId>maven-ejb-plugin</artifactId> <version>${version.ejb.plugin}</version> <configuration> <ejbVersion>3.1</ejbVersion> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>default</id> <activation> <activeByDefault>true</activeByDefault> </activation> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>${version.surefire.plugin}</version> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </build> </profile> <profile> <id>arq-jbossas-managed</id> <dependencies> <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-arquillian-container-managed</artifactId> <scope>test</scope> </dependency> </dependencies> </profile> <profile> <id>arq-jbossas-remote</id> <dependencies> <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-arquillian-container-remote</artifactId> <scope>test</scope> </dependency> </dependencies> </profile> </profiles> </project>
java enums noclassdeffounderror maven jboss
user613114
source share