messageSource bean: ResourceBundle$Control is a restricted class

491 views
Skip to first unread message

Jaroslav Záruba

unread,
Jan 3, 2015, 8:41:46 PM1/3/15
to google-a...@googlegroups.com
Hello

What is the proper way of using message sources on AppEngine please?

This is what I've bumped into:
java.lang.NoClassDefFoundError: java.util.ResourceBundle$Control is a restricted class. Please see the Google App Engine developer's guide for more details. at com.google.apphosting.runtime.security.shared.stub.java.util.ResourceBundle$Control.<clinit>(ResourceBundle.java) at org.springframework.context.support.ResourceBundleMessageSource.doGetBundle(ResourceBundleMessageSource.java:313) at org.springframework.context.support.ResourceBundleMessageSource.getResourceBundle(ResourceBundleMessageSource.java:268) at org.springframework.context.support.ResourceBundleMessageSource.resolveCodeWithoutArguments(ResourceBundleMessageSource.java:231) at org.springframework.context.support.AbstractMessageSource.getMessageInternal(AbstractMessageSource.java:218) at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:151) at org.springframework.context.support.DelegatingMessageSource.getMessage(DelegatingMessageSource.java:66) at org.springframework.context.support.AbstractApplicationContext.getMessage(AbstractApplicationContext.java:1122) at org.thymeleaf.spring4.messageresolver.SpringMessageResolver.resolveMessage(SpringMessageResolver.java:151)

Nothing special here:
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">

       <property name="basename" value="messages/Messages" />

       <property name="cacheSeconds" value="-1" />

</bean>


Regards
  Jarda

Vinny P

unread,
Jan 5, 2015, 2:11:30 AM1/5/15
to google-a...@googlegroups.com
On Sat, Jan 3, 2015 at 7:41 PM, Jaroslav Záruba <jarosla...@gmail.com> wrote:
What is the proper way of using message sources on AppEngine please?

This is what I've bumped into:
java.lang.NoClassDefFoundError: java.util.ResourceBundle$Control is a restricted class. Please see the Google App Engine developer's guide for more details.



Is your source file saved as a UTF8 character encoding? If so, can you try resaving the file as a ISO-8859-1 encoding, and see if that solves your issue? An explanation of how to convert is here: http://stackoverflow.com/a/4660195

If everything else fails, you can move to using Managed VMs ( https://cloud.google.com/appengine/docs/managed-vms/ ) where you can use restricted classes.
 
 
-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

Jaroslav Záruba

unread,
Jan 5, 2015, 10:34:48 AM1/5/15
to google-a...@googlegroups.com
I was hoping I could avoid that somehow, but I guess there's no way around it, I will change the encoding.

Thank you, Vinny! :)

Jaroslav Záruba

unread,
Jan 5, 2015, 12:21:51 PM1/5/15
to google-a...@googlegroups.com
Changing the encoding didn't help in the end. I downloaded sources and it turns out the cache configuration was the issue:

if((this.defaultEncoding != null && !"ISO-8859-1".equals(this.defaultEncoding)) || !this.fallbackToSystemLocale || this.cacheMillis >= 0)
       
return ResourceBundle.getBundle(basename, locale, getBundleClassLoader(), new MessageSourceControl());


...mine was set to "0" for development.


On Sunday, January 4, 2015 2:41:46 AM UTC+1, Jaroslav Záruba wrote:

Ivan Martinov

unread,
Feb 17, 2015, 12:21:36 AM2/17/15
to google-a...@googlegroups.com
I am running into the same issue because I am attempting to change the encoding the messageSource bean is using to UTF-8.

In my case I am internationalizing my app and have properties in 2 different languages, obviously the non-English language requiring UTF-8 encoding.  

I was looking forward to using gae for this project, but this is definitely a huge roadblock.


Ivan Martinov

unread,
Feb 17, 2015, 7:11:37 PM2/17/15
to google-a...@googlegroups.com
I was able to use ReloadableResourceBundleMessageSource  instead and that can load UTF-8 files without any issues with app engine!
Reply all
Reply to author
Forward
0 new messages