Does EJB need a dedicated server in order to be used? - java

I am new to Java EE. Does EJB need a dedicated server in order to be used or can I potentially make a Java EE application simulation on my laptop via only a web server?

EJB need an application server like JBoss, WebSphere, WebLogic, GlassFish, etc.
Pure web servers like Tomcat or Jetty cannot run EJB.
All application servers can also function as a web server.
So the answer to your question is - no, you can't run EJB only via a web server but yes, you can run an application server on your laptop and use it to run web and EJBs.
A more technical explanation is that you need an EJB container to run EJBs and a web container to run servlets and JSPs. A web server has only a web container. An application server has both.

You need an EJB container to run EJB with all the features (i.e. transaction, security etc.). But if you are are using EJB3 you can use something like ejb3unit to unit test the functionality of the EJB classes.
http://ejb3unit.sourceforge.net/

You need a EJB container to run EJB applications. However, it is easy to run one on your computer, just as it is easy to run Apache server for HTML/PHP applications. Glassfish is an example server which contains an EJB container.
If you only want the EntityManager functionality from EJBs, then you can simply use Java SE. See here.

Related

Running EJB 2.1 on Wildfly 10

I want to run EJB 2.1 with Wildfly-10 AS
I have a server running on jBoss-EAP-6.2
Following are the configuration xml files
I wanna achieve to run a Web Module (JSF) with existing server (EJB 2.1) running on JBoss-EAP-6.2.
Following are the ideas
I can run JSF on JBoss-EAP-6.2 (possible?) that can communicate with EJB within the server
Deploy JSF on wildfly and it communicate with EJB through JBoss-EAP-6.2
MORE / FINDINGS
while deploying JSF on JBoss-6, I am getting blank page on opening, noting is shown
Wildfly does not support CMP files of EJB 2.1
The Idea
We have a desktop based [swing] application running on JDK 1.7, EJB 2.1, JBoss-EAP-6.2. I want to enable/implement its web module [JSF]
I want to reuse its server [EJB].
My idea is to use EJB 2.1 with JSF on Wildfly or deploy JSF to connect EJB on JBoss-EAP-6.2.
Try to migrate from EJB2.1 to new EJB3.x. I understand that it will be really a hard way, but it will be easier to extend this application further. Then you will be able to easily write your web module on JSF within WildFly 10.
Start new server instance of WildFly 10 and try to use remote EJB2.x interfaces within it to access business logic. And then use it to build your web module.
Develop REST facade on top of your EJB on jBoss-EAP and then use it the way you want it.
Start writing from scratch with new technologies.

Spring application deployment on Java-ee servers

Can I deploy a Spring java application on all (or at least most) of JavaEE servers ? like Weblogic, JBoss, Webshpere, Tomcat, Jettty etc.
And is there is preferred Java EE server for Spring ?
Yes you can. And no - there isn´t. Errata: you can take a look at the SpringSource dm Server. Be aware that spring is not a java EE implementation. Read this post here.
Yes, you can deploy it on any server, and you can use it on standalone applications and even on mobile applications. It is in no way restricted to web deployment. It is not even restricted to java, there is Spring.NET and even a Python version. However, java and web servers are a common if not the most common use for it.
Currently recommended web server by VMWare/Pivotal (current owner of Spring) is VFabric tcServer, which is a Tomcat fork containing some extra tools and functionality. But server in itself does not matter, Spring is container agnostic.
There is no preferred EE server. VFabric tcServer is a servlet container, not an EE server. It contains "enterprise capabilities" instead, but that's not the same thing. As said however, you can use whichever EE server you want.

JBoss starting with only EJB Container

I am currently writing a web application which uses JBoss6.x as the application server, for load sharing what I have decided is to write some EJB's which can be either run locally on the same machine as the web application on the Jboss or in a separate machine which will be remotely connected which will have Jboss running on it.
Now the question here is, I would be needing only 1 JBoss server to serve the web application, all other Jboss in question should be running with only the EJB Containers. Is it possible to run only the EJB Container and the naming services so that I can remotely connect to the same? Pointers or specific links as to how to go about doing this would be much appreciated.

Does EJB container reside in all application servers. EJB container in depth

