Why should we declare dependencies on the JBOSS 8 (wildfly) manifest?

given the following EAR:

  • my-app.ear
    • my-ejb .jar
    • my-webapp.war
    • Lib
      • my pb .jar

my-ejb needs an oracle library to work with oracle space for geometry building and data storage. Oracle module loaded correctly JBOSS 8 (wildfly).

When I ran the application, I got ClassNotFoundException oracle.sql.STRUCT

.

OK I have added oracle driver dependency ojdbc6.jar to my-ejb META-INF/manifest.mf

.

Class-Path: ojdbc6.jar
Dependencies: oracle.sql 

      

When I ran the application, I got ClassNotFoundException oracle.sql.StructDescriptor

. I know that when I read data into and out of the result set, the object coming out of the result set is an instance of the class oracle.sql.STRUCT

but oracle.sql.StructDescriptor

is in the same package.

OK I added the same oracle driver dependency ojdbc6.jar to my-lib META-INF/manifest.mf

.

And it works!

My question

  • which is the role of the manifest on JBOSS 8?
  • Why in oracle weblogic I dont need to add these dependencies in manifest.mf?
+3


source to share


2 answers


To answer your question:

  • which is the role of the manifest on JBOSS 8?

Manifests are automatically generated whenever a jar archive is created. There is no specific role associated with JBOSS 8, but its general purpose. In the special case, if the jar says file1.jar depends on some classes belonging to another file2.jar jar, then these jars should be loaded when file1.jar is loaded. Now the trick is that whenever a jar file is loaded by a classloader, the manifest is a way to tell the classloader to load other jars that jar needs. ( Check this link ). This is the reason the code doesn't work when ojdbc6.jar is missing from the manifest .



  • Why in oracle weblogic I dont need to add these dependencies in manifest.mf?

Well that's because in oracle weblogic ojdbc6.jar comes bundled with weblogic server and is already loaded when server starts. Note that even if the application has ojdbc6.jar installed , it is not used. Here is the relevant documentation for that .

+7


source


Santosh gave the correct answer, but let me clarify some questions about weblogic vs jboss.

JBOSS and WebLogic have different class loader mechanisms. Let me clarify:

1.Why a manifesto?

Java-Oracle answer: You may want to reference classes in other JARs from the JAR file.

2.Why is it showing up in an EAR / WAR app?

Oracle Weblogic reply: WebLogic Server supports add-on packages as described in the Java EE 5.0 Specification, Section 8.2 Supplemental Package Support, with the versions described in the Supplemental Package Updates section. Additional packages provide similar functionality to Java EE libraries, making it easy to share a single JAR file between multiple applications. As with Java EE libraries, add-on packages must first be registered with the WebLogic Server by deploying the corresponding JAR file as an add-on package. After registering the package, you can deploy Java EE modules that reference the package in the manifest files.

Add-on packages differ from Java EE libraries in that add-on packages can be linked to them from any Java EE module (EAR, JAR, WAR, or RAR archive) or archive subdirectory. Java EE libraries can only be referenced by a valid Enterprise Application.

[...]

Any Java EE application or module can reference an optional package (using META-INF / MANIFEST.MF), whereas only enterprise applications and web applications can reference the shared Java EE library (using weblogic-application.xml or weblogic.xml )

3.then why should we not declare java-ee-api.jar, jsf, jsp, ...

Jboss reply: The following table lists the modules that are automatically added to deployments as dependencies and the conditions that cause the dependency.

Implicit_Module_Dependencies

4. not all modules are loaded by JBOSS?



Jboss's answer: This chapter goes over how applications packaged as jars can claim to depend on one or more modules:

Dependencies: oracle.sql, another.module.with.version:1.0

      

Manifest module information

4.1 alternatively define jboss-deployment-structure.xml

<jboss-deployment-structure>

   <deployment>

      <dependencies>
         <module name="oracle.sql" export="TRUE" />
      </dependencies>

   </deployment>

</jboss-deployment-structure>

      

Add implicit module dependency for deployment

4.2 with maven

<plugins>

   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <configuration>
         <archive>
            <manifestEntries>
               <Dependencies>org.javassist, org.apache.velocity</Dependencies>
            </manifestEntries>
         </archive>
      </configuration>
   </plugin> 

</plugins>

      

see: Create MANIFESTMF records with Maven

see: How do you create module dependencies in MANIFEST.MF for JBoss AS 7 using maven?

7. Why didn't we receive this important information earlier?

With the new organizational model, JBOSS 7/8 ditches the well-known class loading hierarchy to move to a simpler model based on the use of modular blocks ( JBoss Modules Project ). The implementation of architecture modules (in addition to the upcoming implementation in the JDK, is now largely in vogue thanks to external projects such as OSGi) actually extends the model used to package Java EE applications; then a module can be a library, a collection of classes, or generally a collection of resources associated with a single classloader: therefore, unlike in the past where a classloader that was assembled in a hierarchical organization of a collection of classes, the point here is exactly the opposite.

see Loading a Class in WildFly

+14


source







All Articles