Application Exception using #Application not working - weblogic.developer.interest.webservices.general(Archived)

I'm trying to create 2 business application exception using the #Application annotation on my 2 java exception class. The first exception is a StarException class that extends java.lang.Exception (per ejb 3.0 spec). Below is snippet of the class.
#ApplicationException(rollback=true)
public class StarException extends Exception {...}.
As you can tell that this is a check exception and will rollback transaction when it occurred. I have another exception class called StarRuntimeException that extends java.lang.RuntimeException. This is also mention on ejb 3.0 spec and is useful if you don't want to catch the exception on the server side and just throw it and the client will receive such application exception class. Below is a snippet of the class ...
#ApplicationException(rollback=false)
public class StarRuntimeException extends RuntimeException {...}.
By the way I'm using this exception in my wls 10.3 webservices stateless beans (jax-rpc 1.1). Some of the methods throws these 2 exceptions.
There are 2 problems with this application exception during runtime on the client side.
1. Regarding StarException, the client can catch this exception when the webservice method throws this exception. The problem is that the error messages is null. Tried both getMesssage() and getLocalizedMessage() are all null.
2. Regarding StarRuntimeException, the generated client stubs and artifacts does not even throw this exception, therefore it will not the caught. This exception is wrapped inside RemoteException instead.
Your help are needed. Thanks

Related

EJBComplianceChecker - Spec veryfication level

Hello,
I migrate large app from OAS to Weblogic 10.3.
I have following exceptions during deploy:
method create(java.lang.Long,java.lang.Long) on the local home interface throws java.rmi.RemoteException. Methods on the local home interface must not throw java.rmi.RemoteException
The problem is that all our EJB throws exceptions that are deprecated in ejb spec:
public interface MyBeanLocalHome extends EJBLocalHome {
..
MyBeanLocal create(Long a, Long b) throws Exception, CreateException;
}
From OAS doc:
All create methods may throw the following exceptions:
javax.ejb.CreateException
javax.ejb.RemoteException
optional application exceptions
From Weblogic:
The ejbCreate() method can throw a RuntimeException, javax.ejb.EJBException, or CreateException. The EJB implementation of ejbCreate() must not throw java.rmi.RemoteException, as this is deprecated in the EJB 1.1 specification.
OAS allows to throw Exception type, Weblogic is more strict about that.
My question is there any parameter that change the level of spec veryfication?
For example Jboss has the one:
ejb-deployer.xml:
<!-- Setting this to 'true' will cause all deployments
to fail when the Verifier detected a problem with the contained
Beans. If false, warnings/errors will be logged but the deployment
will not fail.
-->
<attribute name="StrictVerifier">false</attribute>
We consider changing all interfaces/implementation but this is a lot of work. Also we could meet the similar problems in ohter places so that feature could help a lot in fast migration.
Thanks in advance!
Edited by: Stoigniew Sztank on Oct 9, 2008 5:23 AM 
Next EJB compliance checker exception is:
the ejbCreate method ejbCreate(java.lang.String,java.lang.String) has no matching ejbPostCreate method. at weblogic.ejb.container.compliance.EntityBeanClassChecker.doCheckCreatesMatchPostCreates(EntityBeanClassChecker.java:109) at
so skiping this strict veryfication is a must, espacially that migration from OAS to Weblogic is now a common case.
Hope to find something.

nested exception from ejbStore

