문제

This is a weird situation. Let me explain it as best as I can.

I have an interface Client which has methods which throw a Custom Exception. My EJB3 Remote extends this interface Client and was annotated @Remote. My EJB3 Bean used to extend the Remote and was annotated @Stateless .

Now comes the weirdness. Due to a very specific issue I cannot deploy any EJB3 jars on my app server. (The question is not how I resolve this deploy issue.)

Now I have to downgrade the code from EJB3 to EJB2. Since all the methods in my Remote Interface have to throw a RemoteException (EJB2 Spec) , I cannot extend from my Client Interface any more.

The option that I am left with is creating a EJB2Wrapper, which can extend from the Client interface and in each method I call into the Remote Interface.

This creates the ugly try catch block for each method, since I have to catch the RemoteException.

Is there a better way to do this?

도움이 되었습니까?

해결책 2

Answering my own question to close the loop.

There is no better way to do this as of now.

다른 팁

I would say that you would not be having such a big problem if the functionality in your beans started life as a POJO. If you have that, you could simply deploy as EJB3, EJB2, servlet, web service, or anything else you wanted.

Perhaps the best solution is to extract the good from the EJB3 as a POJO and defer deployment choices until the end. I would prefer this solution to the EJB2Wrapper. You already have to do some work; best to invest in something that will have value even if you decide to go with REST web services instead of EJBs in the future.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top