Injecting client proxy in JSF Bean - spring

In my project, Web services are implemented using JAX WS - RI.
I want to call the web service methods from the JSF managed beans.
I mean to say I require the spring injection of client proxy in the managed bean.
For CXF i have read that we can use jaxws:client tag in the spring application context xml.
But for JAXWS RI I have no idea.
Any idea how can i do that?

For this you need to include the following preamble at the top of your Spring XML configuration file
xsi:schemaLocation="http://jax-ws.java.net/spring/servlet
http://jax-ws.java.net/spring/servlet.xsd"
and use the WebServiceServlet(WSS) tags.
More Info: link

Related

Would #WebService annotation interfere with #Endpoint in Spring Web Services?

I'm writing a Spring Boot Web Services application, thus I'm using #Endpoint and #PayloadRoot annotations.
For documentation purposes I'm using Enunciate, which doesn't support Spring-WS annotatinos at the time of writing.
Would it do any harm if I add the javax.jws.WebService to an already #Endpoint-annotated class too? Should I use only one of them?
As long as you don't have a JAX-WS implementation like CXF in your classpath and configured the WebService annotation will not be considered.

Force Spring Boot to use servlet mapping in web.xml

I'm currently trying to shift my existing dynamic web project to Spring boot project and it uses web.xml for servlet mapping. I understand that spring would ignore the web.xml file, what should be the correct approach for spring to use the existing web.xml? And yes, I still need to stick to using web.xml for this project.
I'm kinda new to this, please guide me through! Thanks!
I suppose that you need to stick with a web.xml because your container uses an older version of Servlet than 3.0.
Spring Boot is built on Servlet 3.0. You have to update your main class to extend SpringBootServletInitializer and override configure method, which tells spring to use its Servlet 3.0 support. Embedded containers like Tomcat need Servlet 3.0, so if you want to start your project during the development process (including JUnit tests) in embedded containers, I think, from what I know, the only way is to rewrite your web.xml to Servlet 3.0 java config. But if you really want to deploy you app in an older container, you still can by using spring-boot-legacy module. It allows you to use web.xml for older containers; only thing you have to do is to add
org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener in your web.xml.
For more information about deploying war in an old container, take a look at Spring Boot's official documentation.
Spring Boot uses Servlet 3.0 APIs to initialize the ServletContext
(register Servlets etc.) so you can’t use the same application out of
the box in a Servlet 2.5 container. It is however possible to run a
Spring Boot application on an older container with some special tools.
If you include org.springframework.boot:spring-boot-legacy as a
dependency (maintained separately to the core of Spring Boot and
currently available at 1.0.2.RELEASE), all you should need to do is
create a web.xml and declare a context listener to create the
application context and your filters and servlets.
This is a very old question, but I'm currently on the same situation and I will share my experience.
I extended the SpringBootServletInitializer class to create my #SpringBootApplication, and it will INCLUDE your web.xml configuration by default. I'm still able to declare or edit existing servlet mapping, and it will be taken in account.

Does Spring Framework come with its own beans?

This text is from the book called Core Java Server Faces:
It is a historical accident that there are two separate mechanisms,
CDI beans and JSF managed beans, for beans that can be used in JSF
pages. We suggest that you use CDI beans unless your application must
work on a plain servlet runner such as Tomcat. The source code for the
book comes in two versions, one with CDI beans (for Java EE 6
application servers) and one with JSF managed beans (for servlet
runners without CDI support).
My question is:
If I use the Spring Framework, and a Tomcat Server, will I need to use one of the beans mentioned above, or does Spring Framework come with its own bean implementations?
As far as I know, Spring Framework supports Dependency Injection. Does it support it if I run the application on Tomcat? Does it mean that I will be using neither the CDI beans nor the JSF Managed means mentioned in this book?
Thank you.
talking about container is more correct than bean implementation. Yes Spring comes with its own container. In fact you can see spring frameworks as a kind of alternative to the full Java EE stack.
Using Spring DI and CDI together has about no interest but you still can use JSF with spring on tomcat although if i would advise you to switch to a Java EE 6 web profile server instead of spring in this case.
Spring comes with is own view framework implementation named spring mvc.
All of this can run perfectly on any servlet container (jetty tomcat etc...) on condition that you provide associated dependencies ofc.

can spring inject EJBs into annotated fields of servlet in a Java SE webapp?

Spring has support for injecting javax.ejb.EJB annotations, much like it injects #Autowired and other jsr-220 injection annotations, thanks to the CommonAnnotationBeanPostProcessor class.
However, injection doesn't work for servlets, since the servlet isn't created by spring.
This article - Spring injects servlets too - doesn't give an example using servlets, but claims it's possible using compile-time weaving of aspects. Unfortunately, compile-time weaving is not an option for us. Is it possible to do this at runtime? It's ok to introduce a subclass to the servlet if that helps, but I want to keep EJB annotations so the servlets can still deployed in a Java EE container.
EDIT: The app will be deployed to a Java EE container in production, but I was thinking of using spring for running functional tests and for local deployment for development to take advantage of hot JSP loading in Tomcat.
You will need Java EE container like in Glassfish that supports injection of EJBs and beware that injection works on managed classes like servlets, managed beans..etc (classes that are managed by containers) so ejb injection in normal classes would require you to use lookups instead.

how to invoke Spring Portlet

I have been reading and following the spring doc on how to create Spring Portlet and I have most of the configurations and a basic controller done. But I don't know how to invoke it. In Spring MVC, we can config a url so that we can invoke that controller. but how is it done in Spring Portlet? It doesn't mention in the documentation, I think.
I also read the following article and it doesn't say how to config the portlet either.
http://www.ibm.com/developerworks/websphere/library/techarticles/0802_patil-pt1/0802_patil-pt1.html
In Oracle WebCenter, to config a portlet, we need a url. What would be the url for the Spring Portlet then.
While configuring Portlet in Jboss portal server only Portlet class name is enough.
Check this to do in Oracle WebCenter Creating Java Portlets

Resources