JBoss 7.1 How to add a module - java

I use the annotation #WebContext in my project using JBoss 7.1.
This annotation is present in a JBOSS module:
<module xmlns="urn:jboss:module:1.1" name="org.jboss.ws.api">
The jar is located in JBOSS\modules\jboss\ws\api (jbossws-api-1.0.0.GA.jar)
I'm not using maven so how do I include this dependency? Can I use the jboss-deployment-structure or Dependencies in the MANIFEST?
My point is to have access to the jar in my Lib. Ideally the jar jbossws-api-1.0.0.GA.jar must be located in JBoss 7.1 Runtime Libs.
I have already try to have the dependency in the MANIFEST and jboss-deployment_structure bu of course with that JBoss 7.1 Runtime Libs isn't updated.
I think the file standalone.xml must be updated in order to add this module. Please explain to me how I do that?
Thanks.

You only need to add a dependency if its not automatically included.
If the org.jboss.ws.api not automatic( you will find out when you deploy to the server ), and I don't see why it wouldn't be, adding it via the jboss-deployment-structure.xml is the way to go.
That file should be included in your WEB-INF directory, along with your web.xml and jboss-web.xml files.
See AS7 Classloading Documentation on the jboss-deployment-structure.xml if need be.

In eclipse preference if you go under Server-->RuntimeEnv-->DefaultClaspathEntry. You can add additional modules. I had to add org.jobss.ws.api.

Related

NoClassDefFound - org/apache/kafka/clients/producer/KafkaProducer

I have an ear file, inside ear file I have the war file. Its based on Spring 2.5.6 and jdk 1.6
now I want to publish few messages to kafka, included kafka-clients-1.0.0 in war/web-inf/lib
but its getting NoClassDefFoundError org/apache/kafka/clients/producer/KafkaProducer.
NoClassDefFoundError usually happens when your project has conflict dependencies, for example 3rd and 4th versions of Spring framework. Check your dependencies and their transitive ones.
It simply means the class which you are trying to run was not found in on your classpath.
Solution: you need to add the class or .jar file which contains this class into the java classpath.

JBoss ClassLoading Parent-Last loading

I wanted to understand parent-last loading in an application JBoss application server. We have a legacy application deployed in JBoss 4.2.1 GA. For which we are trying the parent-last loading.
I am referring to the this link.
I wanted to learn a parent last loading. So had created simple maven jar package application with maven-jar-plugin and configuration -> addDefaultImplementationEntries = true. I have created 2 jar versions 1.0.0 and 1.0.1 from the same jar creation maven application. The jar has single class TestClass and a simple String return method that returns the version of the jar the class is loaded from.
what I wanted to experience the use of java2ClassLoadingCompliance. I have packaged the version 1.0.0 jar in the server/deploy/MyApplication/WEB-INF/lib (My web application is a simple servlet application that calls the method of the class thus printing the version number from which jar it was called from.) and version 1.0.1 jar in server/lib.
Note : Logically it does not make sense to use an older version of jar in application and overriding it with the newer version present in server lib, but just wanted to experience the class loading.
I have tried the following
Without any jboss-web.xml in the meta-inf folder.
I tried introduction jboss-we.xml in META-INF and doing the same with java2ClassLoadingCompliance = false.
With java2ClassLoadingCompliance = true.
All the time class from the application lib would get loaded by the application.
My jboss-web.xml looks like reference
<jboss-web>
<class-loading java2ClassLoadingCompliance="true">
<loader-repository>
com.example:archive=JBossClassLoadingTestServlet-0.0.1-SNAPSHOT.ear
<loader-repository-config>java2ParentDelegation=true</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>
Can someone help me understanding parent-last configuration in JBoss? What is the mistake I am doing here that always class from application lib gets loaded?
I am afraid that your link is not so related to your experiment. It is more related about the EAR deployments, in which there exists multi-module deployments and need multiple versions of the lib to isolate.
In your case, you just override lib in one Jar.
The following is from Servlet Spec:
It is recommended also that the application class loader is implemented so
that classes and resources packaged within the WAR are loaded in preference to
classes and resources residing in container-wide library JARs.
So, JBoss follow the spec and it always loads application lib first.
I didn't find such old version doc, but it should similar as AS7:
In order of highest priority to lowest priority
System Dependencies - These are dependencies that are added to the module automatically by the container, including the Java EE APIs.
User Dependencies - These are dependencies that are added through JBoss-deployment-structure.xml or through the Dependencies: manifest entry.
Local Resource - Class files packaged up inside the deployment itself, e.g. class files from WEB-INF/classes or WEB-INF/lib of a war.
Inter-deployment dependencies - These are dependencies on other deployments in an ear deployment. This can include classes in an ear's lib directory, or classes defined in other EJB jars.
Related:
a similar jetty classloading problem

JBoss 7 add jar to classpath

I'm trying to deploy WAR file into JBoss 7.
I placed the WAR file in the standalone/deployments folder.
while starting the server I’m getting ClassNotFoundError.
I believe Since the jars are not part of the WAR file and not placed in the WEB_INF/lib folder so I need to add them externally.
I read so many tutorials but I just can’t understand how it works.
So my question is how I simply add JAR files to the JBoss classpath.
If you want to add any jars that are not part of WebApp but are still needed to be loaded, one approach would trying to copy the jars at following location:
$JAVA_HOME/jre/lib/ext.
The JBOSS server should point to this java installation and this might resolve your issue.
This might be one way.
JBOSS 7 uses module based loading, hence most of the jars will be loaded if module is included in standalone.xml.
You will need to check in JBoss Release notes if third party modules can be loaded.
Ok I solved it by creating new module and by adding the module dependency in the MANIFEST of my jar.

Glassfish JSF Jars

I downloaded the zip version of Glassfish 3.1.2.2 and unzip it in my local directory.
When I try to add the following glassfish directory as a runtime library, it says there is no glassfish runtime.
I checked out the folder and I think it is missing some jsf jar such as jsf-impl..
How do I set this up? DO I really need to download some 3rd party jsf implmentation jars?
Thanks
I checked out the folder and I think it is missing some jsf jar such as jsf-impl.
The two JARs jsf-api.jar and jsf-impl.jar have since Mojarra 2.1.6 been merged into a single JAR javax.faces.jar. This was done so to be in line with general Java EE Maven rules. See also issue 2028.

How to make an EAR refer WAR shared library

I would like to get a help from you all. The below is the issue I am currently facing with.
I have added a reference of WAR shared library in weblogic-application.xml of EAR file.
In EAR, I do have a ejb module which has "library-directory" tag in application.xml. I want ejb module to refer jar files in shared library but it looks for jar files in lib folder of EAR.
In lib folder of EAR, jar files are not available but the jars are available in WAR shared library.
How to resolve this issue and make the ejb module of EAR refer the jars of WAR shared library.
Please add a comment if the problem is not completely understandable.
Many thanks in advance for your help!
Try defining the jars you need as modules in application.xml. Something like:
<module>
<java>pathToWarLib/needed.jar</java>
</module>

Categories