JBoss AS 6.0.1 class resourcestream - classloader

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().

Related

spring boot application deploy to dedicated jetty instance

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.

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.

a Web Service deployed (as an aar) file to Axis2

I have a Web Service deployed (as an aar) file to Axis2, but the dependencies (in the form of .jar files within the lib directory of the aar file) are not found on execution. They do get used properly if I copy them into the WEB-INF lib directory of the Axis2 installation, but this is not an ideal workaround.
Does anybody know of any configuration settings I might have missed? Has anybody got a
aar file (on OC4J or other server) with Axis2 v1.2? I'm not sure whether my problem is with Axis2, so might have to deploy the service to a Tomcat server to check but would rather not go through that cycle if someone can point me in the right direction.
Thanks,
You can put the jars into a lib directory inside the AAR. as pointed out in Where to deploy a jar dependency of my webservice?
This will help you understand the structure of the aar file -http://axis.apache.org/axis2/java/core/docs/quickstartguide.html

war file of web service

I am developing a web service using Exlipse ( Java EE - JUNO- ), Tomcat, and CXF.
I have problem because I am not sure how I can export the war file; Specially two folders have been created. one for the service and the other for the client.
can anybody please explain to me how I can export and deploy the war file correctly.
thanks;
In the Project Explorer, you can right click on your project name → export → WAR File
A WAR File is for a Web App. For the second project (client), you should export is as a JAR file. You can select the option "Export source files".
You can deploy the WAR file on a web application server like Apache Tomcat. I don't know exactly how to but it's simple, you can search for it.