File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes EJB 3.0 Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB 3.0 Question" Watch "EJB 3.0 Question" New topic
Author

EJB 3.0 Question

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 629
Hi All,
I have a question. In EJB 2.0, we have this ejb-jar.xml file and no annotations right. Now, In EJB 3.0 we have annotations and I know that, what I don�t know or get confused is if

1). There is no ejb-jar.xml file at all since we are using annotations

(Or)

2). The ejb-jar.xml file need not be coded but is automatically generated.

Which one is true?/

Thanks.


Be Humble... Be Nice.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

The ejb-jar.xml is not mandatory but is optional. The ejb-jar.xml will not be auto generated by the application server, but will have to be provided by your application.


[My Blog] [JavaRanch Journal]
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 629
Originally posted by Jaikiran Pai:
The ejb-jar.xml is not mandatory but is optional. The ejb-jar.xml will not be auto generated by the application server, but will have to be provided by your application.


Ok, so you are saying in EJB 3.0, having ejb-jar.xml file is optional and we can have it or not. But in EJB2.0, it is mandatory right?/

Thanks.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

Originally posted by Arjun Reddy:

Ok, so you are saying in EJB 3.0, having ejb-jar.xml file is optional and we can have it or not. But in EJB2.0, it is mandatory right?/



Yes, that's correct
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

EJB2 components can be compiled under JDK 1.4, which does not support annotations. One reason annotations were added to Java 5 was to eliminate the need for a separate metadata declarations file.

A lot of modern-day frameworks support both annotations and XML. In part, this is to allow backwards compatibility, but the XML is also a way to override the annotations. Unlike annotations, you don't have to have source code and recompile - just pack a new JAR, WAR, EAR or whatever. By using the XML you have the ability to tweak stuff that you've only been given binaries for.


Customer surveys are for companies who didn't pay proper attention to begin with.
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 629
Thanks Jaikiran and Tim
Vidyasagar Guduru
Greenhorn

Joined: Apr 17, 2006
Posts: 26
Actually ejb-jar.xml file provides the metadata of the EJBs plus it also includes some other useful stuff like defining security roles, method permissions, transactions etc.

One of the advantages of the configuration/meta data files is without changing the actual application code we can change the application behavior by changing these property values.

Now if we move these settings to the annotations in the actual business components, do we need to change the components code, build and redeploy every time if there are any changes in those property values.
Ashwin Pai
Ranch Hand

Joined: May 20, 2008
Posts: 90
Vidyasagar Guduru wrote:Actually ejb-jar.xml file provides the metadata of the EJBs plus it also includes some other useful stuff like defining security roles, method permissions, transactions etc.

One of the advantages of the configuration/meta data files is without changing the actual application code we can change the application behavior by changing these property values.

Now if we move these settings to the annotations in the actual business components, do we need to change the components code, build and redeploy every time if there are any changes in those property values.


Just to add to above post..
metadata config/deployment descriptors files are also a way to override annotations. For every xml tag in the ejb-jar.xml there is an equivalent annotation...

HTH
Ashwin


The only way to make your dream come true is to wake up.
Vidyasagar Guduru
Greenhorn

Joined: Apr 17, 2006
Posts: 26
Yes, I thought the other way that Annotations overwrite the configuration file settings.

Thanks.
narasimhudu kalva
Greenhorn

Joined: Aug 03, 2009
Posts: 2
Hi all
I have a question . I know the IP Address and port number of another system which is running with sun app server. Now I want to access the methods from another client system in ejb 3.0. please tell the details of that properties file completely
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3858

Hi narasimhudu kalva,

This thread's last post is older than 7 months. Please post a new topic for your questions. And Welcome to Javaranch


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
narasimhudu kalva
Greenhorn

Joined: Aug 03, 2009
Posts: 2
I am new for this site. I don't know what todo
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10288
    
168

All you have to do is click on the "New topic" button in this forum and start a new topic to discuss your question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB 3.0 Question