I have an application that uses Java 8 + Spring Boot + Spring 5. I packaged this application in War and I can implement it in Tomcat 8.5+ successfully.
Obviously, when I put the same WAR in WAS, it fails. This inherits the JEE context and the libraries get into conflict.
Can I add some kind of descriptor to ignore the capabilities of JEE in my WAR? I want to use WebSphere like a Tomcat.
Finally, I could run my WAR in WAS successfully. I had to downgrade Spring Boot version to 1.5.x because Spring 5 is not complaint with JEE 6.
Please check WebSphere's classloader configuration. Maybe you can make it to load your librares earlier.
https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/crun_classload.html
Related
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.
Why Spring Boot by default packaging web applications as .jar ? Are there any advantages over .war ?
Shouldn't be all web applications packed as .war in order to be deployed to real web server ?
I thought that .jar files are for desktop applications whereas .war files are for web applications. since .jar doesn't contain web application components as mentioned here:
Java war vs. jar - what is the difference?
You linked to a question about a WAR vs a JAR, while Spring boot's JAR is indeed a JAR, it contains more than what you usually put inside a JAR. Spring boot comes with an embedded servlet container, inside the JAR itself.
So the difference:
A JAR: Usually contains resources/libraries/desktop applications/...
A WAR: A web application that can be run on a web container
The Spring boot fat JAR: A web application that runs on its own web container
About your question:
Shouldn't be all web applications packed as .war in order to be deployed to real web server?
If you want to run a web application on an existing servlet container, you have to use a WAR file. But the Spring boot JAR comes with its own servlet container, so you can perfectly run it as well.
Which of the two you choose is your own choice. Even though Josh Long's mantra is "Make JAR, not WAR".
By default Spring boot will provide you with embedded Tomcat (in jar). Deploying such jar will make you less dependant on the environment and requires less configuration ("out of the box solution").
See very similar question and its answers.
I think whole point of springboot is speed of development with minimal configuration. So you may think that they provide out of the box solution , that server(tomcat or jetty ) is embedded in the jar.
Also micro-services on cloud are promoting embedded server in jar only so that server can be optimized for application only and there is no need to setup tomcat server for small application.
If you want you can create war of spring boot application
https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html
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
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?
How do I run Seam applications in JBoss AS?
I put JBoss SEAM as a dependence (using MAVEN2) of my project and deployed it in JBoss AS - just that will sufice to make my project work properly (with all the features provided by JBoss Seam) or do I need to modify JBoss AS in any way (like, for example, include some extra seam library in the lib directory of JBoss AS)?
You don't have to modify your JBoss AS installation, deploying the SEAM JARs as part of your application EAR should work perfectly.
mvn archetype:generate
option 20 and follow steps, you should have a good start up pom.xml.