Implementing a Singleton in EJB

   

Troubleshooting

Method Not Declared to Throw RemoteException

I'm using a business interface for a remote component interface and I get an error during deployment complaining that a method declared in that interface isn't declared to throw RemoteException .

The EJB specification requires that all methods declared in the remote interface of an enterprise bean (and any interfaces extended by the remote) be declared to throw RemoteException . Even if the bean implementation class doesn't throw RemoteException from any of its method implementations , the declarations in the business interface have to include it to make the remote interface valid. The compiler won't catch this error if you forget to do it, but deploying the bean will fail.

Singleton State Lost

I'm using a Singleton class but the state of its attributes is being lost.

Singletons require special consideration in an EJB application, especially those that hold state. Most containers start multiple JVMs resulting in an instance of each Singleton being generated per JVM. If you literally need to limit the number of instances to one, consider implementing the Singleton as a CORBA or RMI object that can be bound in the JNDI namespace for access by clients .



Special Edition Using Enterprise JavaBeans 2.0
Special Edition Using Enterprise JavaBeans 2.0
ISBN: 0789725673
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net