[JBoss Seam] - Transaction failed faces message
by milesif
Hi everybody,
I'm making some experiment with a class that extends EntityHome and overrides persist() in this way (I need to show customized error messages when database constraints are violated):
| @Override
| @Transactional
| public String persist() {
| try {
| return super.persist();
| } catch (Exception e) {
| facesMessages.addFromResourceBundle(SEVERITY_INFO, getMessageKeyPrefix() + "unique", "I got an error" );
| return "persist";
| }
| }
|
When I insert a record that violates a constraint, I catch the exception and add a faces message. The problem is that the <h:messages tag in my page shows my message plus another one that says "Transaction failed", That message seems to be added by the framework after the persist() method has returned. Where does that come from ? How can I eliminate or hide it ?
Thanks in advance for helping
Ciao Francesco
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994272#3994272
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994272
19 years, 4 months
[Javassist user questions] - Can I instrument CodeConverter at runtime?
by dodomio
Hi everybody,
I'm trying to modify a method of my custom CodeConverter at runtime, as the instrumentation is based on the content of a configuration file. I'm stuck at the error You can see below.
Actually I wrote this:
| public class Main {
|
| public static void main(String[] args) throws Throwable {
|
| ClassPool cp = ClassPool.getDefault();
| Loader loader = new Loader(Main.class.getClassLoader(),cp);
|
| // Get the class and instrument
| CtClass conv = cp.get("pkg.CustomConverter");
| CtMethod m = conv.getDeclaredMethod("init");
| StringBuffer sb = new StringBuffer();
| sb.append("{\n");
| sb.append("CtMethod m1 = thePool.get(\"pkg.Hello\").getDeclaredMethod(\"say\");\n");
| sb.append("CtMethod m2 = thePool.get(\"pkg.Hello\").getDeclaredMethod(\"first\");\n");
| sb.append("insertBeforeMethod(m1, m2);\n");
| sb.append("}\n");
| m.setBody(sb.toString()); // (*) Here I got the error shown below
|
| CustomConverter conv = (CustomConverter) conv.toClass().newInstance();
| CustXlator xlat = new CustXlator(conv);
|
| loader.addTranslator(cp, xlat);
| loader.run(args); // Loads and runs the class pkg.Hello
| }
|
| }
|
CustXlator's onLoad method does simply:
| if (className.equals("pkg.Hello")) {
| CtClass c = pool.get(className);
| c.instrument(converter);
| // converter is an instance of CustomConverter passed as
| // the only parameter to CustXlat constructor
| }
|
while CustomConverter has only the init method that I'm trying to instrument.
I'm stuck at an exception occourring during setBody execution. The stacktrace is:
| javassist.CannotCompileException: [source error] no such class: CtMethod
| at javassist.CtBehavior.setBody(CtBehavior.java:346)
| at javassist.CtBehavior.setBody(CtBehavior.java:315)
| at pkg.Main.main(Main.java:29)
| Caused by: compile error: no such class: CtMethod
| at javassist.compiler.MemberResolver.searchImports(MemberResolver.java:416)
| at javassist.compiler.MemberResolver.lookupClass(MemberResolver.java:392)
| at javassist.compiler.MemberResolver.lookupClassByJvmName(MemberResolver.java:310)
| at javassist.compiler.MemberResolver.resolveJvmClassName(MemberResolver.java:460)
| at javassist.compiler.MemberCodeGen.resolveClassName(MemberCodeGen.java:1064)
| at javassist.compiler.CodeGen.atDeclarator(CodeGen.java:698)
| at javassist.compiler.ast.Declarator.accept(Declarator.java:99)
| at javassist.compiler.CodeGen.atStmnt(CodeGen.java:344)
| at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
| at javassist.compiler.CodeGen.atStmnt(CodeGen.java:344)
| at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
| at javassist.compiler.CodeGen.atMethodBody(CodeGen.java:285)
| at javassist.compiler.Javac.compileBody(Javac.java:212)
| at javassist.CtBehavior.setBody(CtBehavior.java:340)
| ... 2 more
|
It seems that CustomConverter was unable to resolve CtMethod class!!!
But if I statically modify the init method all is ok.
I really don't know how to solve the problem.
Can someone help me? I'll appreciate it very much!
Thanks in advance, Mauro.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994268#3994268
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994268
19 years, 4 months
[JBoss Portal] - Re: Struts Portlet
by rabbuhl
Here are the steps to get struts-demo-for-jboss-portal to work on JBoss Portal 2.4.0:
1. Verify that jboss-portal-2.4.0 is installed and working correctly.
2. Download http://docs.jboss.org/jbportal/samples/struts-demo-for-jboss-portal.zip.
3. Unzip struts-demo-for-jboss-portal.zip.
4. Create a directory called struts-demo and unzip struts-demo.war into this directory.
5. Cd to struts-demo\WEB-INF\lib.
6. Delete portals-bridges-struts-0.2.jar from struts-demo\WEB-INF\lib.
7. Download portals-bridges-src-1.0.zip from http://portals.apache.org/bridges/download.html.
8. Unzip portals-bridges-src-1.0.zip.
9. Copy portals-bridges-struts-1.2.4-1.0.jar to struts-demo\WEB-INF\lib.
10. Zip the struts-demo directory to struts-demo.war.
11. Deploy struts-demo.war to jboss-portal-2.4.0\server\default\deploy.
12. Start up JBoss Portal by running jboss-portal-2.4.0\bin\run.bat.
13. Point your web browser to http://localhost:8080/portal.
14. Login as admin/admin.
15. Click on the admin tab.
16. In the Management Portlet window click on Portlets.
17. Find the Struts Portlet Demo and click on local./struts-demo.StrutsPortletDemo.
18. On the right side of the window type "Struts Portlet" and click the Create instance button.
19. In the Management Portlet window click on Portal. Expand root, then default.
20. Click on default. In New Page Name type "struts" and then click on Add Page.
21. Click on Struts. Find Struts Portlet in the drop-down list. To the left type in "Struts Demo".
22. Click on the Add left button.
23. Click on the Struts tab to see the Struts MailReader Demo.
Since the struts bridge is included in the JBoss Portal can someone at JBoss can update the portals-bridges-struts
jar in struts-demo.war and update the documentation so that it describes how to install the demo using JBoss
Portal 2.4.0 or later?
Can this example also be added to the tutorial documentation in the Reference Guide Tutorials (with a link
pointing to the download for struts-demo-for-jboss-portal.zip)?
Regards,
Richard
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994266#3994266
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994266
19 years, 4 months