I am throwing applicaton exceptions (subclasses of RuntimeException) from ejbStore - in case an update to the database fails because a unique constraint was violated. I get a weblogic.transaction.RollbackException back. I tried to use the getNested()method, but my import of the RollbackException class failed in compilation, even though the compilation classpath includes weblogic.jar. Also, I'd prefer not to use a vendor-specific exception if possible. When throwing the same application exceptions from ejbCreate, it was possible to catch a RemoteException and get the nested exception out of it. Thanks for any help!
First, an application exception is hardly a subclass of
RuntimeException. Application exceptions should derive from
java.lang.Exception and for those the container would just throw the
application exception to the caller. If you want to rollback the
transaction you can do so by doing EjbContext.setRollbackOnly() and then
throw the exception.
Having said that you should still be able to extract the underlying
exception from the javax.transaction.TransactionRolledbackException the
container throws (I haven't heard of
weblogic.transaction.RollbackException and even if such exists it should
be a subclass of TransactionRolledbackException) by doing exception.detail .
I've had some problems in 6.0 as in some cases it does not include the
underlying exception but in 6.1 and probably in 7.0 (haven't used it a
lot) it work fine.
Regards,
Dejan
Paul Bennett wrote:
I am throwing applicaton exceptions (subclasses of RuntimeException) from ejbStore - in case an update to the database fails because a unique constraint was violated. I get a weblogic.transaction.RollbackException back. I tried to use the getNested()method, but my import of the RollbackException class failed in compilation, even though the compilation classpath includes weblogic.jar. Also, I'd prefer not to use a vendor-specific exception if possible. When throwing the same application exceptions from ejbCreate, it was possible to catch a RemoteException and get the nested exception out of it. Thanks for any help!

multiple custom exceptions

I am using wls 8.1 sp1. I have the following problem dealing with custom exception:
say, I have a method :
public boolean a() throws Exception1, Exception2
where Exception 1 and 2 are custom exceptions and they both extend from Exception.
This is what happened in my application:
when Exception1 is thrown, things are OK. However, when exception2 is thrown from the web service, on the client side, it received Exception1 instead (with Exception2 wrapped inside the SOAPFault object, I can see that thru the dubugger). The client always sees the first custom exception only. Does anyone have this problem before?

Wrong posting

I'm trying to create 2 business application exception using the #Application annotation on my 2 java exception class. The first exception is a StarException class that extends java.lang.Exception (per ejb 3.0 spec). Below is snippet of the class.
#ApplicationException(rollback=true)
public class StarException extends Exception {...}.
As you can tell that this is a check exception and will rollback transaction when it occurred. I have another exception class called StarRuntimeException that extends java.lang.RuntimeException. This is also mention on ejb 3.0 spec and is useful if you don't want to catch the exception on the server side and just throw it and the client will receive such application exception class. Below is a snippet of the class ...
#ApplicationException(rollback=false)
public class StarRuntimeException extends RuntimeException {...}.
By the way I'm using this exception in my wls 10.3 webservices stateless beans (jax-rpc 1.1). Some of the methods throws these 2 exceptions.
There are 2 problems with this application exception during runtime on the client side.
1. Regarding StarException, the client can catch this exception when the webservice method throws this exception. The problem is that the error messages is null. Tried both getMesssage() and getLocalizedMessage() are all null.
2. Regarding StarRuntimeException, the generated client stubs and artifacts does not even throw this exception, therefore it will not the caught. This exception is wrapped inside RemoteException instead.
Your help are needed. Thanks
--
Edited by junvictorio at 04/08/2008 11:41 AM

Undocumented weblogic.ejb20.internal.MethodPermissionException?

Environment: Weblogic 6.0 sp2 w/ ejb20.jar.
We are experimenting with security and noticed that if a client to an ejb
(session bean in our case) attempts to make a method call that they do not
have permission for (due to the descriptor .xml file roles), the exception
that is thrown on the client is this very proprietary sounding and
undocumented exception:
weblogic.ejb20.internal.MethodPermissionException
Using reflection we can see that this exception class has this lineage:
weblogic.ejb20.internal.MethodPermissionException
java.rmi.RemoteException
java.io.IOException
java.lang.Exception
java.lang.Throwable
java.lang.Object
Can you provide any more info on this? Ideally I'd like to be able to
distinguish between the very generic RemoteException, but not code such
undocumented exception names into my files (i.e. it sounds like the name of
this "internal" exception could easily change with a service pack or
something and then we'd be hosed).
Thanks,
- John Freeborg

Categories

Resources