I am newbie to EJB's. From all the reading and searching I have done till now, I understood the following:
EJB are the beans in which an applications business logic is written and maintained.
All EJB's are put into something called EJB container.
EJB container is nothing but a server side program written in order to manage EJB's, and to provide basic functionalities which are meant to be provided by EJB(viz, transaction management, security, collision free envt, etc).
1) My doubt is, does the so called EJB component reside in all application servers?
2) When we say EJB 2.1/3.0/3.1, does it mean that the new version of EJB container has been released?
3) Does the EJB container reside in web servers too?
Thank you.
You understood the EJB idea correctly.
Yes and no. Depends on what you understand as "Application server" (ambiguity described below in answer 3.)
When you say EJB 2.x/3.0/3.1 or so on, you're referring to a particular EJB specification which means that you're referring to a set of services this version supports. In other words - yes, it means that the EJB container must be in a given version.
First the specification is released (you can see the draft versions, vote for new features and basically participate in this process). Then, a reference implementation (RI) is written just to show that it's "doable" and you can use it right away. Then, different vendors might provide their own EJB containers which must conform to the particular EJB specification.
There are few different terms you need to be aware of. Just to be sure, we're talking about the same things:
Web server is a HTTP/HTTPS server like Apache HTTP Server which serves clients requests. This term is not only related with Java EE.
Web container is a Java EE term which can mean few things, but usually it refers to Servlet container and, let's say JSP container. Those containers are serving web clients, so that's why it's web container. Generally, web container have a web server within it (like in the case of Tomcat.) However, you can configure it so that the static resources will be server by only pure web server while dynamic content (your Java App, Servlets, JSP, etc.) will be server by your web container.
Application server is a vague name. In Java EE purists world it can mean only such server that provides all the Java EE services. Non-Java EE purists treats Application server just as an arbitrary server which consists of your application. According to this definition, you can call Tomcat (a web container and web server) an application server.
As you see, the vocabulary is not sharp, as one thing might mean few slightly different things. Moreover, since Java EE 6 we have profiles. This means that you can have Java EE Application Server conforming to the Web Profile or Full Profile. In such terms, just the Web Profile server should be treated as an application server.
Just as a summary - you can use EJB Container in Web Container. Take a look at OpenEJB or basically at project TomEE.
To answer your questions
Generally yes. Application server is generally referred to a server with has EJB container like Glassfish, Jboss etc. But you need make sure that the application server has EJB support.
YES
NO. Web servers or Web containers (Tomcat, Jetty etc ) serve a different purpose than EJB container. But all the application servers do have web servers (along with EJB containers. ).
The EJB container and web container (servers) server are different layers in a Java EE application scenario . Check this link for more info.

Communication between EJBs deployed in different Application Servers from different vendors

I ‘m trying to create a small EJB 3.1 application in which I want to use two application servers from two different vendors. (JBoss 6.1.0 Final and Glassfish 3.1). This is just to experience the taste of distributed applications and new features of EJB3.1.
This is the problem I’m having…
I have created a simple EJB (kind of a hello world ejb) and deployed it in GlassFish server which is running in the machine A. Let’s call it GlassFishHelloWorldEjb. This one has business remote and local views.
I have created another EJB project in which I have an EJB called JBossHelloWorldEjb. I have deployed it in the Jboss server which is running in the machine B.
Now I want to inject GlassFishHelloWorldEjb to a reference in the JBossHelloWorldEjb so that I can call it within the JBossHelloWorldEjb. Then I have a web app deployed in the Jboss which calls the JBossHelloWorldEjb.
MyWebApp(Jboss, machine B)-----> JBossHelloWorldEjb (Jboss, machine B)----> GlassFishHelloWorldEjb(GlassFish, Machine A)
I tried many ways to inject the GlassFishHelloWorldEjb in to the JBossHelloWorldEjb but failed. Could some please shed some light to achieve this.
Would greatly appreciate if you could show me the way to do this through both INJECTION and Programmatic JNDI look up.
Cheers
Lekamge
one option might be to use Spring RemoteEJB Proxies
OR. import client required jars for remote and write your own wrapper

Categories