Here on StackOVerflow I read that we shouldnt use Remote and Local interface inheritance for EJB server appllication and more, we shouldnt use deployment XML files any more.
So what are the main steps now (2013) for creating a complete EJB simple "Hello World" application? Is there any tutorial which explains it step by step for people for whom its a totally new thing? Cheers
What I found on the Internet is that the newest EJB standard is EJB 3.1. - is that correct?
EJB has really fallen out of favor. I recommend listing out what benefits you are looking for and see if there are simpler ways of doing them, in many cases there are. Are you sure you need to go EJB? Try looking at http://spring.io/.
JSR-345 defines the 3.2 version of the ejb specification
Conceptually the added features from 3.1/3.0 are not significant, so most tutorials you find for those versions will still be ok.
anyways, a recent tutorial can be found here
So what are the main steps now (2013) for creating a complete EJB
simple "Hello World" application? Is there any tutorial which explains
it step by step for people for whom its a totally new thing?
You have a lot of tutorials on oracle site.
What I found on the Internet is that the newest EJB standard is EJB
3.1. - is that correct?
Yes, latest EJB (at this moment) is EJB 3.1.
Related
I have been trying to start with studying OSGI for quiet a few days now. I've tried many tutorials to work on eclipse especially to start with apache felix or Equinox but the step by step tutorials never take me to the end of creating even one bundle.
I even tried the console commands with no luck. Is OSGI out dated? All the tutorials on the alliance web site are also extremely old and I couldn't follow them to the end. I also tried the BndTools Totorial here but on eclipse it couldn't resolve "#Component" when I reach 4.3 so I stopped there. When following Osgi Book Preview, I also couldn't find "Make Bundle" so I stopped again. I'm really frustrated. Isn't there a way for beginners to get into OSGI?
UPDATE:
For other people who are interested in getting started with OSGI, I found the book Osgi in Action as very helpful and a good guide for beginners.
The Bndtools tutorial was mentioned and dismissed in the original question; however we were able to resolve the issue. So I post this as an answer for others who might be looking for an introductory OSGi tutorial: check out the Bndtools Tutorial!
Actually there are two questions being posed here, which I asked myself recently as well, one in the title and one in the content. The question in the title seems mostly rhetorical. It expresses a notional answer for the real question that you find at the end of the text: "I'm really frustrated. Isn't there a way for beginners to get into OSGI?"
Answer: There are ways, but they aren't as easy as they should be. The "update" to the question mentions "OSGi in Action". This is a good book (which I discovered too late, it's not really on the top of the search results), but quite outdated with respect to tooling (e.g. Bndtools appears in the appendix only).
Finding no easy way for beginners, I eventually started to dig my way through the topic using an eclectic selection of resources found on the web. I documented my experience in what you might call a log of my (ongoing) journey in the hope that it may be helpful to others. I'll leave it to you to judge whether this can be considered a shy "yes" to the question, after all.
Not having reached "the end of my journey" yet, I'm not perfectly sure why there are so few up-to-date resources for beginners to get into OSGi. I suppose that the attention that OSGi got from a lot of people because it was used in Eclipse was one of the first problems. The attempt of the OSGi alliance to align with enterprise edition features was another (there are references for this, but I'm not allowed to post more than 2 links). Both incidents led first to hype (and lots of articles) and then to disappointment. In the time following, experts understood the technology better and better and applied it successfully to the problem domains where it is of use. (And these are fewer than the initial hype suggested -- or different, OSGi may regain some attention with the IoT.) But as it is often the case in such cases, the (now) experts never felt tempted to write the kind of introductions that you find during the hype-phase of a new technology.
Which brings me back to the question from the title, after all: "Is there a new standard?" (which implies whether it is worth to spend time on looking into OSGi). The answer depends on what aspects of OSGi are important to you. Project JigSaw aims to bring modules to the Java platform and to developers. With a target date of March 2017 for the central JSR 376 I'd say this might be called an "upcoming standard" (provided it gets finished). But OSGi is more than just modules. Other key features are dynamic configuration (I can't see any competing standard regarding this feature) and micro-Services (be careful about that term, it seems to have two different interpretations currently). Eventually, you have to look a bit into OSGi yourself to decide on its usefulness for your project.
You can check tutorials that help you start with OSGi OSGi Tutorial: From project structure to release and OSGi Tutorial: 4 ways to activate code in OSGi bundle
There's a lot of outdated tutorials out there, outdated documentation, and stuff which is deep in the Java EE thinking bog - incomprehensible if you're not familiar with the problems arising from the solution to the problems arising from the solution to some obscure Java decision in the previous millennium, which you're now stuck with in your mammoth EE app.
Today, there is the OSGi enRoute projects which provides a set of pretty nice tutorials, along with an OSGi "distribution" which makes dependency resolution easier. My understanding is that a lot of the additional services in enRoute are en route (ha!) to becoming the OSGi Release 7 standard.
If you want to do new development in OSGi, it's what I would go to for sure. In fact, even if you want to use OSGi in some legacy-support function, I'd read up on the enRoute way first, before getting into all the ugly compromises needed for legacy's sake.
If you are mainly looking for server side OOGi then using maven and the maven bundle plugin works very well. See http://www.liquid-reality.de/display/liquid/2011/02/15/Karaf+Tutorial+Part+1+-+Installation+and+First+application
Apache Karaf is an OSGi container that I believe makes OSGi, 'easier,' to understand and work with. You might consider getting this installed and just try it out. Documentation is pretty good as well. Take some time learning about a running OSGi container; watch it run first trying out a few commands and then deploy some simple bundles while putting a tail on the karaf.log.
Seeing Karaf running will help you understand more about OSGi and what it takes to get a bundle built and deployed/running.
IMHO: Both BndTools and Maven Bundle plugin are fantastic resources for OSGi development.
I am really really having hard time to create simple "Hello World" Web Service in Java. If you exclude several mobile Android mobile apps I have done, I am pretty new to Java environment.
First I tried Axis2 and that simply doesn't work out of the box. Fresh installation of Eclipse, Tomcat 6.0 and Axis2. Tried sample test app and it failed miserably. You can read about it here. My conclusion is that Axis2 simply doesn't work (maybe it used to work). I will try to go back to install older versions, maybe one will magically start working. I have to modify some old project at work that was using Axis2, so that's why I have to stick with it. I would hate to have to migrate to some other tool.
Then I ran on Oracle article Getting Started with JAX-RPC and I was thinking, cool, let's try that. Well, I just managed to get pissed off. After getting half way through the article and trying to write some simple test web service I realized that their code examples are poorly written. Missing brackets, wrong references, missing explanations, etc...
First of all, an interface should extend not implement. Am I right?
public interface SunRegPort implements java.rmi.Remote {
Also, this doesn't exist:
import java.xml.rpc.server.ServiceLifecycle;
But this does:
import javax.xml.rpc.server.ServiceLifecycle;
Well, I don't feel competent to criticize too much (cause of my level of knowledge about this subject of course), but after all I am suspicious that this article is complete JUNK and therefore I am not able to follow it.
Please somebody tell me that I am wrong and if anybody has some advice or link to some How-To page that talks about web services, I would appreciate.
Thanks.
The terminology Web Services is pretty vague. In Java, the modern and reasonably easy way to do this is by annotating classes.
I would recommend that first, you decide whether you want to implement:
SOAP Web Services -> look at JAX-WS
REST Web Services -> look at JAX-RS
Once you have chosen the "type" of Web Services, choose the library that implements the specification.
The Wikipedia entries list a few of these implementations. Apache CXF (complete but a beast), Jersey (popular) and Restlet are very common choices. I personally like the JBoss implementations as well for JAX-WS.
For JAX-WS with Apache CXF, here is a quick start tutorial that looks pretty good (untested)
For JAX-RS with Jersey, try this
Unless you have strong reasons to do otherwise (for instance you need to call an existing system), use REST which is simpler and leaner.
I would recommend you to check out the CXF project by apache. It's quite easy to use and should help you to set up a webservice.
There is a nice guide to Hello world set up.
http://cxf.apache.org/docs/a-simple-jax-ws-service.html
If you're still interested in giving Tomcat a shot, here is a tutorial on youtube of making a very basic "Hello world" example using Eclipse. It leaves a lot to learn; but it looks like it will at least get you started.
FYI, the version of Eclipse used is slightly outdated. So some of the menu options may not be exactly the same:
http://www.youtube.com/watch?v=EOkN5IPoJVs
Also, the meaning of "Web Service" can be subjective. So, to be specific; this just shows you how to get a basic HTTP endpoint started on your local machine.
If you are not tied to Eclipse, give NetBeans a shot. I think it's much better for Web Services in Java.
Web Services are most widely implemented examples of Service Oriented Architecture (SOA). A service contract is defined with the help of SOAP and Web Service Definition Language (WSDL) and that is published for other applications to use.
In this article we will see how we can create web service and web service client in java.
http://www.opencodez.com/java/how-to-build-and-deploy-web-service-and-client-in-java.htm
I'm trying to fully master and fully grasp Java's Spring 2.5 and Hibernate framework for a limited amount of time (maybe in in less than 2 days?) and would like to ask this community if you can point out where I can start in mastering both frameworks. I kind of understand that it takes time to fully master both frameworks but would it be alright if you can point out tutorials where annotations, the xml mapping, and many of the basic things I need to grasp Spring and Hibernate are explained to a beginner who only tried to understand within the past couple of days?
I've tried googling bunch of times and wasted 3 days already trying to figure out and understand the concepts but it seems I understood nothing yet.
One of the major problems is that I could only use the following: Eclipse, Maven, Jetty, MySQL and can't use others like Tomcat or Ant, etc.
I'm using Linux Mint 10 / Ubuntu 10.10 in learning this in short time (yeah, I am in a limited amount of time #_#).
I thank you in advance.
The Spring Reference Documentation (for 2.5.x) is a very good place to get an overview and examples on how to use the framework's features. I would recommend using a recent version of Spring, though (3.0.5 is the current stable release, 3.1 will be out soon).
The same goes for the Hibernate docs (choose your version there).
I know that reference docs are not that popular, but especially the Spring guys do great work putting together speaking examples. They also have a blog post series called "Green Beans" which introduces Spring features one by one. Maybe this should be your starting point, together with their sample projects SVN repository - the "Petclinic" project uses Spring and Hibernate together.
I'd recommend POJOs in Action, by Chris Richardson. It's a few years old but it still covers what you need.
After reading a ton of blogs and getting frustrated by all the different ways people suggest configuring these projects, I finally just created a very basic example project which integrates Spring 3.0.5, Hibernate and Ehcache. It also enables JMX easily. Take a look...
https://github.com/lookfirst/fallback
I would recommend spring Frame work reference docs. secondly, download the Spring Source Code, set up the project, go thru the internals, try sample given with spring download, google help for spring samples or tutorials.
You Will be the Master!
I am learning EJB and to do that I bought a book name EJB 3 Developer Guides. I got some understanding on how EJB architecture is and how it works. The book does well in explaining this.
But the examples in the book are all run through ant task. I basically wanted to learn how EJB's are being used in conjunction with Servlets and JSP. Some sort of a web client accessing a JSP page and a servlet getting the service of an EJB bean?
Any idea how can I move forward learning how to use EJB with the Web Tier? Tutorials or links would be better or is there any other book that I could read?
Thanks.
Simple EJB3 Servlet Application
And another option is Netbeans Java EE and Java Web Tutorials -- a best bet, if you are using Netbeans. And if you are not, and you are new to Java, I would highly recommend you Netbeans IDE. It is simple and straight forward.
Important note: if you try running the "Simple EJB3 Servlet Application" from the link about be sure you are using an appropriate version of Glassfish. It might work on JBoss 5.x - but I've never tested it (according to JBoss).
You won't be able to run on the sample application on older versions of JBoss (like 4.2.x) without some workarounds - like ones I described in one of my posts: sample application
The Netbeans tutorial seems fine - but stick to the environment and platform they are describing - otherwise you might quickly discourage and give up.
--Jakub
Do you still use session or entity EJBs in your project? Why?
EJB3 is a vast improvement over previous versions. It's still technically the standard server-side implementation toolset for JavaEE and since it now has none of the previous baggage (thanks to annotations and Java Persistence), is quite usable and being deployed as we speak. As one commenter noted, JBoss SEAM is based upon it.
EJB 3 is a viable alternative to Spring, and the two technologies may become more tightly related. this article details that Spring 3.0 will be compatible with EJB Lite (which I'm not sure what that is, exactly) and possibly be part of Java EE 6.
EJB is not going anywhere.
We're working with EJB here and it works quite well with JBoss Seam and JSF, Faclets and MyFaces Trinidad. Good UI, Templating, AJAX and stable production 24/7 running on JBoss 4.2.
It's a good stack for business processes, workflows, messageing, webservices and ui control. Fast delivery of features, easy programming and stable ground based on entitybeans with mysql persistance.
I don't want to miss the featureset of EJB 3 for the tasks our product demands.
See the overview of new features in Java EE 6. EJB 3.1 and WebBeans 1.0 help make a Java EE 6 container environment become easier to use, similar to frameworks like Seam on Java EE 5 or Spring. If you're familiar with Spring 3, this article illustrates how Java EE has evolved to become a comparable framework.
EJB is still there and growing up. There are many new features (SOAP/RESTful webservice, JPA entities, JAXB...) depend on it or at least reuse the philosophy of developing.
Yes, but EJB were stupidly complex for most use cases. Very clever, but real overkill in most cases. Hence the lightweight approach taken now-a-days.
Justin
I've just started back to work on an EJB project. I didn't remember how heavy and hard was to work with this technology. It was luck when Spring, Hibernate and Maven came. Since then everything was different and much easier.
I always could see this technology was never used properly and was taken as a pattern that I never understood.
It was supposed you needed two containers and if it was possible one server for each container. One for Business(EJBs) and another one for Views(MVC). I never saw that.
Well, it's good to know that EBJ is upgrading.