[jboss-user] [Beginners Corner] - UndeclaredThrowableException and duplicate primary key

kstrunk do-not-reply at jboss.com
Sat Oct 14 11:22:27 EDT 2006


Hello!

I'm really new to JBoss and I hope somebody can help me with my first problem I can't solve myself.

When I call create on a locale EntityBean with a primary key which already exists, I get an UndeclaredThrowableException which is caused by a DuplicateKeyException, but I really don't know why this happens. 
The DuplicateKeyException is what I've expected. But why do I get the UndeclaredThrowableException?? Does anybody have an idea what I'm doing wrong? 

Here is my code in my test servlet which is running in the bundled tomcat:


  | Properties props = new Properties();
  | props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
  | props.setProperty(Context.URL_PKG_PREFIXES,"org.jboss.naming.client");
  | props.setProperty(Context.PROVIDER_URL, "localhost");
  | 
  | InitialContext initialContext = new InitialContext(props);
  | MandatorLocalHome mandatorLocalHome = (MandatorLocalHome) initialContext.lookup(MandatorLocalHome.JNDI_NAME);
  | 
  | Integer mandatorId = new Integer(1);
  | try {
  |     MandatorLocal mandator = mandatorLocalHome.create(mandatorId);
  | } catch (DuplicateKeyException e) {
  |     writer.write("mandator " + mandatorId + " already exists\n");
  | }
  | 

My configuration:
JBoss 4.0.4
PostgreSQL 8.1

And here is the full stacktrace:

  | 16:58:26,500 ERROR [STDERR] java.lang.reflect.UndeclaredThrowableException
  | 16:58:26,500 ERROR [STDERR] 	at $Proxy166.create(Unknown Source)
  | 16:58:26,531 ERROR [STDERR] 	at org.cryptobox.gui.TestServlet.doPost(TestServlet.java:49)
  | 16:58:26,531 ERROR [STDERR] 	at org.cryptobox.gui.TestServlet.doGet(TestServlet.java:29)
  | 16:58:26,531 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
  | 16:58:26,531 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  | 16:58:26,531 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  | 16:58:26,546 ERROR [STDERR] 	at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  | 16:58:26,546 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:595)
  | 16:58:26,546 ERROR [STDERR] Caused by: javax.ejb.DuplicateKeyException: Entity with primary key 1 already exists
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.cmp.jdbc.JDBCInsertPKCreateCommand.beforeInsert(JDBCInsertPKCreateCommand.java:99)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:150)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:587)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:237)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:225)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:618)
  | 16:58:26,546 ERROR [STDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 16:58:26,546 ERROR [STDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | 16:58:26,546 ERROR [STDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 16:58:26,546 ERROR [STDERR] 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1130)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:203)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:189)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:134)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:76)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:43)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:56)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:161)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:145)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:514)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.Container.invoke(Container.java:975)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:359)
  | 16:58:26,546 ERROR [STDERR] 	at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:133)
  | 16:58:26,546 ERROR [STDERR] 	... 23 more
  | 


Thanx very much for help!

 Karsten

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3978331#3978331

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3978331



More information about the jboss-user mailing list