Code Monkey home page Code Monkey logo

gs-convert-jar-to-war's Introduction

Table of Contents

Spring Boot comes with two powerful plugins:

  • spring-boot-gradle-plugin

  • spring-boot-maven-plugin

They both essentially have feature parity and provide the ability to run Spring Boot apps from the command line as well as bundle up runnable JARs. This subject is mentioned in almost every guide at the execution phase towards the end.

A popular subject is that many people still wish to generate WAR files to be deployed inside containers. Both of these plugins support that as well. Essentially, you have to reconfigure your project to produce a WAR file and declare the embedded container dependencies as "provided". This ensures that the relevant embedded container dependencies aren’t included in the WAR file.

For detailed steps on how to configure your application to create a WAR file for your container, please see:

Note
Spring Boot operates on servlet 5.0 spec containers.

gs-convert-jar-to-war's People

Contributors

bernard-pvit avatar btalbott avatar buzzardo avatar cbeams avatar dsyer avatar ericbottard avatar gregturn avatar royclarkson avatar sdeleuze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gs-convert-jar-to-war's Issues

Code formatting error in "Create a WAR file" section

There is some code beginning with:


configurations {
providedRuntime
}

Outside of that block, it goes on:

dependencies { … providedRuntime("org.springframework.boot:spring-boot-starter-tomcat") … } ---

Presumably this should be one code block.

Doesn't work in JBossAS 7.2

Trying the 'complete' example in JBoss AS 7.2 (RedHat EAP 6.1). Unfortunately, it doesn't work straight out of the box.

12:15:41,411 WARN [org.jboss.as.ee](MSC service thread 1-14) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class org.springframework.http.server.ServletServerHttpAsyncRequestControl
at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:607) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:80) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_40]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_40]
at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]

Instructions missing for Maven

The "What you'll need" section states you can need "Gradle 1.11+ or Maven 3.0+". However, the "Create a WAR file" section - the crux of the guide - only describes steps for Gradle.

Would it be possible to either make it clear this is a Gradle-only guide, or provide a solution for Maven users?

Example for HelloWebXML needs to be updated

Current code does not build correctly with the latest SpringBootServletInitializer for Spring 4.0.0.RC1.

configure method needs to be updated to

@OverRide
protected SpringApplicationBuilder configure(
SpringApplicationBuilder application) {

    application.sources(Application.class);
    return super.configure(application);
}

Running in STS not working

According to your readme in STS I should be able to:
"Drag the entire application's root folder down to the server instance."
and
"Click the Start button to start the app."

This is not working. Dragging and dropping is not picking up my application.

ps. only if you use the gradle version of the project

execute bit not set on linux systems

If you are using the spring-guides on a linux system (at least on ubuntu) the execute bit is not set on gradlew. Therefore you can't execute the gradle wrapper.
You have to do a

chmod o+x gradlew

first.
I think this is an issue for all spring-guides using the gradle wrapper.

java.lang.ClassNotFoundException: org.apache.tomcat.websocket.server.WsSci

Imported the 'complete' version of the project into STS 3.5.0.M@. When I deploy it to the TcServer instance by drag and drop I get this error while the server is starting and the app does not appear to get properly deployed.

The same also happens when I run "./gradlew war" and deploy the resulting war manually to the same TcServer instance.

The error: java.lang.ClassNotFoundException: org.apache.tomcat.websocket.server.WsSci

    java.lang.ClassNotFoundException: org.apache.tomcat.websocket.server.WsSci
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.apache.catalina.startup.ContextConfig.getServletContainerInitializer(ContextConfig.java:1668)
at org.apache.catalina.startup.ContextConfig.getServletContainerInitializers(ContextConfig.java:1652)
at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1562)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1270)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

Convert jar to war incase using Spring Data JPA

Hi All ,

I want to add next section to in gs-convert-jar-to-war guide .

Guide went well if you use Spring Web only , but if You are using Spring Data JPA in your project and need datasourc to connect with your DataBase for example MySQL .

your war file will not be deployed on tomcat because not able to create datasource as it can not find application.properties file where you configure data base connection.

To Solve this issue i add @propertysource("classpath:application.properties") to my Application.java.

So i hope to mention it you Guide for more simplicity.

Similar Problem :
http://stackoverflow.com/questions/20667653/tomcat-not-reading-spring-boot-application-properties?rq=1

Thanks
Nabil

Issues deploying the boot war module in GlassFish 3.1.2

I need to deploy an ear module which has an ejb and a war module. we created the war file using spring boot. when i try deploying the ear into glassfish, i get the following log beyond which i dont seem to go beyond..

[#|2014-03-04T14:53:51.787+0530|INFO|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=17;_ThreadName=Thread-4;|PWC1412: WebModule[null] ServletContext.log():Spring WebApplicationInitializers detected on classpath: [com.espn.api.motorsports.config.WebAppInitializer@18f9ba0]|#]

One Step is missing: ./gradlew eclipseWtp

After changing the build.gradle file (apply plugin: 'war') you have to call

./gradlew eclipseWtp 

to change the eclipse project to a web project.

If you don't do this, you are not able to deploy the project directly to tcserver.

The final war file does not work when using 0.5.0.M7

When using the spring boot started parent 0.5.0.M7 the final war file includes the tomcat-embed-core-7.0.47.jar and the application fails to start in a tomcat container.
Original:

org.springframework.boot spring-boot-starter-parent 0.5.0.M6

Changed to

org.springframework.boot
spring-boot-starter-parent
0.5.0.M7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.