Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to package 3rd party JARs into an EJB jar?

I have an old J2EE application (J2EE 1.3), which packages into an EAR, and in the EAR, there are WARs and EJB JARs. Now one of the EJB JARs needs to refer to some 3rd party library JARs, so what's the best place to package those JARs and how?

like image 370
Tong Wang Avatar asked Sep 01 '09 20:09

Tong Wang


People also ask

How do I add a jar file to EJB project?

In the Project Explorer view of the Java™ EE perspective, select File > Import. Under Select an import source, click EJB > EJB JAR file and click Next. In the EJB JAR file field, enter the location and name of the EJB JAR file that you want to import.

What is EJB packaging?

Advertisements. Requirement of Packaging applications using EJB 3.0 are similar to that of J2EE platform. EJB components are packaged into modules as jar files and are packaged into application enterprise archive as ear file. There are majorly three components of any enterprise application −

What is EJB JAR file?

An EJB JAR file is portable and can be used for various applications. To assemble a Java EE application, package one or more modules, such as EJB JAR files, into an EAR file, the archive file that holds the application.


1 Answers

They go in the ear file, at the root or you can create a lib directory to store them. Any project (EJB or WAR) that needs to reference them must include them in the Class-Path: of the manifest file.

Ear contents

  - log4j.jar
  - lib
     - commons-lang.jar
  - MyEJBProj.jar
  - MyWAR.war

MyEJBProj contents

 - classes
 - META-INF
    - MANIFEST.MF

MANIFEST.MF

    Manifest-Version: 1.0
    Class-Path: log4j.jar lib/commons-lang.jar
like image 91
Robin Avatar answered Sep 21 '22 12:09

Robin