How to solve conflict between Jboss libs and webapps libs - java

I use JBoss 5.1 and I deploy an ear on it.
In my ear, few webapps are using some jars which are using by JBoss to.
For example, jboss use slf4j in version 1.5.6 and my webapps uses version 1.7.1
This two versions of slf4j are not compatible (see Logging framework incompatibility).
Is there any way to say to JBoss to use his own lib but webapp have to use theirs ?
Edit : I don't want to change the version of JBoss I use.
Thanks for help !

Create jboss-deployment-structure.xml file in WEB-INF folder with deployment exclusions of jars which you want to attach.
How do I disable app server embedded library(jar) for a particular WAR or EAR?

Related

WEBLOGIC : Using jar in EAR file instead of domain/lib

I am trying to use a new version of ehcache in my EAR file but there is an older one in the domain/lib folder of the weblogic server.
Of course it's not possible to upgrade the one in the domain/lib folder because it's used in other EAR files.
Is there a way to use the one inside my EAR file.
I tried to use :
<prefer-application-packages>
And
<prefer-application-resources>
In the weblogic-application.xml without success. It seems that the jar used is the one in the domain/lib folder.
I am trying to use ehcache with spring and I am using spring within a library deployed in weblogic.
Right now we are using WEBLOGIC 10 and we will use WEBLOGIC 12 in a few weeks.
Any ideas to solve this?
In my case it was not working because I used Spring from a library deployed in my weblogic.
So Spring was not able to use the Ehcache JAR in my EAR because Spring was not in my EAR. I removed the use of this Spring library and included all the Spring JARs in my EAR to make it work.

Jboss 7 getResourcesAsStream()

Application structure description: Ear application with ejb module (.jar), jboss-seam (.jar) and war module (.war).
I have a StartupAction.class (seam component) annotated with org.jboss.seam.annotations.Startup. During application deployment I need to get the resource from application.war module root (application.war/pages/page.xhtml) and WEB-INF/classes (application.war/WEB-INF/classes/file.properties)
Jboss 4.2
Thread.currentThread().getContextClassLoader().getResourceAsStream("file.properties") would fetch the file from application.war/WEB-INF/classes/file.properties.
Jboss 7.1.1
Code from above doesn't work with Jboss 7.
I know that the class loading changed but I can't figure it out how to get into application.war in jboss 7.
Is it possible to do this? Are there any example of this?
Thanks in advance.
As mentioned by #BalusC, you will not be able to read a properties file that is embedded in a web module from any other modules (EJB or otherwise) that are packaged in your EAR.
The fact that this works in JBoss 4.x is a consequence of it providing backwards compatibility for even earlier versions of JBoss. Additional configuration is required in JBoss 4.x in order for it to use specification compliant class loading. JBoss 7.x and newer use specification compliant class loading by default.
If your properties file contains external configuration that is intended to be accessible after deployment then you might consider the approach described in How to put an external file in the classpath.
However, if it is effectively static data then you should package the properties file in a jar module and place it in the the lib directory of your EAR.
In jboss7, you have a classloader for each subdeploy.
In your case, Thread.currentThread().getContextClassLoader() will return the classloader of the current deployment.
To fix your problem, you could try this:
SomeRandomClassContainedInsideTheWAR.class.getClassLoader()
Check this guide to learn more about JBoss7 ClassLoader
https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

Eclipse Jboss Tools - Deploying parent child project

I am new to jboss-tools. I am facing some configuration issues. I have configure jboss-tools and added wildfly 8.1 runtime.
I have one web application and many supporting java project. I have configured build path for the web application,added all the child projects in the build path.
Now I want to deploy them.
The problem is that child projects are deployed as "jar" files. They are deployed in web-inf/lib as jar file. I am unable to debug them.
I want to delploy them as exploded archive in the web-inf/classes.
Using the "Deployment Assembly" when ever I add a project, it is added as for example "abc.jar"
Please help.
Thank you,
Rashid
Deploying modules as exploded jars is a new feature in JBoss Tools 4.3.0.Final. From the release notes:
In Wildfly 8.2, support was added for exploded jar deployment inside exploded wars. This has allowed our tooling to support this use case as well. This new functionality will be very useful when creating a modular web application, with different parts implemented in separate projects. Hot deployment of resources such as Facelets' XHTMLs is crucial for rapid development and testing
JBoss Tools 4.3.0.Final is available in the Eclipse MarketPlace

Is it possible to deploy war file into WebSphere 7?

I am able to deploy ear file into WAS 7. But for same project unable to deploy the war file into websphere 7. Is it possible to deploy war file into websphere 7?
I would strongly recommend deploying your WAR file in EAR archive for WebSphere Application Server. Although WAS servers support deploying WAS from admin console (and not from IDE like Eclipse or RAD), after deploying such WAR, WAS packages it into automatically generated EAR. So WAS (and also some other servers like Weblogic) always in fact run EAR applications.
With deploying WAR you also have no influence on EAR level configuration as it is generated automatically on WAS.
Websphere 7 is a Java-ee 5 application server and provides so both ejb and servlet container.
It's so indeed possible to deploy a war.
If your web-application (war) is part of your Java-ee application (ear) you have to package it inside the ear, otherwise you can deploy it alone.
See packaging application

Share ejb jar file with multiple wars in Wildfly

I'm aware that this is a very simple issue, but as I'm new to Wildfly I haven't had success trying to accomplish it.
In the old days of JBoss 4.2, when I wanted to share an ejb jar file with multiple war files I just deployed the ejb jar file to the application server and configured jndi in my war projects with a file 'jndi.properties' placed in some source directory in the war files, like this:
jndi.properties
---------------
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=jnp://localhost:1099
Now, with Wildfly 8.1, this approach is not working anymore. I don't know if the contents of the jndi properties file changed or if I have to do something else. So, I ask: how do I share an ejb jar file with multiple wars in Wildfly 8.1 (I don't want to use ear files for this)?
Thank you in advance.
Marcos
PS.: Cross-posted: https://developer.jboss.org/thread/249133
just deploy the jar file and add adependency to your war file (either in Manifest.MF or in jboss-deployment-structure.xml from your war to your jar. Then you should be able to do JNDI-lookups using java:global/... or using CDI for injecting the beans using #Inject (for this approach you will need to activate CDI using beans.xml)
see also:
Wildfly class loading
Wildfly deployment descriptors
CDI reference
Application deployment

Categories

Resources