You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Clere, Jean-Frederic" <jf...@fujitsu.siemens.es> on 2000/03/30 19:15:28 UTC
RE: ResourceBundle.getBundle() throws MissingResourceException in
JSP
jakarta-tomcat/src/share/org/apache/tomcat/loader/AdaptiveClassLoader.java..
.
I get a problem in jserv and it dispairs after a fixe (not from me!):
--- ./src/java/org/apache/java/lang/AdaptiveClassLoader.java.org Wed
Dec 8 21:33:25 1999
+++ ./src/java/org/apache/java/lang/AdaptiveClassLoader.java Fri Feb 4
13:05:33 2000
@@ -656,18 +656,28 @@
*/
private InputStream loadResourceFromZipfile(File file, String name) {
ZipFile zipfile = null;
+ InputStream resourceStream = null;
try {
zipfile = new ZipFile(file);
ZipEntry entry = zipfile.getEntry(name);
if (entry != null) {
- return zipfile.getInputStream(entry);
+ long length = entry.getSize();
+ resourceStream = zipfile.getInputStream(entry);
+ byte[] data = loadBytesFromStream(resourceStream,
(int)length);
+ return new ByteArrayInputStream(data);
} else {
return null;
}
} catch(IOException e) {
return null;
} finally {
+ if ( resourceStream != null ) {
+ try {
+ resourceStream.close();
+ } catch ( IOException ignored ) {
+ }
+ }
if ( zipfile != null ) {
try {
zipfile.close();
Any way the code we use looks bad (the close closes the InputStream... do
not it?).
<<patch.help.notmine>>
> -----Original Message-----
> From: nathank@lexmark.com [SMTP:nathank@lexmark.com]
> Sent: Thursday, March 30, 2000 5:39 PM
> To: tomcat-dev@jakarta.apache.org
> Subject: ResourceBundle.getBundle() throws MissingResourceException
> in JSP
>
> When I try to get a ResourceBundle from a JSP, I get a
> MissingResourceException.
> But if I do it in a Bean called from the JSP, it works. It also works
> from a
> servlet. I have the properties file in the WEB-INF\classes directory.
> Anyone
> know why? I think it has something to do with the ClassLoader. I'm using
> the
> 20000327 build of Tomcat
>
> Nathan Klemperer
>
>
> Here is the JSP file:
>
> <%@ page language="java" %>
> <%@ page import="java.util.*" %>
>
> <HTML>
> <HEAD>
> <TITLE>
> Test
> </TITLE>
> </HEAD>
>
> <%
> try
> {
> out.println("<p>Try to get ResourceBundle from
> ResourceBundle.getBundle()");
>
> ResourceBundle rb = ResourceBundle.getBundle("LocalStrings");
> out.println("<p>Success: " + rb.getString("helloworld.title"));
> }
> catch (MissingResourceException e)
> {
> out.println("<p>Failed: " + e);
> }
>
> try
> {
> out.println("<p>Try to get ResourceBundle from Bean");
>
> ResourceBundle rb = new RB("LocalStrings").rb;
> out.println("<p>Success: " + rb.getString("helloworld.title"));
> }
> catch (MissingResourceException e)
> {
> out.println("<p>Failed: " + e);
> }
> %>
>
>
> Here is the Bean:
>
> public class RB
> {
> public java.util.ResourceBundle rb;
>
> public RB(String name)
> {
> rb = java.util.ResourceBundle.getBundle(name);
> }
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org