It would be helpful here if you logged the full stack trace when your MissingResourceException occurred. Perhaps, for debugging purposes, you could include an
e.printStackTrace() call in your catch clause before the throw. Of course, you could write this to a String and then log it but that would be more work. I think the problem has to do with how ResourceBundle.getBundle() determines which classloader (and hence which path) to use when loading a resource bundle for the one and two argument forms of getBundle(). From what I can tell, ResourceBundle uses the classloader of its caller's caller. This is why I need the stack trace to determine what's going on. It's also why I think that things worked when you placed the file in your extensions directory. Is XalanJ in your extensions directory? If so, the problem is not in how XalanJ uses the CLASSPATH but in how ResourceBundle uses the CLASSPATH. I think it's going to use the same classloader that loaded the XalanJ class org.apache.xalan.extensions.ExtensionHandlerJavaClass which I think will be in the stack trace in the second spot from the top (but I'd like to verify it). If you're going to put XalanJ in the extensions directory, that's where ResourceBundle is going to look for any resources that it loads, I'm afraid. ResourceBundle doesn't try to use the current thread class loader. If you don't want to move XalanJ out of the extensions directory, mu siggestion is that you write your own extension instead of using java.util.ResourceBundle directly. Your extension could simply call ResourceBundle.getBundle as: return ResourceBundle.getBundle(baseName, locale, Thread.getContextClassLoader()); HTH, Gary > -----Original Message----- > From: Michael Engelhart [mailto:[EMAIL PROTECTED] > Sent: Friday, March 01, 2002 5:26 PM > To: Gary L Peskin > Cc: [EMAIL PROTECTED] > Subject: Re: xalan extensions classpath > > > Hi Gary, > > Here's the error output in my Log4J file: > ERROR [earthtrip]: XSLT Transformation failed: > java.util.MissingResourceException: Can't find bundle for base name > clients.earthtrip.i18n, locale en_US 2002-02-28 16:37:51,259 > > JDK 1.3.1 on Mac OS X > Xalan 2.2.0 > > I'm not executing from the command line. Just programmatically from > within my code. Here's the code that loads the stylesheet > and does the > transform (I'm using JDOM 1.0b7 for XML). The reason I'm assuming > this is a Xalan problem is because it only happens from within the > stylesheet extension. > > try { > Transformer transformer = > TransformerFactory.newInstance().newTransformer(new > StreamSource(stylesheet)); > StreamResult out = new StreamResult(new StringWriter()); > transformer.transform(new JDOMSource(this.doc), out); > StringWriter writer = (StringWriter) out.getWriter(); > return writer.getBuffer(); > } > catch (Exception e) { > throw new JDOMException("XSLT Transformation failed", e); > } > > > Also I'm not getting a JDOMException but a > java.util.MissingResourceException > I have the classpath set in the application launcher to point to the > directory that contains the "client" directory so the rest of my code > can call it fine. > > Thanks for your help. > > Mike > > > On Friday, March 1, 2002, at 04:21 PM, Gary L Peskin wrote: > > > Hi, Mike -- > > > > What version of XalanJ are you using? What is your JDK > version? Can > > you include the full stack trace of the MissingResourceException, > > please (you may need to include the -edump command line switch). > > > > Also, if you're executing XalanJ from the command line, can > you please > > type > > > > java org.apache.xalan.xslt.EnvironmentCheck > > > > and include the output? > > > > Thanks, > > Gary > > > >> -----Original Message----- > >> From: Michael Engelhart [mailto:[EMAIL PROTECTED] > >> Sent: Friday, March 01, 2002 1:16 PM > >> To: [EMAIL PROTECTED] > >> Subject: xalan extensions classpath > >> > >> > >> Hi, > >> > >> I have a stylesheet with the following in it: > >> > >> <xsl:variable name="language" select="/Document/@Language" /> > >> <xsl:variable name="country" select="/Document/@Country" /> > >> <xsl:variable name="locale" > >> select="java:java.util.Locale.new($language, > >> $country)" /> > >> <xsl:variable name="i18nBundle" > >> select="java:java.util.ResourceBundle.getBundle('clients.somec > >> lient.i18n', > >> $locale)" /> > >> > >> > >> This standalone application has the directory that contains > >> "clients/someclient" in the classpath and I can easily call: > >> ResourceBundle bundle = > >> ResourceBundle.getBundle("clients.someclient.i18n"); > >> without throwing a MissingResourceException from anywhere > in my java > >> class files. I can also do transforms with Xalan as well > but when I > >> include the above XSL extension code I get a > MissingResourceException > >> thrown. > >> > >> So my question is how come Xalan isn't using the applications > >> classpath > >> in it's extension mechanism? Also I tried jarring up that clients > >> directory and sticking it my Java Extensions directory > (which on Mac > >> OS X gets added to the classpath automatically) and it > found the file > >> fine. But I want these properties files to be editable and not > >> wrapped up in a jar. The clients directory is to sit in the > >> applications top level directory. > >> > >> Any help/advice would be apprectiated. > >> > >> Thanks > >> Mike > >> >
