What steps are required to make a executable war without unpacking the war. ( Similar to the way spring boot does). Basically want to wrap Embedded Tomcat into existing war and make it execurable.
Env: Spring mvc, Java 7, Webapp with web.xml
So far I have done following research:
How Spring boot creates Embedded container in TomcatEmbeddedServletContainerFactory, but all those WebApploader stuff I'm not able to understsnd.
Successfull in packaging a executable war just using spring boot maven plugin but not able to run without unpacking it.
Tomcat api class doesn't read app from war directly.
Have successfully tested embedded tomcat by extracting it in a particular location and calling addWebapp method.
I do not want to create a big fat jar using shade plugin.
Do not want to specify path like src/main as indicated on many examples on the internet.
Upgrading the app to spring boot web is not possible due to time and other dependencies.
Related
I'm having trouble deploying my Spring MVC Webapp with the xsbt-web-plugin. When i'm using container:start everything works just fine, but when i'm trying to run the packaged .war file inside a tomcat instance the webapp isn't loaded. It is just starting a plain tomcat instance.
I had an error in my path that slipped through. I've overlooked this for days. Sorry.
Suppose when I make a java spring boot application, it needs jars .
But when I deploy my app to cloud foundry will all the jars get build with my app and then go to cloud foundry or cloud foundry provides the jars dependency by seeing pom etc.
I have seen build folder but the jars are not there so how does it work.
I am new to cloud foundry so if someone can clear my doubt.
For most application types and build packs, when you push an application to Cloud Foundry you are pushing source code, and, if necessary, that source codes gets compiled during the staging process by the build pack. For example, with the Golang build pack you push your Go source code and it's compiled in staging and then run.
The two exceptions to this rule are the Java build pack and the binary build pack. These two build packs assume that you are pushing compiled bits and do not compile anything for you.
In the case of Java, this means that you're going to run Maven, Gradle or some other build system locally or on your CI system to produce a deployable artifact. This could be a WAR file or a JAR file, or a few other things (see "Standard Containers" on the Java build pack docs for other supported formats). Regardless of the format, it needs to be a complete and deployable unit, so it will need to include all dependent libraries.
As a side note, the cf cli has a nice feature that helps to speed up the cf push process and save bandwidth. It matches any files being uploaded and over 65k in size (default, operators can change this) to files cached on the Cloud Controller. If a local file already exists in the cache, it is not uploaded again. This works great for dependent JAR files which don't often change between pushes.
Spring Boot apps are typically packaged as "fat jars" using the Spring Boot maven or gradle plugin. The application code and all dependent jars are packaged into a single jar file.
Cloud Foundry will not download dependent jars when a Java application is deployed. It is the app's responsibility to bring all dependencies with it.
I have built a small web app using Gradle. Things seemed to be going well using the embedded Jetty server, but not so well when I tried to copy the WAR file to a standalone server.
I used the gradle war plugin to assemble the war.
Running gradle jettyRunWar works fine.
Copying the war to the Jetty webapps folder and running Jetty fails with this exception:
java.lang.IllegalStateException: No such servlet servlet_name
But this very same servlet is found and used without issue in the embedded Jetty server.
The same issue happens if I manually copy the exploded war to the webapps directory.
The Spring web and Spring mvc libs are copied and present in the WEB-INF/libs directory, so it isn't an issue of not finding Spring (or is it?)
I'm using Jetty 9.1, and my web.xml file is configured for Servlets v3.
I'm also using Spring 3.2. The web app I'm writing is a RESTful service, using the #Controller annotations to route requests.
This should be as simple as copying the war over, but it seems not to be. At a bit of a loss at what to do here, any thoughts?
Thanks!
Sometimes the answer is staring you in the face...after posting I realized that I had my servlet-mapping before my servlet declaration. While this did not present an issue for the Gradle Jetty (not sure why), it made Jetty unhappy. Not sure why I changed the order to begin with...
In short, Jetty seemed to not find the servlet because it had not been declared yet.
I am new to deployment and development of web applications.
Suppose I create three jar files and deploy them on a Tomcat server. I use maven to install the jar file and to deploy.
How is it possible to call a method in another jar file?
For example:
I developed a simple application in mytwitter.jar.
Then, I create myapp.jar, where one of the classes needs to call a method in mytwitter.jar.
Do I first deploy mytwitter.jar to the server and myapp.jar later?
You package all of the JARs you need (yours and 3rd party alike) into a WAR file which is what gets deployed to the Tomcat server. So in your maven config you likely already have dependencies configured for things like the twitter API and other packages. Just add your own JARs in there as well and then your code has access to it like anything else.
I have a question about RAD & WAS Spring MVC development. So that we have a project in SVN that was created by me in STS (eclipse), but some of our team members can't retrieve & run this Spring MVC project on their RAD (ibm tool) IDE on WebSphere Application Server 7. It requires to create an EAR to run it on WAS, but in this case there're 2 projects in project explorer; EAR project & the normal one... the normal is almost an empty project, but everything from SVN is kept under EAR project. But they can't simply access index.jsp file from WebContent folder when they try to run EAR project on WAS, it says "Failed to find resource /index.jsp".
Any suggestions?
When work Spring projects over RAD we do the following approach:
We create a Dynamic Web project that contains all our Java Classes, JSP's, Spring files and some libraries that are inherent to the project. This project can be exported to a WAR and executed in containers like Apache Tomcat with no problem.
The we create an Enterprise Application Project that contains a Web Module reference to our Spring project, so we can run our application over IBM WAS as an EAR (although, WAS can work with WAR's too). This project only contains some configurations files and upper-level libraries.
Your Spring project should be imported in RAD's workspace as a Dynamic Web Project, and the EAR project must be created by the guys that uses RAD for development (an uploaded to SVN if you need it). If your "normal" -i.e Dynamic Web Project- is empty, you should check that the uploaded files are OK and the checkout process was normal.
Can you access the other resources besides index.jsp?
You got to narrow down things?
What is the context root for your web application? Is it "/"?
Post in additional information before folks can assist you
HTH
Manglu