How to get MyException from ExceptionHandler
I want to implement an application specific exception handling for my struts application. So, I defined my own Exception class that extends a normal Exception by an error code and the filename where the exception occured: public class MyException extends Exception { private int errorCode = -1; private String file = null; public MyException() { super(); } public MyException (String message, int errorCode, String file) { super(message); this.errorCode = errorCode; this.file = file; } public int getErrorCode () { return errorCode; } public void setErrorCode (int errorCode) { this.errorCode = errorCode; } public String getFile () { return file; } public void setFile (String file) { this.file = file; } } I've also created my own ExceptionHandler class: public class MyExceptionHandler extends ExceptionHandler { public ActionForward execute (Exception ex, ExceptionConfig config, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException { ... } } In struts-config.xml I've configured this exception handler as a global-exception that should handle ALL excetions: global-exceptions exception handler=de.fortu.actions.MyExceptionHandler type=java.lang.Exception key=global.error path=/jsp/error/error.jsp scope=request / /global-exceptions Now I generate a NullPointerException and throw my exception object: try { String str = null; str.charAt(0); } catch (Exception e) { throw new MyException (Test, 100, MyAction); } What I see is that I run through MyExceptionHandler class, i.e. the global-exception definition seems to work. What I do NOT see is MyException class. When I stop in MyExceptionHandler and inspect the Exception object I do not find the values I set in the catch block before. The detailMessage says: Error calling form action handler: metrics_onDrilldown reason: null Any ideas what's going wrong here? Best regards, Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Application specific Exception Handling
Hi, I try to implement an application specific exception handling. Therefor I created a class that extends ExceptionHandler and my own Exception class that has variables for holding an error code and the filename where the exception occured. When I generate a NullPointerException I generate a new object of my exception class an throw it. Unfortunately, in the exception handler class I only see an object of class Exception. So, I'm not able to get the error code and the filename from the exception object. When I try to cast the exception explicitly to my exception class I get a ClassCastException. How can I get an object of my own exception in the exception handler? Regards, Ralf. struts-config.xml: global-exceptions exception handler=de.fortu.actions.FortuExceptionHandler type=java.lang.Exception key=global.error path=/jsp/error/error.jsp scope=request / /global-exceptions ExceptionHandler Class: public class FortuExceptionHandler extends ExceptionHandler { public ActionForward execute (Exception ex, ExceptionConfig config, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException { String property = null; String path = null; if(config.getPath() != null) path = config.getPath(); else path = mapping.getInput(); ActionForward forward = new ActionForward(path); ActionError error = new ActionError(global.error.nosession); storeException (request, property, error, forward, config.getScope()); return forward; } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multiple Resource Bundles
Hi, I try to use multiple resource bundles that get the strings from a database in an environment using JBoss, Struts and Velocity. I have defined two message-resources in struts-config.xml: message-resources factory=com.bk.web.struts.BKWebStringResourceFactory parameter=StringResources key=Strings/ message-resources factory=com.bk.web.struts.BKWebMessageResourceFactory parameter=ApplicationResources/ During startup of JBoss the createResource() method of both factories is called. But when I call a page on which the strings come from the StringResources bundle the getMessage() method of the ApplicationResources bundle is called. In the HTML code I've placed calls like this (: $msg.get(global.close, StringResources) msg is defined in toolbox.xml: tool keymsg/key classorg.apache.velocity.tools.struts.MessageTool/class /tool What's wrong with my call of $msg.get()? Did I miss anything? Best regards, Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
MessageResources Problem in Action
Hi, I want to access the strings in a resource bundle from within an action. I have two resource files (ApplicationResources.properties and ApplicationResources_de.properties) and they are accessed correctly from the JSP, but not from the action. When I look at the locale with request.getLocale() in the action I see that it is set to de_AT. This is what I expected. Unfortunately, the strings are fetched from ApplicationResources.properties, not from ApplicationResources_de.properties as they should be. I use this code to get a string from the resource bundle: MessageResources messages = getResources (request); String msg = messages.getMessage(rights.new); Any ideas what might be the problem? Thanks, Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: MessageResources Problem in Action
Am Dienstag, 1. Juni 2004 15:15 schrieb None None: I use the following code: myActionForm.setMessage(getResources(request).getMessage(getLocale(request) , messages.deleteFailed)); Great! This works fine! The only thing that I missed was to get the locale from the request. Thanks, Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Special Characters (german Umlaute)
Am Montag, 3. Mai 2004 21:57 schrieb Ruth, Brice: You can use the native2ascii application that is bundled with your JDK to automatically convert your native-encoded file with umlauts to \u format encodings. Thanks, works fine! The only thing I have to manage now is to automate this task within Eclipse 3.0M8. At the moment, there is no build.xml file in my project. So, Eclipse must somehow know what to do with the resource files as they are copied automatically from the source to the classes directory when they are saved. How can I tell Eclipe not only to copy them but to run native2ascii? Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use resource bundle in attributes
But this is not the way I want to use it. This way, I could use it to put a translated text into the body of a tag like tdfmt:message key=login/td But how can I use the translated text as an attribute value as written before? Ralf. Am Montag, 3. Mai 2004 17:12 schrieb Nathan Maves: I am not 100% sure but I believe that you just use the fmt:message tag. Just use something like... fmt:message key=login.tooltip.username / if you need to send parameters just put them in the body of the tag. fmt:message key=login.tooltip.username fmt:param value=${username}/ /fmt:message Nathan On May 3, 2004, at 8:44 AM, Ralf Schneider wrote: Could you give a short example of how this can be done with JSTL or point me to an example? I looked into the Java Web Services Tutorial, but the chapter about internationalization with JSTL only describes the use of internationalized strings in the body of a tag (e.g. fmt:message ...). Ralf. Am Montag, 3. Mai 2004 15:37 schrieb Nathan Maves: Use jstl! On May 3, 2004, at 6:51 AM, Ralf Schneider wrote: Hi, how can a use internationalized text strings stored in a resource bundle as values of attributes? For example: html:text property=username title=login.tooltip.username/ I know, this will not work, but how can it be done? Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- ## Ralf Schneider ## Fürstenallee 14 - 34454 Bad Arolsen ## Tel. +49-5691-625994 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to use resource bundle in attributes
Yes! That's exactly what I was looking for. Thanks a lot! I missed this attribute when looking through the endless list of attributes of the HTML taglib. Ralf. Am Montag, 3. Mai 2004 18:28 schrieb bOOyah: Ralf Schneider wrote: how can a use internationalized text strings stored in a resource bundle as values of attributes? html:text property=username title=login.tooltip.username/ Hi Ralf Have you tried html:text property=username titleKey=login.tooltip.username/ I use the 'titleKey' attribute like this on 'html:submit' buttons. -- ## Ralf Schneider ## Fürstenallee 14 - 34454 Bad Arolsen ## Tel. +49-5691-625994 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Special Characters (german Umlaute)
Hi, my web application loads german strings from a resource bundle. Unfortunately, the special characters (german Umlaute like , , ) are displayed incorrectly if they come from the resource bundle. When I write them directly into the HTML code they are displayed correctly. At the beginning of my JSP file I have this line: %@ page contentType=text/html; charset=UTF-8 % And the HTML block is opened with this line: html:html locale=true xhtml=true What do I have to change to get the special characters displayed as they were written in the resource bundle? Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with Data Source Definition
Am Dienstag, 20. April 2004 08:53 schrieb Xuemin Guan: Tomcat (5.0.19) comes together with commons-pool-1.1.jar, which is under CALINA_HOME/common/lib. This directory is both seen by container and you web applications. So, I guess the problem is not cause by the lack of commons-pool-1.1.jar. Am I missing anything here? Exactly, commons-pool-1.1.jar as well as commons-dbcp-1.1.jar are located in CATALINE_HOME/common/lib and I added them as external JARs to the build path of the project. So I guess it should be found by the application. Is there a way to get a more detailed information about what's going wrong during startup? The displayed message StandardContext[/demo_03]Servlet /demo_03 threw load() exception javax.servlet.UnavailableException: Initializing application data source local_01 at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1091) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472) at javax.servlet.GenericServlet.init(GenericServlet.java:256) does not really help to fix this problem. Probably, the problem might be one of the properties. I took them from the example from the Struts HowTo on accessing databases. Any ideas? Best regards, Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with Data Source Definition
Hi, I'm trying to setup Struts 1.1 with a database connection using DBCP 1.1 to connect to a SAP DB 7.4 database. Unfortunately, I get the following error during startup of Tomcat (5.0.19): StandardContext[/demo_03]Servlet /demo_03 threw load() exception javax.servlet.UnavailableException: Initializing application data source local_01 at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1091) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472) at javax.servlet.GenericServlet.init(GenericServlet.java:256) This is the data sources part of my struts-config.xml: data-sources data-source key=local_01 type=org.apache.commons.dbcp.BasicDataSource set-property property=description value=My DB Configuration / set-property property=driverClassName value=com.sap.dbtech.jdbc.DriverSapDB / set-property property=url value=jdbc:sapdb://localhost/ENIWDB / set-property property=user value=test / set-property property=password value=Test / set-property property=defaultAutoCommit value=false / set-property property=defaultReadOnly value=false / set-property property=maxActive value=10 / set-property property=maxWait value=5000 / set-property property=validationQuery value=SELECT COUNT(*) FROM dual / /data-source /data-sources The same connection settings work in another project not using Struts and DBCP. Any ideas what the problem is with this configuration? Thanks in advance, Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts with Tomcat and Apache
Am Samstag, 10. April 2004 15:30 schrieb Paul Thomas: I supect that you're trying to use the old mod_jk connector. Try mod_jk2 instead. No, I use mod_jk2. The connection between Tomcat and Apache works now. But the next problem is that I get an error when trying to access the struts example apps (e.g. struts-blank): exception javax.servlet.ServletException: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/lang/String;ZZ)V org.apache.jasper.servlet.JspServlet.service(JspServlet.java:256) javax.servlet.http.HttpServlet.service(HttpServlet.java:853) root cause java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/lang/String;ZZ)V org.apache.jasper.compiler.TagLibraryInfoImpl.createAttribute(TagLibraryInfoImpl.java:572) org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:432) org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:290) org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:204) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:458) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:523) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1577) org.apache.jasper.compiler.Parser.parse(Parser.java:171) org.apache.jasper.compiler.ParserController.parse(ParserController.java:247) org.apache.jasper.compiler.ParserController.parse(ParserController.java:149) org.apache.jasper.compiler.ParserController.parse(ParserController.java:135) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:237) org.apache.jasper.compiler.Compiler.compile(Compiler.java:456) org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:853) Did I miss anything? Do I have to install anything else for being able to try the example apps? Best regards, Ralf. -- ## Ralf Schneider ## Software Engineering - IT Research ## Fürstenallee 14, 34454 Bad Arolsen ## www.rs-soft-eng.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with Struts example apps
Hi, after copying the example apps that come with struts 1.1 into the webapps directory of my Tomcat 5.0.16, I wanted to try them. But when I try to access them (e.g. struts-blank) I get the following error: exception javax.servlet.ServletException: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/lang/String;ZZ)V org.apache.jasper.servlet.JspServlet.service(JspServlet.java:256) javax.servlet.http.HttpServlet.service(HttpServlet.java:853) root cause java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/lang/String;ZZ)V org.apache.jasper.compiler.TagLibraryInfoImpl.createAttribute(TagLibraryInfoImpl.java:572) org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:432) org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:290) org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:204) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:458) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:523) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1577) org.apache.jasper.compiler.Parser.parse(Parser.java:171) org.apache.jasper.compiler.ParserController.parse(ParserController.java:247) org.apache.jasper.compiler.ParserController.parse(ParserController.java:149) org.apache.jasper.compiler.ParserController.parse(ParserController.java:135) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:237) org.apache.jasper.compiler.Compiler.compile(Compiler.java:456) org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:853) Did I miss anything? Do I have to install anything else for being able to try the example apps? Best regards, Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with Struts example apps
Hi, after copying the example apps that come with struts 1.1 into the webapps directory of my Tomcat 5.0.16, I wanted to try them. But when I try to access them (e.g. struts-blank) I get the following error: exception javax.servlet.ServletException: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/lang/String;ZZ)V org.apache.jasper.servlet.JspServlet.service(JspServlet.java:256) javax.servlet.http.HttpServlet.service(HttpServlet.java:853) root cause java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/lang/String;ZZ)V org.apache.jasper.compiler.TagLibraryInfoImpl.createAttribute(TagLibraryInfoImpl.java:572) org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:432) org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:290) org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:204) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:458) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:523) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1577) org.apache.jasper.compiler.Parser.parse(Parser.java:171) org.apache.jasper.compiler.ParserController.parse(ParserController.java:247) org.apache.jasper.compiler.ParserController.parse(ParserController.java:149) org.apache.jasper.compiler.ParserController.parse(ParserController.java:135) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:237) org.apache.jasper.compiler.Compiler.compile(Compiler.java:456) org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:853) Did I miss anything? Do I have to install anything else for being able to try the example apps? Best regards, Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts with Tomcat and Apache
Am Samstag, 10. April 2004 15:30 schrieb Paul Thomas: I supect that you're trying to use the old mod_jk connector. Try mod_jk2 instead. No, I use mod_jk2. The connection between Tomcat and Apache works now. But the next problem is that I get an error when trying to access the struts example apps (e.g. struts-blank): exception javax.servlet.ServletException: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/lang/String;ZZ)V org.apache.jasper.servlet.JspServlet.service(JspServlet.java:256) javax.servlet.http.HttpServlet.service(HttpServlet.java:853) root cause java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/lang/String;ZZ)V org.apache.jasper.compiler.TagLibraryInfoImpl.createAttribute(TagLibraryInfoImpl.java:572) org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:432) org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:290) org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:204) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:458) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:523) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1577) org.apache.jasper.compiler.Parser.parse(Parser.java:171) org.apache.jasper.compiler.ParserController.parse(ParserController.java:247) org.apache.jasper.compiler.ParserController.parse(ParserController.java:149) org.apache.jasper.compiler.ParserController.parse(ParserController.java:135) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:237) org.apache.jasper.compiler.Compiler.compile(Compiler.java:456) org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:853) Did I miss anything? Do I have to install anything else for being able to try the example apps? Best regards, Ralf. -- ## Ralf Schneider ## Software Engineering - IT Research ## Fürstenallee 14, 34454 Bad Arolsen ## www.rs-soft-eng.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts with Tomcat and Apache
Hi, I'm new to Struts and I'm trying to install Struts 1.1 with Tomcat 5.0.16 and Apache 2.0.48. The documentation only talks about Tomcat 3.x. My first try was to follow these instructions for Tomcat 3.2.1. I copied the war files included with the binary distribution into the webapps directory of my Tomcat installation. Then I restarted Tomcat, but the file tomcat-apache.conf is not generate as described in the docs. So, I assume the installation works a bit different with these newer versions, but how? I that described anywhere? And if yes, where? Any hint would be apreciated, Ralf. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]