Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6004701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:18:00+00:00 2026-05-23T01:18:00+00:00

I would like to create an exception handler for the specific case that happens

  • 0

I would like to create an exception handler for the specific case that happens when an EJB client application loses the connection with the application server. The code we are creating is able to handle the client application in user friendly way to try to reconnect to the same server or another server in a fail-over environment. By “losing the connection” I mean anything the requires reconnecting. The cause maybe a network problem, server lock-up, service down, etc.

Here is an idea of what we are looking for (client code):

private void doSomething() throws RecoverableException {
//(...)
BusinessRemoteEJB ejb=ctx.lookup("BusinessRemoteEJB");

try {
    List<product> list=ejb.getProducts();
    //(...)
} catch (EJBException e){
 Exception e = e.getCausedByException();

 //Here is what I'm looking for: some excpetion that indicates a connection problem
 if(e !=null && e instanceof EJBConnectionException){

     //This will be catched in a proper place to try to reconnect
     throw new RecoverableException(e);
 } else {
 //If it is any other excpetion, just let it work up the stack
 throw e;

}

Of course EJBConnectionException doesn’t exist. Is there anything like it?

We are using OpenEJB 1.4 (EJB 3.x compliant). However, we want to use an exception handler that could be used across different application servers if possible.

Another thing is that some application servers provide some kind of fail over mechanisms but our requirements are a little specific and we can implement it directly in the client code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:18:01+00:00Added an answer on May 23, 2026 at 1:18 am

    An @Remote interface that also implements java.rmi.Remote will have it’s exception handling changed slightly. Namely, every method in the interface will be required to declare java.rmi.RemoteException. That will allow the client to receive the connection related issues. In the absence of java.rmi.Remote, the container will convert all such issues to EJBException. There are no requirements beyond it being an EJBException, so relying on the cause or any subclass of EJBException is non-portable.

    @Remote
    public interface OrangeRemote extends java.rmi.Remote {
    
        public void doSomething() throws RemoteException;
    }
    
    @Stateless
    public class OrangeBean implements OrangeRemote {
    
        @Override
        public void doSomething() {
            //...
        }
    }
    

    Note that the bean itself is not required to declare RemoteException in the throws clause. Java lets you declare a subset of the exceptions when implementing an interface and EJB does not change that. Throwing RemoteException from the bean itself would defeat the entire point, so leaving it out is a good idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to handle a ManagementException exception for a specific ErrorCode only and am
Essentially, I'd like a special form of an Interface for Exceptions that requires anyone
I'd like to create a proxy to fprintf , like so: void raise_exception(char *filename,
I am currently developing an application for an angle measurement device (goniometer). A DataGridView
I want create some type of ASP.NET (C# 2.0) Metrics class to help monitor
I have a repository data access pattern like so: IRepository<T> { .. query members
I have a web service in which I have created a custom exception. Let's
This question could easily take multiple paths, so I will hit the more specific
I need to add localization to the exceptions thrown by my application as a
Here is the code that I use to play around with. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.