Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8007283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:46:29+00:00 2026-06-04T17:46:29+00:00

I am creating a Java unit test to test some code I recently changed.

  • 0

I am creating a Java unit test to test some code I recently changed. However, the method I am testing instantiates a class which uses ResourceBundle …

ResourceBundle.getBundle("businessVariables").getString("product.name"));

The resource file lives in the web package at Mycompany_web/src/main/webapp/WEB-INF/classes/businessVariables.properties

My test lives in my xml package at Mycompany_xml/src/test/java/uk/co/mycompany/xmlapi/RequestProcessorTestNew.java

During normal runtime the resource bundle is accessible, but not when my unit test is run. It throws this error …

Testcase: testCreateInitialStatusResponse(uk.co.mycompany.xmlapi.RequestProcessorTestNew):  Caused an ERROR
null
java.lang.reflect.InvocationTargetException
    at uk.co.mycompany.xmlapi.RequestProcessorTestNew.testCreateInitialStatusResponse(RequestProcessorTestNew.java:62)
Caused by: java.lang.ExceptionInInitializerError
    at uk.co.mycompany.xmlapi.RequestProcessorImpl.createInitialStatusResponse(RequestProcessorImpl.java:812)
Caused by: java.util.MissingResourceException: Can't find bundle for base name businessVariables, locale en_US

What should I do? Can I enable my test to see the resource bundle somehow? Can I create a mock resource file somewhere which somehow the code will be able to see?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:46:30+00:00Added an answer on June 4, 2026 at 5:46 pm

    If you have build your project structure according to Maven archetype, your resource bundle should ideally be in Mycompany_xml/src/test/resources. Then you can run unit tests from project home i.e. Mycompany_xml directory using mvn test.

    While packaging the war, copy the resource bundle from Mycompany_xml/src/test/resources to the war using maven-assembly-plugin.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a new Grails project that uses some Java code to do
I am creating a java app. I have one class q2a2 which is a
I tried creating a test project with maven and the unit testing worked fine.
I'm creating Java wrappers for some C code using JNI. There are dependencies on
I'm new to unit testing using nunit (and Java development in general). When creating
Unit test is in Java, using Maven to build & run. I can use
is there some RAD tool for creating java apps with event driven flow ?
I am creating a Java application in which I need to read the first
I'm creating a library that includes both Clojure and Java code, and would like
I remember there existed a testing program/library that will run your code and/or unit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.