This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NEED HELP !!

 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am preparing for BCD5.0

Please refer to the Orielly Book page 66. I am trying to jar up the files as said there.
Before jarring up the files I need to complile them. Which J2eeSDK should I use for that? Please give me link to download it. Also please give let me know the CLASSPATH and PATH settings for the same.

Also, this is said on page 63 �

Although they are not required to, it is good practice for stateless session beans to implement all of their business interfaces so that the client/bean contract can be enforced by the Java compiler

What does this mean? What contract?
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

note that annotations require at least java 5.
I suggest you to download it from Sun Microsystems. Then, your CLASSPATH will be the path where you decide to install it. The PATH, instead, will be $CLASSPATH/bin, or %CLASSPATH%\bin, according to the syntax your o.s. accepts.

For what about the second point, you can specify the remote interface, which is your contract, by annotations and/or implementing it. But if you don't implement your interface, but only annotate it, you might make some errors that your compiler would easily avoid.

Example

SB.java:


SBRemoteInterface.java:


In this example, you define an interface(contract) but your session bean does not respect it, so I suppose you would get an error when deploying or using your bean.
Instead, if your bean implements the remote interface, such errors are avoidable at compile time.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean to say, that interfaces having the remote annotations must be implemented by some bean...if not, the compiler will give error.

so, stand alone, unimplemented remote interfaces will give pain

so such interfaces cant be just there for fun..

in short 'if a remote interface exists, it must be implemented be some bean' else... ERROR !!
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well,
I mean that if you annotate a bean with @Remote(YourInterface.class) and you don't implement, directly or indirectly, you might have a lot of pain :-)
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok...let me know if this understanding is correct -

Say my busineess logic needs me to write 3 remote interfaces and 3 beans to handle clients. But amidst all the chaos in the daily life, i forgot to implement one of the interfaces ...and if such a JAR is deployed, a run time error is bound to rock the clients if a client requests some method in the unimplemented bean interface...a runtime error can come.

The container help you by giving a complile time error..and avoids the carnage that can happen at run time.

is it like this ?
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Niranjan Deshpande:
Ok...let me know if this understanding is correct -

Say my busineess logic needs me to write 3 remote interfaces and 3 beans to handle clients. But amidst all the chaos in the daily life, i forgot to implement one of the interfaces ...and if such a JAR is deployed, a run time error is bound to rock the clients if a client requests some method in the unimplemented bean interface...a runtime error can come.

The container help you by giving a complile time error..and avoids the carnage that can happen at run time.

is it like this ?


How you can make jar without compiling the EJB. At the compile time itself it give error that the required interface is not implemented or not found. It is basic java source code compilation. The IDE or java compiler take care of this. The container has no role to compile the EJBs. It only provide container and services to deploy the EJB.

Thanks
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the compile time itself it give error that the required interface is not implemented or not found. It is basic java source code compilation.


Narendra, I was talking about a interface hanging alone, not implemented bu any of the bean. and a case where even if a 3rd bean exists it doesnt implement the interface, exists as a stand alone class, just with usual annotations.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I correct ?
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A session bean can implement its business interface directly (using clause) or indirectly (thru annotations or DD).
When you implement directly and if you miss some/all of the methods in the interface, you will be scolded by the compiler itself(core Java). If you implement indirectly, no way the compiler can know since it is a concrete class with no clause so i think you will be caught by the container when the bean is deployed. There will be no run time exceptions for the client. Hope i am correct clear me frnds if i am wrong.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys I am talking about a dangling Remote interface not implemented by any of my beans.

In such case will the server/container give error -

"Hey you, knock knock, you are trying to deploy a EJB which has a unimplemented remote interface. Don't you think that this will give pain in case the client calls a method on it thinking that, you ahve implemented it?"

So, it will not allow you to deploy it.

Got it now?
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry friends.. this is wrong that there will be no runtime exceptions for the client if the bean doesnt implement its business interface (declared thru annotations or DD) and the container will alert you when the bean is deployed.

Actually i tried executing the first example from oreilly without implementing its business interface (declared thru annotation) methods and my client got

java.lang.RuntimeException: Could not resolve beanClass method from proxy call

so moral of the story:
There will be no deployment time alerts from the container when your bean doesnt implement the methods of its business interface(s) (declared thru annotations or DD). So it will be safe that your bean implements your business interface directly (thru 'implements' clause) since your compiler alerts you at the earlier stage. Thats where the point from Oreilly

Although they are not required to, it is good practice for stateless session beans to implement all of their business interfaces so that the client/bean contract can be enforced by the Java compiler

stands!!. Hope this helps.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
awesome mutthu !! thanks a lot !! i wist i could execute the beans

yet to have the JBoss installed
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic