spring boot application deploy to dedicated jetty instance - jetty

How to deploy "war" file built with spring boot to jetty? I am unable to access restful services of my spring boot application when I deploy the war file to jetty.
Steps I followed:
Referring to Spring boot war documentation I created a war file. I could see the files are available in the war file.
Copied the war to ${jetty home}/webapps. (/usr/share/jetty/webapps)
Added a contexts.xml file with my war name (excluding .war suffix)
Restarted Jetty service
When I browse localhost:8080 I see folder structure of my web app. (i.e WEB-INF resources)
None of spring resource paths are available from localhost. My spring application has JAX-RS resource. Below is my ApplicationInitializer class (Groovy).
class ApplicationInitializer extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
Properties props = getPropertiesFromArgs()
return new SpringApplicationBuilder([Application, "classpath:/META-INF/com/foo/testapp/bootstrap.xml"] as Object[])
.properties(props)
}
Its as-if jetty start did not start spring context. What am I missing? Application works fine if I run the spring boot built uber jar. I can access all restful resources of the app.

Figured out. I was not using Servlet 3.0 compliant jetty version. sudo apt-get install jetty pulled 2.5 compliant version. Once I updated to Jetty 9.x, it worked fine.

Related

Can compile Django project to War file as boot spring

Can compile the Django project to War file as boot spring?
I would like to deploy the Django project as a compiler library which is a similar WAR file of boot spring framework into the webserver?
is there any way to hide or encrypt Django source code in order to deploy it into a web server?

ClassNotFoundError even though class is included in lib/ext folder in Jetty 9.2.2

Just want to ask about my problem. I am trying to setup a jetty server and included my own webapp. I put the web application in the webapp folder of jetty server. I also included the necessary libraries needed by the web application in lib/ext folder of jetty, it is not included in the war file. when i run the jetty server and access the webapp, i get the 'NoClassDefFoundError'.
I run the jetty server using the 'java -jar start.jar'. I am also sure that the jar file which contains the class that causes the error is in the classpath.
Did i miss something?
Thank you.

How to deploy the Web service in to tomcat 7 from out side of eclipse juno?

i am very new to web services and i have one problem please suggest me .. i.e i have a WSDL(SOAP) file and with that i created the Web Service-server and web service-Client using Top-Down approach with JAX-WS in eclipse Juno Java EE. i integrated the Tomcat 7 with that Eclipse and from eclipse its working fine.
But my problem is i need to run the Tomcat from out side of the eclipse and i need to deploy the web service in to the tomcat. i don't want to run the Tomcat using eclipse? i just need to run the client from eclipse but i dont want to run the tomcat from eclipse. Please Help me.
File -> Export -> Web -> War (configure where to create it)
Deploying a tomcat application consist of building a war file then deploying it. We call this servlet.
Building the WAR
As you already have your server code, you should now complet the WEB-INF/web.xml file. This file describe the path of your servlet(your server code), on the tomcat server. Depending of your framework you can have some configuration to add in your META-INF/context.xml file.
In an eclipse project, thoses file are generaly under a directory name 'webapp' in your project. (src/main/webapp for a maven project).
First you must use the javaee & javaweb tools of eclipse to build a war file that contains all yours libs, files, class and web.xml
Alternativly you can use a maven build process to get a war, if you use maven.
Deploying the war
After installing tomcat, the deployement is as simple as drop the .war file is deploy directory of the home-directory of tomcat. Then your application is usable on default port 8080.
If you have install also the manager webapp of tomcat, you can see all yours currently deployed application in the manager http://myurl:8080/manager/html.
When you install tomcat, let be sure that your eclipse pseudo server is shutdown, or your tomcat server will have problem to get it's port and startup.

JBoss AS 6.0.1 class resourcestream

I am trying to migrate application from Jboss 4.2.3 to Jboss 6.0.1.in our application i have to access a resource (image) from war folder.
WAR
|__ logo.jpg
|__images/icons
|__WEB_INF
|__classes
|__jps
|__logo.jpg
I would like to access logo.jpg. in JBoss 4.2.3 this.getClassLoader().getResource("logo.jpg") --> will return path/handle of logo.jpg in war folder
but in Jboss 6.0.1, same code returns null & i am not able to access any resource in war folder.
Please help me how to access logo.jpg in war folder & logo.jpg in WEB_INF folder dynamically in JBoss6.0.1.
Looks like you are using the wrong classloader as explained here:
How to load resource from jar file packaged in a war file?
Using this.getClassLoader() will only be able to access resources under WEB-INF/classes.
Also you should use getResourceAsStream().

how to run metro webservice on jetty in Maven project?

how to run metro webservice on jetty in Maven project??
As per this source.
If you place your web service in a WAR file, like here, it should run fine
on Jetty, just as it would on any servlet container. There might be some
subsequent Jetty-specific configuration needed, but I would try to deploy
the WAR first on Jetty and see where it gets you.
If you want to embed Jetty, instead of running on Jetty standalone, this
might give you some pointers.