spring boot startup fails when using war built on jenkins - maven

We have a spring-boot application, built as a .war assembly (Maven build), which is deployed on the server with simple java -jar command.
As a part of CI/CD, the same code is being built on Jenkins. The Jenkins server is CentOS and the target deployment server is RedHat. The .war file built on Jenkins fails with Spring Beans Cyclic Dependency resolution error, while the same code when built on local(Mac OS) or on RedHat server works fine.
I tried to look through the war file, for each and every dependency, and everything looks same except for jsp-api-2.1 jar. The jsp-api-2.1.jar included in .war built on Jenkins has Created-By: 1.5.0_06-b04 in MANIFEST.MF, while the jsp-api-2.1.jar included in .war built on local (MacOs) or on Redhat has Created-By: 1.5.0_04-b05 in MANIFEST.MF. Other than this all other dependencies are the same.
The war files' sizes differ slightly, however, I could not find any difference other than what mentioned above.
The error which we are getting on Jenkins built jar is below,
Description:
The dependencies of some of the beans in the application context form a cycle:
| Class A
↑ ↓
| Class B
└─────┘
Does Maven generate any OS specific files, or are the dependencies downloaded from repository OS specific?
I can't really think of anything as both the .war files look similar. Any information on this will be helpful.

Related

Locally installed jar is not included in my IDEA tomcat deployment

My IDEA project compiles and builds just fine when I compile using IntelliJ.
For some reason, when I deploy to tomcat using an exploded-war, 1 jar I have isn't included in the deployment and my spring app fails to load because it can't find the class.
The jar in question is a locally installed maven dependency i.e. on my laptop
Could this be the reason why it is being skipped by IDEA? It maybe tries to find the jar using maven, but since it is local is can't and skips it?
How can I fix this?
The IDEA project is a maven module and builds fine.
Put that jar into the libs folder of tomcat or embed it into your own jar using maven assembly plugin. https://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html

Maven JBOSS application deployment

I followed this tutorial http://www.mastertheboss.com/jboss-maven/jboss-maven-example-building-a-java-ee-6-application/ in order to have a simple web application to better understand Java EE and JBOSS. I set up the example project (by archetype) and compiled it.
However, I am stuck after running mvn compile. I want to deploy my application as a war file to my JBOSS webroot directory (in my case /usr/share/jboss-as/standalone/deployments/).
I think mvn package and mvn install must be executed. Where can I specify that I want a war file and that it should be copied to my deployment location on JBOSS?
Obviously, I can use the jboss maven plugin http://docs.jboss.org/jbossas/7/plugins/maven/latest/, which is addressed via console
jboss-as:deploy
Configuration is read from the POM file.

Deploy MavenWebApp in Eclipse Tomcat

I have the following Problem:
I have a Maven MainProject with some SubProjects.
Two of this SubProjects are WebApplications. (One WebApp and one WebService)
If I build the MainProject in the command line with mvn clean package the 2 .war files are deployable in an external Apache Tomcat 6.0.
If I build the MainProject in eclipse with the m2e plugin i can also deploy the .war files into an external Tomcat.
BUT if i want to deploy the WebProjects in an Apache Tomcat in Eclipse, it doesn't boot.
The Problem is, that the file structure of the eclipse build for the internal Tomcat is different to the Maven one.
In the Maven build (console / m2e) the path is correctly from e.g. Project/src/main/java/com/... to WEB-INF/com...
The eclipse build for the internal Tomcat creates the structure like WEB-INF/main/java/com/...
So many of the .xml files which are mandatory for the Tomcat boot are not found bacause of the wrong path.
How can i tell eclipse that it should do the similar build like m2e or maven on command line so that i can use an internal tomcat in eclipse?
I am using
Eclipse Juno 4.2 or Helios 3.6
m2e - Maven Integration for Eclipse / 1.1.0.20120530-0009 / org.eclipse.m2e.feature.feature.group
Maven Integration for WTP / 0.15.2.20120306-2040 / org.maven.ide.eclipse.wtp.feature.feature.group
I fixed the problem.
The problem was the deployment assembly options in the eclipse projects.
Eclipse default option is to deploy /src to / folder.
Because of the maven structure /src/main/java/com the deployed folder also looks like /main/java/com.
I only had to change the source folder from /src to /src/main/java (the destination still remains /). If there are other necessary files i had to add them the same way, e.g. /src/main/resources.
The /src/main/webapp folder was already set correctly by eclipse to /WEB-INF

Maven Jetty Run from Jar

Here is want I want to do. I created a maven project and configured the jetty plugin for it in eclipse...
So from Eclipse if I do run and set the maven goal there to be jetty:run it runs my project in jetty on the port specified in web.xml. Now I want to build the jar file and when I do java -jar myapp.jar it will automatically call jetty:run.
How can I do this?
If you want to package your application so that you can hand it to someone and have them run it as a standalone application without having to go through deploying a war file into a web container, then that is a different concern from doing mvn jetty:run at development time, I will call that deployment time to avoid any confusion
At deployment time, we can't assume there will be maven on the machine, thus no mvn jetty:run, and even if there was, this would not work, unless we deliver the source code to run the build as in the development environment!
A standalone web application can be packaged by bundling the jetty jars in the application war along with a Main class to start jetty programmatically, and get it to run the application war. This relies on the fact that the file and directory structure of the WAR and JAR are different, and thus there is no significant overlap between the two, which is what makes this workaround possible, and it also leaves the option of deploying the war file in a web container possible
There is a maven plugin that embeds winstone which is another lightweight servlet container
For jetty, you may start by reading Embedded Jetty 7 webapp executable with Maven

Which way is the best to go for building a webapp as osgi bundle via maven and start them with webstart?

I am looking for a way to reach my vision. What is the best way to go?
Here is my vision:
I would like to build a captain casa app via maven (as a war file).
Then i would like to create a osgi bundle from the builded war via maven.
Next i would like build a artifact which could be downloaded and started via java webstart (jnlp).
The jnlp file should be download the osgi environment with web container support (maybe jetty osgi service), next download osgi bundled war. Then the osgi container and the jetty service should be started and my war should be deployed. Finally the app is running local in a osgi environment.
There are many questions to be answered:
How can i build a captain casa app via maven to a war?
Which maven plugin should be used to build the osgi bundle (pax, maven-bundle-plugin, tycho, ...) What are the differnce?
How to build a jnlp artifact via maven which can deployed on a site?
How must be modified the osgi bundle to support java webstart?
Known informations:
Blog entry to prepare osgi bundle for java webstart.
many pages to maven plugins, such as pax, maven-bundle-plugin, tycho, bnd, ...
It might be worth asking this as 3 separate questions, but when building Web application Bundles I use the maven-bundle-plugin version 2.2.0 (currently unreleased, so you'll need to depend on a snapshot).
Then I use the following file structure:
src/main/java - any .java files
src/main/resources - any non .java files that should be on the classpath
src/main/webapp - static content, images, html files jsps and so on
Then inside the pom once you have configured the normal data for the maven-bundle-plugin you specify the following:
<_wab>src/main/webapp</_wab>
this will cause the static content to be pulled into the bundle and the bundle to be structured with the classes and resources in the WEB-INF/classes directory.

Resources