I've seen others having similar problems but nothing I try seems to work. I was originally using Spring, Hibernate, and JSF with straight-up JAR files. I ran into dependency hell and decided to convert my project over to a Maven web application project. The dependency issues no longer occur and I can compile but it throws the following exception at startup. I didn't change anything (file is still at com\example\config.properties) and I was able to use it successfully before migrating to Maven. From what I can tell, there is some additional plugin I am missing but I'm not sure what. I am using Glassfish.
I read somewhere that the src\main\resources folder is suppose to get copied over to a classes folder in WEB-INF but my resources folder is empty.
Any help is much appreciated. My pom.xml is below:
java.util.MissingResourceException: Can't find bundle for base name com.example.config, locale en
I don't see anything obvious. Please post the full build output. You might also want to run the build with the -X option - if that doesn't help you then post the full output. If the output is long (over 50 lines) attached it as a file. Without the full build output it is difficult to tell during which phase this error occurs.
I don't think the -X option will help because I don't think it's getting into the deployment. I remember reading somewhere that the maven plugin (not sure which one) is suppose to copy src\main\resources (which contains nothing) into target\classes or something like that. I opened up the WAR file in the target directory and it does not contain the properties files where they should be. It's like the classes are copied over but not the properties files. It has to be some setting with Maven/Netbeans not copying over the files where they should be. This worked before I switched to Maven.
One more thought. You have a very long list of dependencies. Did you by any chance simple convert the list of JARs required by Spring into the dependency list? If so, you do not need to do that. The only dependencies you are are the immediate dependencies for your code. See if this discussion helps: http://www.coderanch.com/t/531762/tools/Ant-Maven-Converter#2412051
Joined: Apr 01, 2011
I was able to get my POM.xml down to a smaller size since I am just interested in Spring's hibernate support by using the following:
This still doesn't solve the MissingResourceException. I found the following document describing web resources on the maven site. I am almost positive the war plugin is not copying the properties files over with the rest of the deployment. If I open the WAR file created, it does not contain the properties files but it contains the class files.
target\classes\com\example - contains compiled class files
target\example - contains facelets pages AND the messages.properties files from src\main\java\com\example\i18n (which has _en, _de, etc.)
config is just a default properties file with configuration data for the app. It isn't being used for language support. I already tried adding a <resource> as mentioned on the maven site but that did not help. Why would maven copy messages.properties (and all locale specific variations) from package com.example.i18n to the root of target\example but not copy config.properties from package com.example? That is the root of the problem. The build is successful. The resource missing exception is a runtime exception. Any one have any ideas? I've been banging my head on this for the past 6 hours.
The config.properties file is in the wrong location, it should be at src\main\resources\com\example. Only Java source files go into src\main\java and its subdirectories. The src/main/resources directory is for file other than Java source files that need to be placed into a JAR/WAR/etc. Thus this is where properties files, xml config files, and the like goes - anything that needs to be in the classpath but is not a Java source file.