Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3233078
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:14:08+00:00 2026-05-17T17:14:08+00:00

I have tried for hours to get my project working but the EJB part

  • 0

I have tried for hours to get my project working but the EJB part is still failing with a java.lang.ClassNotFoundException: org.slf4j.LoggerFactory (I want to output some log in my EJB).

The layout of the project is the following:

|-- nnWeb-ear
|   |-- pom.xml
|   `-- src
|       `-- main
|           |-- application
|           |   `-- META-INF
|           |       `-- MANIFEST.MF
|           `-- java
|-- nnWeb-ejb
|   |-- pom.xml
|   `-- src
|       |-- main
|       |   |-- java
|       |   |   `-- com
|       |   |       `-- test
|       |   |           `-- packaging
|       |   |               `-- SimpleStateLess.java
|       |   `-- resources
|       |       |-- logback.xml
|       |       `-- META-INF
|       |           `-- MANIFEST.MF
|       `-- test
|           `-- java
|               `-- com
|                   `-- test
|                       `-- packaging
|-- nnWeb-web
|   |-- pom.xml
|   `-- src
|       |-- main
|       |   |-- java
|       |   |   `-- com
|       |   |       `-- test
|       |   |           `-- packaging
|       |   |               |-- SimpleEJB.java
|       |   |               `-- SimpleServlet.java
|       |   |-- resources
|       |   |   `-- logback.xml
|       |   `-- webapp
|       |       |-- index.jsp
|       |       `-- WEB-INF
|       |           `-- sun-web.xml
|       `-- test
|           `-- java
`-- pom.xml

the main pom.xml :

<?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>
  <groupId>com.test.packaging</groupId>
  <artifactId>nnWeb</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>nnWeb</name>
  <url>http://maven.apache.org</url>
  <modules>
    <module>nnWeb-ear</module>
    <module>nnWeb-web</module>
    <module>nnWeb-ejb</module>
  </modules>
</project>

The ejb pom.xml:

<?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>nnWeb</artifactId>
        <groupId>com.test.packaging</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.test.packaging</groupId>
    <artifactId>nnWeb-ejb</artifactId>
    <packaging>ejb</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>nnWebEjb</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>0.9.18</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.11</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>java.net2</id>
            <name>Java.Net Maven2 Repository, hosts the javaee-api dependency</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <ejbVersion>3.1</ejbVersion>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>APP-INF/lib</classpathPrefix>
                        </manifest>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>

            </plugin>
        </plugins>
        <finalName>nnWeb-ejb</finalName>
    </build>
    <profiles>
        <profile>
            <id>endorsed</id>
            <activation>
                <property>
                    <name>sun.boot.class.path</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>2.0.2</version>
                        <configuration>
                            <!-- javaee6 contains upgrades of APIs contained within the JDK itself.
                                 As such these need to be placed on the bootclasspath, rather than classpath of the
                                 compiler.
                                 If you don't make use of these new updated API, you can delete the profile.
                                 On non-SUN jdk, you will need to create a similar profile for your jdk, with the similar property as sun.boot.class.path in Sun's JDK.-->
                            <compilerArguments>
                                <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path}</bootclasspath>
                            </compilerArguments>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <properties>
        <netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
    </properties>
</project>

The ear pom.xml:

<?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>nnWeb</artifactId>
        <groupId>com.test.packaging</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.test.packaging</groupId>
    <artifactId>nnWeb-ear</artifactId>
    <packaging>ear</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>nnWebEar</name>
    <url>http://maven.apache.org</url>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <version>6</version>
                   <!-- <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                        </archive>-->
                        <defaultJavaBundleDir>APP-INF/lib</defaultJavaBundleDir>
                </configuration>
            </plugin>

                    <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>process-classes</phase>
                        <goals>

                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <finalName>nnWeb-ear</finalName>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.test.packaging</groupId>
            <artifactId>nnWeb-ejb</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>ejb</type>
        </dependency>
        <dependency>
            <groupId>com.test.packaging</groupId>
            <artifactId>nnWeb-web</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>0.9.18</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.11</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.sli4j</groupId>
            <artifactId>sli4j-slf4j-jdk14</artifactId>
            <version>2.0</version>
        </dependency>
    </dependencies>
    <properties>
        <netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
    </properties>
</project>

and the SimpleStateless.java EJB:

package com.test.packaging;

import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Stateless
public class SimpleStateLess {
     private static Logger logger = LoggerFactory.getLogger(SimpleStateLess.class);

   public void constructLog(){
       logger.debug("Finally got logging working in ejb module :)");
   }
}

Once packaged, the ear file looks like:

|-- APP-INF
|   `-- lib
|       |-- aopalliance-1.0.jar
|       |-- guice-2.0.jar
|       |-- logback-classic-0.9.18.jar
|       |-- logback-core-0.9.18.jar
|       |-- slf4j-api-1.5.11.jar
|       |-- slf4j-jdk14-1.5.10.jar
|       |-- sli4j-core-2.0.jar
|       `-- sli4j-slf4j-jdk14-2.0.jar
|-- META-INF
|   |-- application.xml
|   |-- MANIFEST.MF
|   `-- maven
|       `-- com.test.packaging
|           `-- nnWeb-ear
|               |-- pom.properties
|               `-- pom.xml
|-- ngWeb-web.war
`-- nnWeb-ejb.jar

and the ejb.jar manifest is:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: dev
Build-Jdk: 1.6.0_21
Class-Path: APP-INF/lib/logback-classic-0.9.18.jar APP-INF/lib/logback
 -core-0.9.18.jar APP-INF/lib/slf4j-api-1.5.11.jar

Note that logging from the war package works (Servlet logging + EJB logging using the WEB-INF/lib directory) and according to what I found, logging in the EJB should work when deploying the ear (if the manifest is correct).

What am I doing wrong ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:14:09+00:00Added an answer on May 17, 2026 at 5:14 pm

    Looking at the exploded ear packaging and the ejb.jar manifest,

    nnWeb-ejb.jar is in the same hierarchy as APP-INF.

    Thus the following Class-Path entries become invalid…

    Class-Path: APP-INF/lib/logback-classic-0.9.18.jar APP-INF/lib/logback
     -core-0.9.18.jar APP-INF/lib/slf4j-api-1.5.11.jar
    

    They would need to be

    Class-Path: ../APP-INF/lib/logback-classic-0.9.18.jar ../APP-INF/lib/logback
     -core-0.9.18.jar ../APP-INF/lib/slf4j-api-1.5.11.jar
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried hours and hours of examples but I continually get the same
I have tried everything, searched the net for two hours or even more and
I have tried var dateHeaders = HttpContext.Current.Request.Headers[Date] but it contains null, apparently there is
I have tried running the code without the collision, and it works fine. But
I have tried to use stripersist with mysql but was not successful. I have
I have tried searching for an answer to this but my searches have come
I've been at this for hours but it just isn't working. I'm trying to
I have read numerous posts, spent hours going over the documents at cakephp.org and
I've been trying for hours to find a solution this problem but have not
I have an aggregation project with a half-dozen submodules. The builds all work but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.