Difference between implementing Web Service using Stateless Session Bean and without it - java

I am trying to learn how to use Web Services. I have been reading this link, but I don't understand the difference between Implement and Not Implement Web Service as a Stateless Session Bean

The #Stateless annotation turns the POJO into an EJB and it gives all the EJB features.
The big difference is that EJBs runs in a full featured Java EE 5+ Web Application Server like GlassFish or JBoss, making it unusable in a Servlet Container like Tomcat or Jetty.
More info:
Difference between an application server and a servlet container?
Web Server Vs Servlet Container Vs Application Server

Related

Is there a way to create a Spring Boot application with an embedded container which invokes remote EJBs?

I've gone through the Spring Boot docs but don't know if it is feasible to create a Spring Boot web application which invokes remote EJB 3.0 beans.
I don't have much experience with invoking EJBs from within Spring, but have read through Spring's Chapter 29 Enterise EJBs and it "seems" fairly straightforward.
However, is there anyway to create a Spring Boot app with an embedded container and still invoke remote EJBs? Or do I have to deploy a war to a JEE-enabled app server (ex: JBoss, Glassfish, Websphere, etc).
Are there any gotcha's or issues I have to consider when trying to invoke remote EJB 3.0 from within a Spring Boot app?
You do not need a container that provides a full Java EE implementation in order to access remote EJBs.
You can invoke a remote EJB from a simple command line program if you want.
Just follow the instructions that you linked for remote EJBs.
Note that configuration required for different target servers (where your remote EJB is hosted) can vary widely between implementations, so you will need to find out how to do it for that specific host.
You may find it easier to get a working configuration in a command line client before trying to get Spring set up because there will be less moving parts to deal with.

Java Spring: benefits of POJO objects

I am learning Spring using this tutorial. I am unable to get my head around the following excerpt from it:
Spring enables developers to develop enterprise-class applications using POJOs. The benefit of using only POJOs is that you do not need an EJB container product such as an application server but you have the option of using only a robust servlet container such as Tomcat or some commercial product.
In the good old days when application servers only supported EJB 2 it was a nightmare to develop services using EJBs. Each service (e.g. a stateless session bean) required a bunch of interfaces and strange additional methods to work properly (home interface, remote interface, deployment descriptors etc).
In order to run EJBs you need an application server such as Jboss or Glassfish. In order to run servlets you simply need a servlet container such as Tomcat or Jetty which is way more lightweight than an application server.
Spring offers a way of creating simple services as plain POJOs (that can be exposed via servlets). Therefore, to be able to develop services as a POJO was simply a dream come true. Services did not need all the constraining dependencies to the EJB-interfaces and they could be deployed in a lightweight servlet container.
Then came EJB3 which greatly improved life for the Java EE developer. EJBs no longer needed the dependencies for home- and remote-interfaces (at least not via inheritence). A modern EJB 3 service is very similar to a POJO-based service. The main difference is that EJBs still require an application server to be deployed.
Spring Guru Rod Johnson released the book J2EE Development without EJBs which greatly explains how to replace your old J2EE components (such as EJBs) with more lightweight Spring Pojos - good reading!
Read below link which may help you understand meaning of benefit of using POJO :
http://www.javaexperience.com/difference-between-pojo-javabean-ejb/

EJB container and 3 layers architecture

I am new to Java EE. I have read some about web containers and ejb containers, but I do not understand if both logical layer and data persistence layer run in the ejb container or just the logical layer runs there. Could someone explain it to me?
EJB container manages different EJB components. EJB components are "logical" components like session beans, persistence units, servlets, etc. So all of them managed by EJB container.
EE container or application container: Manages the execution of EJB, JMS, JTA run on the Java EE server. It also takes care fot transactions, security, and data sources (JDBC resources).
e.g. JBoss, Glassfish.
Web container : Manages the execution of web pages, servlets, and some EJB components for Java EE applications. Web components and their container run on the Web server such as Jetty, tomcat.

EJB 3.1 Lookup from Standalone Java program

I have a Stateless Session Bean defined using EJB 3.1 Specs and deployed on WAS 8.5 server.
Have a Standalone, Java application program which needs to do EJB lookup and call the Business method
How do I write code to do the EJB lookup from the Standalone Java Program.
You want to use a Remote Context. There are lots of documentation which cover this
http://docs.oracle.com/cd/B15904_01/web.1012/b15505/access.htm
http://openejb.codehaus.org/hello-world.html
EJB3/UseInitialContextToLookupEJB.htm">http://www.java2s.com/Tutorial/Java/0415_EJB3/UseInitialContextToLookupEJB.htm
https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project

CDI/Weld with JEE5 and Tomcat6

I'm working on a web application that is Java EE 5. I may be able to upgrade it to EE 6 at some point, but can't at the moment. The web app is running in Tomcat 6. Can I use CDI with it?
I noticed in the Weld documentation that there is a note that I can't use session beans:
There is a major limitation to using a servlet container. Weld doesn't support deploying session beans, injection using #EJB or #PersistenceContext, or using transactional events in servlet containers. For enterprise features such as these, you should really be looking at a Java EE application server.
Does this mean I can't use the #SessionScoped annotation? If so, that would be a show-stopper for using CDI at the moment.
Any thoughts? Thanks.
This is about EJB session beans. You can use CDI with JSF in tomcat 6. Just follow the installation instructions for Weld.

Categories

Resources