[EJB 3.0] - Re: Exception handling
by jc7442
First, I'm not an expert that's just my way to manage exception !
I do not manage my exception in the same way as yours.
First, if you want log exception and throw another exception, you may perhaps consider to use JBoss AOP interceptor in order not to make your source code more complex.
Now my way to manage exception is the following (it's my solution, maybe that's not good):
Usually I do not catch exception for my DAO (it means that if a runtime exception is thrown it may rollback the JTA transaction) and I have added an interceptor on all methods of remote session bean and MDB. This interceptor is in charge to log the exception and to modifiy throw a new exception (this exception as a ref on the logged exception. I often have swing client, I log exception on server side to be sure to have a log - if i just leave the exception go to client side, usualy client does not have in its classpath one of the chained exception).
In some cases, when the exception thrown is a error case (not a bug in my code), in the session bean, I cacth the excpetion, log it and usualy throw an exception with an ApplicationException annotation with a rollback=false. Consequently the exception does not rollback the JTA transaction. This exception is not a Runtime consequently, invoker has to manage the exception.
To summarize:
- consider using JBoss AOP inteceptor
- Consider using ApplicationException annotation
You probably will have more flexibility for your exception management and a easier code to write.
I'm interesting to know what's your feeling about that !
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972007#3972007
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972007
19 years, 7 months
[Persistence, JBoss/CMP, Hibernate, Database] - TransactionRolledBackLocalException accessing entity bean re
by jaysperk
I am getting an exception TransactionRolledBackLocalException caused by NoSuchObjectLocalException: Entity not found
under the following scenario:
Using BMT.
Commit Option A.
Entities
Customer
Account
Customer has one to many relationship with accounts.
Sequence of events:
Start Transaction
Create a customer entity (PK - 400)
Commit
Start Transaction (T1 - Start)
Create an account entity (PK - 1)
Add account (PK - 1) to customer entity (PK - 400, custaccts CMR)
Start Transaction (T2 - Start, T1 - suspended)
Get customer entity (PK - 400)
Create account entity (PK - 100)
Add account (PK - 100) to customer (PK - 400, custaccts CMR)
Rollback transaction (T2 - End, T1 - activated)
Create account (PK - 1000)
Get accounts for customer(PK - 400) - contains 2 entities (should contain 1 account (PK - 1))
Go through list of accounts and access field - get exception above because one of the created entities does not exist because of a rollback.
Is this the expected behavior? Or would you expect the CMR method that gets the accounts for a customer to return only valid entities? Or does this have something to do with my commit option? Can I avoid having my transaction rolled back when I find the stale entity?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972005#3972005
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972005
19 years, 7 months
[JBoss Seam] - Does injection perform standard JSF conversion?
by adambrod
Hi-
I have a property in my managed bean that is injected from the request parameters. Will Seam perform standard conversions like regular JSF managed properties?
This property fails:
@In("#{param.managedFileId}")
| protected Long managedFileId;
with the exception below. From what I can tell, Seam is trying to inject the request parameter as a String, but the target expects a Long. How can I fix this? Here is the request url I'm using: http://localhost:8000/files/dFile.faces?managedFileId=30050
java.lang.IllegalArgumentException
| at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
| at java.lang.reflect.Field.set(Field.java:656)
| at org.jboss.seam.Component.setFieldValue(Component.java:1210)
| at org.jboss.seam.Component.injectFields(Component.java:1024)
| at org.jboss.seam.Component.inject(Component.java:795)
| at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:30)
| at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:82)
| at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:60
| at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.TransactionInterceptor.doInTransactionIfNecessary(TransactionInterceptor.java:34)
| at sun.reflect.GeneratedMethodAccessor103.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:39)
| at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
| at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
| at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
| at org.jboss.seam.ejb.SeamInterceptor.aroundInvokeInContexts(SeamInterceptor.java:73)
| at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:45)
| at org.jboss.seam.interceptors.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:51)
| at org.jboss.seam.interceptors.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:39)
| at com.intralinks.web.managedfile2.DisplayManagedFileController$$EnhancerByCGLIB$$c2e391ae.toString(<generated>)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972002#3972002
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972002
19 years, 7 months
[JBoss Portal] - Re: I can't see the tabs in my new portal.
by mmontoni
Hi,
I tried what you said and it work beautiful. I just have one issue though. For the Ajax option for example I can stillthe the tabs but if I click on SpringMVC or Stock News the tabs disapear...I compared the .xmls and all seems to be the same. I wonder if there is a particular configuration I am missing....
Any ideas would be appreciate it.
Thanks,
Mariella.
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
| <deployments>
| <deployment>
| <if-exists>overwrite</if-exists>
| <parent-ref />
| <portal>
| <portal-name>GEPortal</portal-name>
| <properties>
| <property>
| <name>portal.defaultObjectName</name>
| <value>Home</value>
| </property>
| <property>
| <name>layout.id</name>
| <value>generic01</value>
| </property>
| <property>
| <name>theme.id</name>
| <value>GE-Blue</value>
| </property>
| <property>
| <name>theme.renderSetId</name>
| <value>divRenderer</value>
| </property>
| <property>
| <name>layout.strategyId</name>
| <value>maximizedRegion</value>
| </property>
| </properties>
| <supported-modes>
| <mode>view</mode>
| <mode>edit</mode>
| <mode>help</mode>
| </supported-modes>
| <supported-window-states>
| <window-state>normal</window-state>
| <window-state>minimized</window-state>
| <window-state>maximized</window-state>
| </supported-window-states>
| <page>
| <page-name>Home</page-name>
| <window>
| <window-name>Navigation</window-name>
| <instance-ref>NavigationPortletInstance</instance-ref>
| <region>navigation</region>
| <height>0</height>
| <properties>
| <property>
| <name>theme.windowRendererId</name>
| <value>emptyRenderer</value>
| </property>
| <property>
| <name>theme.decorationRendererId</name>
| <value>emptyRenderer</value>
| </property>
| <property>
| <name>theme.portletRendererId</name>
| <value>emptyRenderer</value>
| </property>
| </properties>
| </window>
| <window>
| <window-name>MyPortletWindow</window-name>
| <instance-ref>MyPortletInstance</instance-ref>
| <region>left</region>
| <height>0</height>
| </window>
| <window>
| <window-name>CalculatorPortletWindow</window-name>
| <instance-ref>CalculatorPortletInstance</instance-ref>
| <region>left</region>
| <height>1</height>
| </window>
| </page>
| <page>
| <page-name>SpringMVC</page-name>
| <window>
| <window-name>Navigation</window-name>
| <instance-ref>NavigationPortletInstance</instance-ref>
| <region>navigation</region>
| <height>0</height>
| <properties>
| <property>
| <name>theme.windowRendererId</name>
| <value>emptyRenderer</value>
| </property>
| <property>
| <name>theme.decorationRendererId</name>
| <value>emptyRenderer</value>
| </property>
| <property>
| <name>theme.portletRendererId</name>
| <value>emptyRenderer</value>
| </property>
| </properties>
| </window>
| <window>
| <window-name>BooksPortletWindow</window-name>
| <instance-ref>BooksPortletInstance</instance-ref>
| <region>left</region>
| <height>0</height>
| </window>
| </page>
| <page>
| <page-name>AJAX</page-name>
| <window>
| <window-name>Navigation</window-name>
| <instance-ref>NavigationPortletInstance</instance-ref>
| <region>navigation</region>
| <height>0</height>
| <properties>
| <property>
| <name>theme.windowRendererId</name>
| <value>emptyRenderer</value>
| </property>
| <property>
| <name>theme.decorationRendererId</name>
| <value>emptyRenderer</value>
| </property>
| <property>
| <name>theme.portletRendererId</name>
| <value>emptyRenderer</value>
| </property>
| </properties>
| </window>
| <window>
| <window-name>AJAXInvoiceViewerPortletWindow</window-name>
| <instance-ref>AJAXInvoiceViewerPortletInstance</instance-ref>
| <region>left</region>
| <height>0</height>
| </window>
| </page>
| </portal>
| </deployment>
| </deployments>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971995#3971995
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971995
19 years, 7 months
[JBoss Seam] - Trouble With Reverse Engineering and javax.ejb.Interceptors
by wbwarren57
I am having trouble with Seam reverse engineering and the javax.ejb.Interceptors class. When I reverse engineer a MySQL schema, the code generator produces code that requires javax.ejb.Interceptors. Since I can't find an instance of this class anywhere, I can't compile my generated application with the generated ant deploy task of the generated build.xml.
1) How can I get the reverse engineering tool to generate code that does not use javax.ejb.Interceptors? I checked the Seam example apps (all of which I can compile, deploy and run without problems) and NONE of them use javax.ejb.Interceptors.
OR
2) Where can I find an instance of javax.ejb.Interceptors that I can compile against? I have installed JBoss AS using the JEM-installer but can't find where there might be an instance of this class.
I am using Ecllipse 3.2 with the latest Calipso extension (including WTP 1.5) and the latest version of the JBoss Exlipse IDE as well as the latest version of the Seam distribution.
Thanks for your help,
Will Warren
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971991#3971991
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971991
19 years, 7 months