Solved

java.util.MissingResourceException during JAXB unmarschal

Posted on 2006-06-27
9
1,154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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
 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

636 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