dev@glassfish.java.net

java.lang.IllegalStateException: Keystore was tampered with, or password was incorrect

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Mon, 27 Nov 2006 14:51:24 -0500

Can someone please help Antonio with this problem? Thanks.

-cheng
----------------------------
Hmmm, I've installed the lastest night build and use my good old script
to create my domain (this script has worked since b13). When I want to
start it I have the following exception. Has something changed in the
way to create a new domain ? I use the following command :
 
asadmin create-domain --adminport 8282 --adminuser admin
--savemasterpassword=true --instanceport 8080 petstore
 
 
 
[#|2006-11-27T20:32:17.640+0100|WARNING|sun-appserver-ee9.1|javax.enterprise.system.stream.err|_ThreadID=10;_ThreadName=main;_RequestID=a3953086-72b0-4a69-a9e3-9c75f2e49d9f;|java.lang.reflect.InvocationTargetException

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java
:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at com.sun.enterprise.server.PELaunch.main(PELaunch.java:272)
Caused by: java.lang.ExceptionInInitializerError
 at com.sun.enterprise.security.SecurityLifecycle.onInitialization
(SecurityLifecycle.java:89)
 at
com.sun.enterprise.server.ApplicationServer.onInitialization(ApplicationServer.java:240)
 at
com.sun.enterprise.server.ondemand.OnDemandServer.onInitialization(OnDemandServer.java:93)

 at com.sun.enterprise.server.PEMain.run(PEMain.java:316)
 at com.sun.enterprise.server.PEMain.main(PEMain.java:260)
 ... 5 more
Caused by: java.lang.IllegalStateException: Keystore was tampered with,
or password was incorrect
 at
com.sun.enterprise.security.SecuritySupportImpl.loadStores(SecuritySupportImpl.java:104)
 at
com.sun.enterprise.security.SecuritySupportImpl.initJKS(SecuritySupportImpl.java:72)
 at com.sun.enterprise.security.SecuritySupportImpl
.<init>(SecuritySupportImpl.java:66)
 at
com.sun.enterprise.security.SecuritySupportImpl.<init>(SecuritySupportImpl.java:61)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
 at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
 at java.lang.reflect.Constructor.newInstance (Constructor.java:494)
 at java.lang.Class.newInstance0(Class.java:350)
 at java.lang.Class.newInstance(Class.java:303)
 at
com.sun.enterprise.pluggable.PluggableFeatureFactoryBaseImpl.invoke(PluggableFeatureFactoryBaseImpl.java
:71)
 at $Proxy0.getSecuritySupport(Unknown Source)
 at
com.sun.enterprise.security.SecurityUtil.getSecuritySupport(SecurityUtil.java:354)
 at com.sun.enterprise.security.SSLUtils.<clinit>(SSLUtils.java:86)
 ... 10 more

attached mail follows:



Hmmm, I've installed the lastest night build and use my good old script to
create my domain (this script has worked since b13). When I want to start it
I have the following exception. Has something changed in the way to create a
new domain ? I use the following command :

asadmin create-domain --adminport 8282 --adminuser admin
--savemasterpassword=true --instanceport 8080 petstore



[#|2006-11-27T20:32:
17.640+0100|WARNING|sun-appserver-ee9.1|javax.enterprise.system.stream.err|_ThreadID=10
;_ThreadName=main;_RequestID=a3953086-72b0-4a69-a9e3-9c75f2e49d9f;|java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at com.sun.enterprise.server.PELaunch.main(PELaunch.java:272)
Caused by: java.lang.ExceptionInInitializerError
 at com.sun.enterprise.security.SecurityLifecycle.onInitialization(
SecurityLifecycle.java:89)
 at com.sun.enterprise.server.ApplicationServer.onInitialization(
ApplicationServer.java:240)
 at com.sun.enterprise.server.ondemand.OnDemandServer.onInitialization(
OnDemandServer.java:93)
 at com.sun.enterprise.server.PEMain.run(PEMain.java:316)
 at com.sun.enterprise.server.PEMain.main(PEMain.java:260)
 ... 5 more
Caused by: java.lang.IllegalStateException: Keystore was tampered with, or
password was incorrect
 at com.sun.enterprise.security.SecuritySupportImpl.loadStores(
SecuritySupportImpl.java:104)
 at com.sun.enterprise.security.SecuritySupportImpl.initJKS(
SecuritySupportImpl.java:72)
 at com.sun.enterprise.security.SecuritySupportImpl.<init>(
SecuritySupportImpl.java:66)
 at com.sun.enterprise.security.SecuritySupportImpl.<init>(
SecuritySupportImpl.java:61)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(
NativeConstructorAccessorImpl.java:39)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
DelegatingConstructorAccessorImpl.java:27)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
 at java.lang.Class.newInstance0(Class.java:350)
 at java.lang.Class.newInstance(Class.java:303)
 at com.sun.enterprise.pluggable.PluggableFeatureFactoryBaseImpl.invoke(
PluggableFeatureFactoryBaseImpl.java:71)
 at $Proxy0.getSecuritySupport(Unknown Source)
 at com.sun.enterprise.security.SecurityUtil.getSecuritySupport(
SecurityUtil.java:354)
 at com.sun.enterprise.security.SSLUtils.<clinit>(SSLUtils.java:86)
 ... 10 more



2006/11/27, Cheng Fang <Cheng.Fang_at_sun.com>:
>
> Hi Antonio,
>
> From https://glassfish.dev.java.net/public/downloadsindex.html, V2b24
> was built on Nov 1, 2006.
>
> The fix for glassfish issue 1359 was committed on Nov 10, 2006.
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=1359
> (EJBException is not properly initialized)
>
> So the fix was not in V2B24. Can you try a recent nightly build? If
> you still see this problem, feel free to reopen the issue with
> additional details and tests.
>
> -cheng
>
> Antonio Goncalves wrote:
> > Hi,
> >
> > I'm using V2b24 but I've also tried with b19 and even b13 just to be
> sure.
> >
> > I've tried ejbException.getCause but it returns null, and here is the
> > stack trace of ejbException.getCausedByException. As you can see, my
> > ValidationException has vanished from the stacktrace.
> >
> >
> > java.rmi.ServerException: RemoteException occurred in server thread;
> > nested exception is:
> > java.rmi.RemoteException
> > at
> > com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java
> :196)
> > at
> >
> com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke
> > (StubInvocationHandlerImpl.java:176)
> > at
> > com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(
> StubInvocationHandlerImpl.java:123)
> > at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke
> > (BCELStubBase.java:197)
> > at
> >
> com.yaps.petstore.stateless.catalog.__CatalogRemote_Remote_DynamicStub.createCategory
> (__CatalogRemote_Remote_DynamicStub.java)
> > at
> >
> com.yaps.petstore.stateless.catalog._CatalogRemote_Wrapper.createCategory
> > (com.yaps.petstore.stateless.catalog._CatalogRemote_Wrapper.java)
> > at
> > com.yaps.petstore.client.delegate.CatalogDelegate.createCategory(
> CatalogDelegate.java:24)
> > at
> >
> com.yaps.petstore.client.ui.catalog.category.CategoryCrudFrame.createActionPerformed
> > (CategoryCrudFrame.java:79)
> > at
> > com.yaps.petstore.client.ui.util.YapsActionPane.fireActionPerformed(
> YapsActionPane.java:192)
> > at
> > com.yaps.petstore.client.ui.util.YapsActionPane.access$000(
> YapsActionPane.java:23)
> > at
> > com.yaps.petstore.client.ui.util.YapsActionPane$2.actionPerformed(
> YapsActionPane.java:106)
> > at
> > javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
> > at javax.swing.AbstractButton$Handler.actionPerformed
> > (AbstractButton.java:2169)
> > at
> > javax.swing.DefaultButtonModel.fireActionPerformed(
> DefaultButtonModel.java:420)
> > at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java
> :258)
> > at javax.swing.plaf.basic.BasicButtonListener.mouseReleased
> > (BasicButtonListener.java:236)
> > at java.awt.Component.processMouseEvent(Component.java:5488)
> > at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
> > at java.awt.Component.processEvent(Component.java:5253)
> > at java.awt.Container.processEvent(Container.java:1966)
> > at java.awt.Component.dispatchEventImpl(Component.java:3955)
> > at java.awt.Container.dispatchEventImpl(Container.java:2024)
> > at java.awt.Component.dispatchEvent (Component.java:3803)
> > at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java
> :4212)
> > at java.awt.LightweightDispatcher.processMouseEvent(Container.java
> :3892)
> > at java.awt.LightweightDispatcher.dispatchEvent (Container.java:3822)
> > at java.awt.Container.dispatchEventImpl(Container.java:2010)
> > at java.awt.Window.dispatchEventImpl(Window.java:1778)
> > at java.awt.Component.dispatchEvent(Component.java:3803)
> > at java.awt.EventQueue.dispatchEvent (EventQueue.java:463)
> > at
> > java.awt.EventDispatchThread.pumpOneEventForHierarchy(
> EventDispatchThread.java:242)
> > at
> > java.awt.EventDispatchThread.pumpEventsForHierarchy(
> EventDispatchThread.java:163)
> > at java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java
> :157)
> > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java
> :149)
> > at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
> > Caused by: java.rmi.RemoteException
> > at
> > com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java
> :234)
> > at
> > com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1303)
> > at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(
> > EJBObjectInvocationHandler.java:197)
> > at
> > com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(
> EJBObjectInvocationHandlerDelegate.java:110)
> > at $Proxy77.createCategory(Unknown Source)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
> > at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> > at java.lang.reflect.Method.invoke (Method.java:585)
> > at
> > com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(
> ReflectiveTie.java:125)
> > at
> >
> com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant
> (CorbaServerRequestDispatcherImpl.java
> > :650)
> > at
> > com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch
> (CorbaServerRequestDispatcherImpl.java:193)
> > at
> >
> com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest
> (CorbaMessageMediatorImpl.java
> > :1711)
> > at
> > com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(
> CorbaMessageMediatorImpl.java:1571)
> > at
> > com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(
> CorbaMessageMediatorImpl.java
> > :953)
> > at
> >
> com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback
> (RequestMessage_1_2.java:182)
> > at
> > com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(
> CorbaMessageMediatorImpl.java
> > :723)
> > at
> > com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(
> SocketOrChannelConnectionImpl.java:480)
> > at
> > com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(
> SocketOrChannelConnectionImpl.java
> > :1356)
> > at
> > com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run
> (ThreadPoolImpl.java:467)
> >
> >
> > 2006/11/27, Cheng Fang <Cheng.Fang_at_sun.com <mailto:Cheng.Fang_at_sun.com>>:
> >
> > Hi Antonio,
> >
> > In your Swing client, can you try
> >
> > ejbException.|* getCausedByException
> > <
> http://java.sun.com/javaee/5/docs/api/javax/ejb/EJBException.html#getCausedByException%28%29
> >*(),
> > and ejbException.getCause()? At least one of them should return
> > the root cause.
> >
> > -cheng
> > |
> >
> > Antonio Goncalves wrote:
> >> Hi,
> >>
> >> Sorry for bringing back an old thread, but I have some issues
> >> with that.
> >>
> >> The problem is that during a call back method of my entity bean I
> >> throw an application exception. This exception is wrapped into an
> >> EJBException by the container. What I've done is that I take this
> >> EJBException and get the root cause. If it's an instance of my
> >> ValidationException, I display its message. It works fine with
> >> JSF and I can display an "invalide name" (for example) in my web
> >> page.
> >>
> >> But when I try to do the same with a swing application, it
> >> doesn't work. The problem is that the Swing app gets the
> >> EJBException but with no root cause. When I call the methode
> >> e.getCause() it returns null. It looks like my
> >> ValidationException is not wrapped into the EJBException when
> >> leaving the container.
> >>
> >> Does anybody have an idea ?
> >>
> >> Thanks,
> >>
> >> Antonio
> >>
> >>
> >> 2006/10/2, Antonio Goncalves <antonio.mailing_at_gmail.com
> >> <mailto:antonio.mailing_at_gmail.com>>:
> >>
> >> > Also note that even if the ValidationException were to be
> >> propagated as
> >> > is, the persistence manager still would not know it is an
> >> EJB "Application Exception"
> >> > so any required behavior such as marking the transaction for
> >> rollback would still be
> >> > performed by the persistence manager regardless of the
> >> attributes of the
> >> > @ApplicationException definition.
> >>
> >> That makes sense. I going to try a similar use case outside
> >> the container to see what king of exception is thrown. I've
> >> changed my ValidationException to extend Exception instead of
> >> RuntimeException, but it doesn't work either. The exception
> >> is still wrapped into an EJBException and the root cause is
> >> event worse *Caused by: java.lang.ClassCastException:
> >> com.yaps.petstore.exception.ValidationException *.
> >>
> >>
> >> javax.ejb.EJBException
> >> at
> >> com.sun.ejb.containers.BaseContainer.processSystemException(
> BaseContainer.java:3753)
> >> at
> >> com.sun.ejb.containers.BaseContainer.completeNewTx(
> BaseContainer.java:3653)
> >> at com.sun.ejb.containers.BaseContainer.postInvokeTx
> >> (BaseContainer.java:3455)
> >> at
> >> com.sun.ejb.containers.BaseContainer.postInvoke(
> BaseContainer.java:1257)
> >> at
> >> com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke
> >> (EJBLocalObjectInvocationHandler.java:192)
> >> at
> >>
> com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(
> EJBLocalObjectInvocationHandlerDelegate.java:118)
> >> at $Proxy69.createCustomer(Unknown Source)
> >>
> >> at
> >> com.yaps.petstore.web.jsf.AccountController.doCreateCustomer
> >> (Unknown Source)
> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> at sun.reflect.NativeMethodAccessorImpl.invoke
> >> (NativeMethodAccessorImpl.java :39)
> >> at sun.reflect.DelegatingMethodAccessorImpl.invoke
> >> (DelegatingMethodAccessorImpl.java:25)
> >> at java.lang.reflect.Method.invoke(Method.java:585)
> >> at com.sun.el.parser.AstValue.invoke (AstValue.java:157)
> >> at
> >> com.sun.el.MethodExpressionImpl.invoke(
> MethodExpressionImpl.java
> >> :283)
> >> at
> >>
> javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(
> MethodBindingMethodExpressionAdapter.java:71)
> >> at
> >> com.sun.faces.application.ActionListenerImpl.processAction
> >> (ActionListenerImpl.java:96)
> >> at javax.faces.component.UICommand.broadcast(UICommand.java
> :383)
> >> at
> >> javax.faces.component.UIViewRoot.broadcastEvents(
> UIViewRoot.java
> >> :471)
> >> at javax.faces.component.UIViewRoot.processApplication
> >> (UIViewRoot.java:783)
> >> at
> >> com.sun.faces.lifecycle.InvokeApplicationPhase.execute(
> InvokeApplicationPhase.java:97)
> >> at com.sun.faces.lifecycle.LifecycleImpl.phase
> >> (LifecycleImpl.java:244)
> >> at com.sun.faces.lifecycle.LifecycleImpl.execute
> >> (LifecycleImpl.java:113)
> >> at
> >> javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
> >> at
> >> org.apache.catalina.core.ApplicationFilterChain.servletService
> >> (ApplicationFilterChain.java:397)
> >> at org.apache.catalina.core.StandardWrapperValve.invoke
> >> (StandardWrapperValve.java:278)
> >> at
> >> org.apache.catalina.core.StandardPipeline.doInvoke(
> StandardPipeline.java:586)
> >> at org.apache.catalina.core.StandardPipeline.invoke
> >> (StandardPipeline.java:556)
> >> at
> >> org.apache.catalina.core.StandardContextValve.invokeInternal
> >> (StandardContextValve.java:246)
> >> at
> >> org.apache.catalina.core.StandardContextValve.invoke(
> StandardContextValve.java:185)
> >> at
> >> org.apache.catalina.core.StandardPipeline.doInvoke(
> StandardPipeline.java:586)
> >> at com.sun.enterprise.web.WebPipeline.invoke
> >> (WebPipeline.java:73)
> >> at
> >> org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java
> >> :182)
> >> at
> >> org.apache.catalina.core.StandardPipeline.doInvoke(
> StandardPipeline.java:586)
> >> at com.sun.enterprise.web.VirtualServerPipeline.invoke
> >> (VirtualServerPipeline.java:120)
> >> at org.apache.catalina.core.ContainerBase.invoke
> >> (ContainerBase.java:939)
> >> at
> >> org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:137)
> >> at org.apache.catalina.core.StandardPipeline.doInvoke
> >> (StandardPipeline.java:586)
> >> at org.apache.catalina.core.StandardPipeline.invoke
> >> (StandardPipeline.java:556)
> >> at
> >> org.apache.catalina.core.ContainerBase.invoke(
> ContainerBase.java:939)
> >> at org.apache.coyote.tomcat5.CoyoteAdapter.service
> >> (CoyoteAdapter.java:231)
> >> at
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter
> >> (DefaultProcessorTask.java:619)
> >> at
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.processNonBlocked
> >> (DefaultProcessorTask.java:550)
> >> at
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process
> >> (DefaultProcessorTask.java:780)
> >> at
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask
> >> (DefaultReadTask.java:326)
> >> at
> >> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask
> (DefaultReadTask.java
> >> :251)
> >> at
> >> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask
> (DefaultReadTask.java:205)
> >>
> >> at
> >> com.sun.enterprise.web.connector.grizzly.TaskBase.run(
> TaskBase.java:252)
> >> at
> >> com.sun.enterprise.web.connector.grizzly.WorkerThreadImpl.run
> >> (WorkerThreadImpl.java:103)
> >> *Caused by: java.lang.ClassCastException :
> >> com.yaps.petstore.exception.ValidationException*
> >> at
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.metadata.listeners.MetadataEntityListener.invokeMethod
> >> (MetadataEntityListener.java:313)
> >> at
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.metadata.listeners.MetadataEntityClassListener.invokeMethod
> >> (MetadataEntityClassListener.java:69)
> >> at
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.metadata.listeners.MetadataEntityListener
> >> .prePersist(MetadataEntityListener.java:439)
> >> at
> >>
> oracle.toplink.essentials.descriptors.DescriptorEventManager.notifyListener
> >> (DescriptorEventManager.java:658)
> >> at
> >>
> oracle.toplink.essentials.descriptors.DescriptorEventManager.notifyEJB30Listeners
> >> (DescriptorEventManager.java:601)
> >> at
> >>
> oracle.toplink.essentials.descriptors.DescriptorEventManager.executeEvent
> >> (DescriptorEventManager.java:199)
> >> at
> >>
> oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist
> >> (UnitOfWorkImpl.java:3226)
> >> at
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist
> >> (RepeatableWriteUnitOfWork.java:298)
> >> at
> >>
> oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist
> >> (UnitOfWorkImpl.java:3186)
> >> at
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist
> >> (EntityManagerImpl.java:170)
> >> at
> >> com.sun.enterprise.util.EntityManagerWrapper.persist(
> EntityManagerWrapper.java
> >> :433)
> >> at
> >> com.yaps.petstore.service.customer.CustomerBean.createCustomer
> (Unknown
> >> Source)
> >> at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native
> Method)
> >> at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java
> >> :39)
> >> at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> >> at java.lang.reflect.Method.invoke (Method.java:585)
> >> at
> >>
> com.sun.enterprise.security.application.EJBSecurityManager.runMethod
> >> (EJBSecurityManager.java:1050)
> >> at
> >> com.sun.enterprise.security.SecurityUtil.invoke(
> SecurityUtil.java:165)
> >> at
> >> com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod
> >> (BaseContainer.java:2788)
> >> at com.sun.ejb.containers.BaseContainer.intercept
> >> (BaseContainer.java:3870)
> >> at
> >> com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(
> EJBLocalObjectInvocationHandler.java:184)
> >> ... 43 more
> >>
> >>
> >>
> >> 2006/10/2, Kenneth Saks <Kenneth.Saks_at_sun.com
> >> <mailto:Kenneth.Saks_at_sun.com>>:
> >>
> >> Cheng Fang wrote:
> >>
> >> > Our tests for the similar scenario passed. The only
> >> difference
> >> > between our tests and your is, your ValidationException
> >> is from Entity
> >> > lifecycle callback methods, and our unchecked
> >> ApplicationException is
> >> > from a regular slsb business methods.
> >> > JPA spec says entity lifecycle callback methods may throw
> >> > runtime/uncheckec exception, which causes the current
> >> transaction to
> >> > be rolled back. So your unchecked ApplicationException
> >> behaves more
> >> > like a system exception. EJB interceptor methods are
> >> more restrictive
> >> > in that it does not allow any application exception.
> >>
> >> That's true of callbacks defined in an interceptor class,
> >> but not true
> >> of AroundInvoke methods.
> >> The signature of an AroundInvoke method is defined to throw
> >> java.lang.Exception so that it may
> >> propagate any application-defined exceptions that appear
> >> in the
> >> corresponding business
> >> method's signature.
> >>
> >> >
> >> >
> >> > Throwing such runtime exception from @PrePersist seems a
> >> pretty common
> >> > use case. The JPA spec has such an example. Can
> >> someone clarify?
> >>
> >> I'm not aware of any requirements in the persistence spec
> >> that guarantee
> >> that an exception thrown
> >> by the entity code will propagate *as is* back to the
> >> caller of an
> >> EntityManager API. The EntityManager
> >> API is typed to throw certain specific runtime
> >> exceptions. The
> >> @ApplicationException behavior
> >> is EJB-container specific, so the persistence manager
> >> doesn't know
> >> anything about it. The persistence
> >> manager is probably just wrapping the ValidationException
> >> into one of
> >> the exceptions defined in
> >> the persist() API method signature. The ejb container
> >> then sees a
> >> runtime exception, not an
> >> Application Exception.
> >>
> >> Also note that even if the ValidationException were to be
> >> propagated as
> >> is, the persistence
> >> manager still would not know it is an EJB "Application
> >> Exception" so any
> >> required behavior
> >> such as marking the transaction for rollback would still
> >> be performed by
> >> the persistence
> >> manager regardless of the attributes of the
> >> @ApplicationException
> >> definition.
> >>
> >> --ken
> >>
> >> >
> >> >
> >> > Cheng
> >> >
> >> >
> >> >
> >> >
> >> > Antonio Goncalves wrote:
> >> >
> >> >> Hi,
> >> >>
> >> >> I've got a JSF back bean trying to catch my application
> >> exception but
> >> >> ends up with an EJBException. Here is my model :
> >> >>
> >> >> * A Customer entity bean throws an Application
> >> Exception in a call
> >> >> back method to validate its data
> >> >>
> >> >> @Entity
> >> >> public class Customer implements Serializable {
> >> >>
> >> >> @PrePersist
> >> >> @PreUpdate
> >> >> private void validateData() {
> >> >> if (firstname == null || "".equals(firstname))
> >> >> throw new *ValidationException*("Invalid
> >> first name");
> >> >> if (lastname == null || "".equals(lastname))
> >> >> throw new ValidationException("Invalid last
> >> name");
> >> >> }
> >> >> }
> >> >>
> >> >> * The Validation Exception is a RuntimeException but
> >> uses the
> >> >> ApplicationException annotation
> >> >>
> >> >> @*ApplicationException*(rollback = true)
> >> >> public class *ValidationException* extends
> >> *RuntimeException* {
> >> >>
> >> >> }
> >> >>
> >> >> * Between the Entity and JSF there is a Stateless bean
> >> that
> >> >> manipulates this entity but doesn't wrap or throw an
> >> exception
> >> >>
> >> >> @Stateless
> >> >> public class CustomerBean implements CustomerRemote,
> >> CustomerLocal {
> >> >>
> >> >> @PersistenceContext(name = "petstorePU")
> >> >> private EntityManager em;
> >> >>
> >> >> public Customer createCustomer(final Customer
> >> customer) {
> >> >> em.persist(*customer*);
> >> >> }
> >> >>
> >> >> }
> >> >>
> >> >> * My JSF Back Bean calls the Stateless to create a
> >> customer. He tries
> >> >> to catch the ValidationException and display the error
> >> message on my
> >> >> page
> >> >>
> >> >> public String doCreateCustomer() {
> >> >>
> >> >> FacesContext context =
> >> FacesContext.getCurrentInstance();
> >> >> String navigateTo = null;
> >> >>
> >> >> try {
> >> >> customer = customerBean.createCustomer
> >> (customer, address);
> >> >> } *catch (ValidationException e)* {
> >> >> context.addMessage(null, new
> >> >> FacesMessage(FacesMessage.SEVERITY_WARN ,
> >> e.getMessage(), null));
> >> >> }
> >> >>
> >> >> If I change the catch (ValidationException e) into catch
> >> >> (EJBException e) it woks because here is my stack trace
> >> on the server
> >> >>
> >> >> *javax.ejb.EJBException*
> >> >> at
> >> >>
> >> com.sun.ejb.containers.BaseContainer.processSystemException
> (BaseContainer.java:3753)
> >> >>
> >> >> at
> >> >>
> >> com.sun.ejb.containers.BaseContainer.completeNewTx(
> BaseContainer.java:3653)
> >> >>
> >> >> at
> >> >>
> >> com.sun.ejb.containers.BaseContainer.postInvokeTx(
> BaseContainer.java:3455)
> >> >>
> >> >> at
> >> >>
> >> com.sun.ejb.containers.BaseContainer.postInvoke(
> BaseContainer.java:1257)
> >> >> at
> >>
> com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke
> >> >> (EJBLocalObjectInvocationHandler.java:192)
> >> >> at
> >> >>
> >>
> com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(
> EJBLocalObjectInvocationHandlerDelegate.java
> >> :118)
> >> >>
> >> >> at $Proxy163.createCustomer(Unknown Source)
> >> >> at
> >> >>
> >>
> com.yaps.petstore.web.jsf.AccountController.doCreateCustomer(Unknown
> >> >> Source)
> >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0
> >> (Native Method)
> >> >> at
> >> >>
> >> sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java
> >> >> :39)
> >> >> at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java
> >> :25)
> >> >>
> >> >> at java.lang.reflect.Method.invoke(Method.java:585)
> >> >> at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
> >> >> at
> >> >>
> >> com.sun.el.MethodExpressionImpl.invoke(
> MethodExpressionImpl.java
> >> :283)
> >> >> at
> >> >>
> >>
> javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(
> MethodBindingMethodExpressionAdapter.java:71)
> >> >>
> >> >> at
> >> com.sun.faces.application.ActionListenerImpl.processAction
> >> >> (ActionListenerImpl.java:96)
> >> >> at
> >> javax.faces.component.UICommand.broadcast(UICommand.java
> :383)
> >> >> at
> >> >>
> >> javax.faces.component.UIViewRoot.broadcastEvents(
> UIViewRoot.java:471)
> >> >> at javax.faces.component.UIViewRoot.processApplication
> >> >> (UIViewRoot.java:783)
> >> >> at
> >> >>
> >> com.sun.faces.lifecycle.InvokeApplicationPhase.execute(
> InvokeApplicationPhase.java:97)
> >> >>
> >> >> at
> >> com.sun.faces.lifecycle.LifecycleImpl.phase(
> LifecycleImpl.java:244)
> >> >> at com.sun.faces.lifecycle.LifecycleImpl.execute
> >> >> (LifecycleImpl.java:113)
> >> >> at javax.faces.webapp.FacesServlet.service
> >> (FacesServlet.java:244)
> >> >> at
> >> >>
> >>
> org.apache.catalina.core.ApplicationFilterChain.servletService(
> ApplicationFilterChain.java:397)
> >> >>
> >> >> at org.apache.catalina.core.StandardWrapperValve.invoke
> >> >> (StandardWrapperValve.java:278)
> >> >> at
> >> >>
> >> org.apache.catalina.core.StandardPipeline.doInvoke(
> StandardPipeline.java:586)
> >> >>
> >> >> at
> >> >> org.apache.catalina.core.StandardPipeline.invoke
> >> (StandardPipeline.java:556)
> >> >>
> >> >> at
> >>
> org.apache.catalina.core.StandardContextValve.invokeInternal
> >> >> (StandardContextValve.java:246)
> >> >> at
> >> >> org.apache.catalina.core.StandardContextValve.invoke
> >> (StandardContextValve.java:185)
> >> >>
> >> >> at
> >> >>
> >> org.apache.catalina.core.StandardPipeline.doInvoke(
> StandardPipeline.java:586)
> >> >>
> >> >> at com.sun.enterprise.web.WebPipeline.invoke (
> >> WebPipeline.java:73)
> >> >> at
> >> >>
> >> org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java:182)
> >> >>
> >> >> at
> >> >>
> >> org.apache.catalina.core.StandardPipeline.doInvoke(
> StandardPipeline.java
> >> :586)
> >> >>
> >> >> at com.sun.enterprise.web.VirtualServerPipeline.invoke
> >> >> (VirtualServerPipeline.java:120)
> >> >> at
> >> >>
> >> org.apache.catalina.core.ContainerBase.invoke(
> ContainerBase.java
> >> :939)
> >> >> at
> >> >>
> >> org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:137)
> >> >>
> >> >> at org.apache.catalina.core.StandardPipeline.doInvoke
> >> >> (StandardPipeline.java :586)
> >> >> at
> >> >>
> >> org.apache.catalina.core.StandardPipeline.invoke(
> StandardPipeline.java:556)
> >> >>
> >> >> at
> >> >>
> >> org.apache.catalina.core.ContainerBase.invoke(
> ContainerBase.java:939)
> >> >> at org.apache.coyote.tomcat5.CoyoteAdapter.service
> >> >> (CoyoteAdapter.java:231)
> >> >> at
> >> >>
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter
> (DefaultProcessorTask.java
> >> :619)
> >> >>
> >> >> at
> >> >>
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.processNonBlocked
> >> >> (DefaultProcessorTask.java:550)
> >> >> at
> >> >>
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process
> >> (DefaultProcessorTask.java:780)
> >> >>
> >> >> at
> >> >>
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask
> >> >> (DefaultReadTask.java:326)
> >> >> at
> >> >>
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask
> >> (DefaultReadTask.java:251)
> >> >>
> >> >> at
> >> >>
> >>
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(
> DefaultReadTask.java:205)
> >> >>
> >> >> at
> >> >> com.sun.enterprise.web.connector.grizzly.TaskBase.run
> >> (TaskBase.java:252)
> >> >> at
> >> >>
> >>
> com.sun.enterprise.web.connector.grizzly.WorkerThreadImpl.run(
> WorkerThreadImpl.java:103)
> >> >>
> >> >> Caused by: com.yaps.petstore.exception.*
> >> ValidationException*:
> >> >> Invalid first name
> >> >> at
> >> com.yaps.petstore.domain.customer.Customer.validateData
> (Unknown
> >> >> Source)
> >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> >> Method)
> >> >> at sun.reflect.NativeMethodAccessorImpl.invoke
> >> >> (NativeMethodAccessorImpl.java:39)
> >> >> at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> >> >>
> >> >> at java.lang.reflect.Method.invoke(Method.java:585)
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.internal.security.PrivilegedAccessHelper.invokeMethod
> >> >> (PrivilegedAccessHelper.java:307)
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.metadata.listeners.MetadataEntityListener.invokeMethod
> (MetadataEntityListener.java:302)
> >> >>
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.metadata.listeners.MetadataEntityClassListener.invokeMethod
> >>
> >> >> (MetadataEntityClassListener.java:69)
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.metadata.listeners.MetadataEntityListener.prePersist
> (MetadataEntityListener.java:439)
> >> >>
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.descriptors.DescriptorEventManager.notifyListener
> >> >> (DescriptorEventManager.java:658)
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.descriptors.DescriptorEventManager.notifyEJB30Listeners
> >> (DescriptorEventManager.java:601)
> >> >>
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.descriptors.DescriptorEventManager.executeEvent
> >> >> (DescriptorEventManager.java:199)
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist
> (UnitOfWorkImpl.java:3226)
> >> >>
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist
> >>
> >> >> (RepeatableWriteUnitOfWork.java:298)
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist
> (UnitOfWorkImpl.java:3186)
> >> >>
> >> >> at
> >> >>
> >>
> oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist
> >> >> (EntityManagerImpl.java:170)
> >> >> at
> >> >>
> >> com.sun.enterprise.util.EntityManagerWrapper.persist(
> EntityManagerWrapper.java
> >> :433)
> >> >>
> >> >> at
> >> >>
> >>
> com.yaps.petstore.service.customer.CustomerBean.createCustomer(Unknown
> >> >> Source)
> >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0
> >> (Native Method)
> >> >> at
> >> >>
> >> sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
> >> >>
> >> >> at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> >> >>
> >> >> at java.lang.reflect.Method.invoke (Method.java:585)
> >> >> at
> >> >>
> >>
> com.sun.enterprise.security.application.EJBSecurityManager.runMethod(
> EJBSecurityManager.java:1050)
> >> >>
> >> >> at
> >> >>
> >> com.sun.enterprise.security.SecurityUtil.invoke(
> SecurityUtil.java:165)
> >> >> at
> >> com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod
> >> >> (BaseContainer.java:2788)
> >> >> at
> >> >>
> >> com.sun.ejb.containers.BaseContainer.intercept(
> BaseContainer.java:3870)
> >> >> at
> >> >>
> >>
> com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(
> EJBLocalObjectInvocationHandler.java:184)
> >> >>
> >> >> ... 43 more
> >> >>
> >> >> I am confused because on the EJB specification this is
> >> what's written :
> >> >>
> >> >> 14.1.1 Application Exceptions
> >> >>
> >> >> An application exception may be a subclass (direct or
> >> indirect) of
> >> >> java.lang.Exception (i.e., a "checked exception"), or
> >> an application
> >> >> exception class may be defined as a subclass of the
> >> >> java.lang.RuntimeException (an "unchecked exception")
> >> >>
> >> >> 14.1.2 Goals for Exception Hand
> >> >>
> >> >> An application exception thrown by an enterprise bean
> >> instance should
> >> >> be reported to the client precisely (i.e., the client
> >> gets the same
> >> >> exception)
> >> >>
> >> >> 14.2.1 Application Exceptions
> >> >>
> >> >> An application exception that is an unchecked exception
> >> is defined as
> >> >> an application exception by annotating it with the
> >> >> applicationException metadata annotation.
> >> >>
> >> >> Thanks for your help,
> >> >>
> >> >>
> >> >>
> >> >> Antonio
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> >
> ---------------------------------------------------------------------
> >>
> >> > To unsubscribe, e-mail:
> >> ejb-unsubscribe_at_glassfish.dev.java.net
> >> <mailto:ejb-unsubscribe_at_glassfish.dev.java.net>
> >> > For additional commands, e-mail:
> >> ejb-help_at_glassfish.dev.java.net
> >> <mailto:ejb-help_at_glassfish.dev.java.net>
> >> >
> >>
> >>
> >>
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>
>