Solved

java.util.MissingResourceException during JAXB unmarschal

Posted on 2006-06-27
9
1,124 Views
Last Modified: 2012-08-13
Hi,

I am using JAXB 1.0 (from Java WSDP 1.4) and I get the following error while unmarshalling a file:

Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name javax.xml.bind.helpers.Messages, locale de_DE
      at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:825)
      at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:794)
      at java.util.ResourceBundle.getBundle(ResourceBundle.java:532)
      at javax.xml.bind.helpers.Messages.format(Messages.java:31)
      at javax.xml.bind.helpers.Messages.format(Messages.java:12)
      at javax.xml.bind.helpers.DefaultValidationEventHandler.handleEvent(DefaultValidationEventHandler.java:57)

The java classes were generated with XJC from a *.xsd file. I use RAD 6.0 and imported the generated classes and the libs from the jwsdp-1.4 directorys "jaxb\lib" and "jwsdp-shared\lib" in my RAD project.
The sample application for unmarshalling works fine but if I use my own classes I get the above error.
Why JAXB want to use the german locale? Is there a javax.xml.bind.helpers.Messages bundle for DE and where can I find it? Or if not, how can I switch to english (hopefully the bundle for EN exists)?

Thankful for any help!!
0
Comment
Question by:PierreHoffmann
  • 5
  • 3
9 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 16990975
Do your own classes set a specific locale somewhere in the code?
0
 

Author Comment

by:PierreHoffmann
ID: 16991061
No (unfortunatly). I use only the JAXB classes and the java classes generated with XJC from the xsd file. For a small test I wrote a Main class (modified unmarshal example) like shown below:

/*
 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
 
import java.io.FileInputStream;
import java.io.IOException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

// import java content classes generated by binding compiler
import com.db.gdb.as.caaa.*;

/*
 * $Id: Main.java,v 1.1.10.1 2004/04/02 19:48:28 ofung Exp $
 *
 * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
 *
 * This software is the proprietary information of Sun Microsystems, Inc.  
 * Use is subject to license terms.
 *
 */
 
public class Main {
   
    // This sample application demonstrates how to unmarshal an instance
    // document into a Java content tree and access data contained within it.
   
    public static void main( String[] args ) {
        try {
            JAXBContext jc = JAXBContext.newInstance( "com.db.gdb.as.caaa" );
           
            // create an Unmarshaller
            Unmarshaller u = jc.createUnmarshaller();
           
            // unmarshal a instance document into a tree of Java content
            // objects composed of classes from the package.
            DataImportType imp = (DataImportType)u.unmarshal( new FileInputStream( "C://Temp//x-caaa1.xml" ) );
           
        } catch( JAXBException je ) {
            je.printStackTrace();
        } catch( IOException ioe ) {
            ioe.printStackTrace();
        }
    }
   
}

The error occurs while executing the following line:
DataImportType imp = (DataImportType)u.unmarshal( new FileInputStream( "C://Temp//x-caaa1.xml" ) );
0
 
LVL 35

Expert Comment

by:girionis
ID: 16991110
I believe it is classpath issue. Can you post your classpath?
0
 

Author Comment

by:PierreHoffmann
ID: 16991461
The classpath is managed by RAD so I post the .classpath config file of the RAD project:

<classpath>
      <classpathentry kind="src" path="JavaSource"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jta-spec1_0_1.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jaxb-api.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/activation.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jaxb-xjc.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jaas.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-collections.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/PackageFormat.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-digester.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/xsdlib.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/namespace.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jaxb-impl.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jaxb-libs.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/mail.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/relaxngDatatype.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jax-qname.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-beanutils.jar"/>
      <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-logging.jar"/>
      <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/WebSphere v5.1 JRE"/>
      <classpathentry kind="con" path="com.ibm.wtp.server.java.core.container/com.ibm.etools.websphere.runtime.core.runtimeTarget.v51/was.base.v51"/>
      <classpathentry kind="output" path="WebContent/WEB-INF/classes"/>
</classpath>

As Java runtime the JRE implemented in WAS 5.1 is used.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 35

Expert Comment

by:girionis
ID: 16991653
Hmmm.. Can't see anythign weird. Are there any german resource bundle files? Can you make a search?
0
 

Author Comment

by:PierreHoffmann
ID: 17001100
After some examinations I found out:
Some of the imported jars (e.g. "jaxb-api.jar") contains *.properties files for the creation of the ResourceBundle (e.g. "Messages.properties"). But the files seems to be ignored. After extracting the *.properties files from the jars and copying to the appropriate package directorys the files were used and the exception no longer occurs.

Maybe someone has a hint why the *.properties files in the jars will be ignored ....
0
 
LVL 35

Expert Comment

by:girionis
ID: 17001135
They shouldn't be ignored. Maybe the class was trying to find them but they were in differemt location. Anyway since you foudn a solution I suggest you ask for a FAQ & points refunded.
0
 
LVL 35

Expert Comment

by:girionis
ID: 17001137
> FAQ

I meant PAQ
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 17004527
Closed, 250 points refunded.
GhostMod
Community Support Moderator
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now