Router servlet for webservice project - http

In my recent project i started using maven , instead of depending on RAD to deploy and build ear, i have been coming across little things why to use , which one is best..
My question here is , below code i copied form web.xml and it us com.ibm.ws.websvcs.transport.http.WASAxis2Servlet servlet by ibm to route http request to web services, is there any servlet present from java that can replace the above one , we dont want our ear generation should be dependent on specific application server
<servlet>
<servlet-name>com.test.HelloWorld</servlet-name>
<servlet-class>com.ibm.ws.websvcs.transport.http.WASAxis2Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>com.test.HelloWorld</servlet-name>
<url-pattern>/HelloWorldService</url-pattern>
</servlet-mapping>

No.
The Servlet that you're seeing in the web.xml is an IBM-proprietary Servlet that routes HTTP requests to Web Services and, as far as I can tell, if you're running WAS 7.0 onwards you don't need it. You can simply use JAX-WS to annotate your Web Service class.
EDIT as per OP's comment
As you're using WAS 8.5, you have JavaEE 6.0 at your disposal. You don't need any router project anymore. IBM's proprietary router was needed in previous versions of WAS in order to route HTTP requests to Web Services and/or EJBs; however, with JavaEE 6.0, you can use JAX-WS in order to automatically intercept HTTP requests by Web Service classes as well as EJBs.
If you have a "router" project, you can safely throw it away.

Related

"Hystrix stream is not generating for my spring mvc application"

I have a simple Spring MVC application. For that application I have Implemented Circuit Breaker Pattern using #EnableCircuitBreaker Annotation. It is working fine. But While trying to generate the hystrix stream it showing 404 error. Can anyone please help me out this.
Hystrix stream (/hystrix.stream) is only enabled if you have spring boot actuator dependency. Please try to add the below dependency into your pom or gradle build file.
org.springframework.boot:spring-boot-starter-actuator
Updated # 2017/06/26
If your application is not based on spring boot, you need to configure HystrixMetricsStreamServlet by yourself. Because /hystrix.stream is auto-configured by spring cloud netflix and it is based on spring boot.
First, you need to add dependency of com.netflix.hystrix:hystrix-metrics-event-stream into your application.
Second, you should HystrixMetricsStreamServlet servlet into web.xml like below.
<servlet>
<description></description>
<display-name>HystrixMetricsStreamServlet</display-name>
<servlet-name>HystrixMetricsStreamServlet</servlet-name>
<servlet-class>com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HystrixMetricsStreamServlet</servlet-name>
<url-pattern>/hystrix.stream</url-pattern>
</servlet-mapping
If you find the details about how to configure HystrixMetricsStreamServlet in your web application here.

Spring MVC transparent resource proxy

I'm looking for a solution which allows me to proxy specific requests from my Spring MVC webapp to an another HTTP server while running in development profile. What i'm trying to achieve is to make Dart's Pub serve the web application files on it's own HTTP port, but map this path into my Spring MVC application so the Spring provided REST resources and the Dart files will be served from the Spring MVC HTTP server from the browser's perspective of view. In a release configuration these files will be bundled into the war so the proxy will be not required.
I wonder if this is supported by any built in MVC element in Spring (eg. the mvc:resource) or i have to write my own proxy element for this?
It can be done using a special Controller which's bean can be assigned to a profile and included in the dispatcher context scope only in development time.

how jvm know the creation of servlet object

I have one webapplciation, i deployed it in server,server uses Jvm.
How jvm know the whether servelt object is created or not?
and one more thing In my web application having more than 5 servlet classes,then how jvm know which servlet instance created.
Servlets are declared in web.xml, when an application server which is in compliance with Servlet API start, it try to look for this file. In web.xml you have listed the servlet you want to load and the classes you should load in order to start servlets.
Servlets has their own lifecycle, if application server can not start a servlet, exception could be thrown then application server know that the servlet is no available.
Try to read more about servlets there many good tutorial over the net.

Use Domino web server hosts servlet, but it's built-in servlet api is too old

according to this guide! I run servlet successfully, but some of actions of the servlet failed, because they need servlet-api 2.5+ support. how can I use my own servlet-api library instead of domino web server's old version.
thanks!
David Taieb (software architect at IBM) stated in a comment to a blog post:
In 8.5.2, Domino introduced support for Equinox Http Service which allows you to create lightweight servlets registered via extension points. I say lightweight because these servlets are not run within the context of a traditional J2EE Web App with web.xml support. However, the Equinox Http Service lets you associate an http context to different servlets so that they share the same http session object.
Starting in 8.5.3, Domino will start supporting the XPD Web Container which is a full fledged J2EE Web Container (although it does not support things like EJBs). With the XPD Web Container, you can transform almost any WAR into a WAB (Web Archive bundle) and run it in Domino.
You maybe also want to take a look at Servlet Sample at OpenNTF.
Otherwise, please state the version of Domino, you are currently using.

How to initialize a web app?

My Web App will be deployed as a WAR package in a Jetty instance. It needs to perform a lot of caching before serving requests. How do I call the caching method before anything else? is the a static void main() in the web app standard?
A standard (old) way is to code a Servlet which takes care of initialization stuff in its init() method. You force it to be initialized at application start by adding a load-on-startup positive value in your web.xml
<servlet>
<servlet-name>myinit</servlet-name>
<servlet-class>com.example.MyInitServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
Today it's more usual to have a bean container like Spring, which takes care of this kind of things (instantiating services objects, preloading cacheable sharable data, etc).
Note: this recipe is for webapps in general, not specific to Jetty.

Resources