You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.
here is how do I call it:
public void importMessages () {
FileSystemMessageProvider filesystemMessageProvider = new FileSystemMessageProvider("webapp/WEB-INF/i18n");
JdbcMessageProvider jdbcMessageProvider = new JdbcMessageProvider();
MessageProvider source = filesystemMessageProvider;
MessageAcceptor target = jdbcMessageProvider;
Importer importer = new Importer(source, target);
// imports messages of all basenames from source to target
//importer.importMessages();
// or just import some basenames?
Collection<String> basenames = source.getAvailableBaseNames();
for (String basename : basenames) {
LoggerFactory.getLogger(getClass()).info(basename);
importer.importMessages(basename);
}
}
An exception:
ERROR org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task.
java.lang.NullPointerException
at org.synyx.messagesource.jdbc.JdbcMessageProvider.deleteMessages(JdbcMessageProvider.java:141)
at org.synyx.messagesource.jdbc.JdbcMessageProvider.setMessages(JdbcMessageProvider.java:76)
at org.synyx.messagesource.importer.Importer.importMessages(Importer.java:43)
...
As I see in log, basename has been sent to importer.
Could you please reply, if I'm missing something.
And I found small issue in doc you posted, there is
< property name="basename">
< list>
< value>messages</ value>
< value>application</ value>
</ list>
</ property>
Should be
< property name="basenameS">
< list>
< value>messages
< value>application
</ list>
</ property>
basenames - not basename.
Also is there any way to email your team or better way is to post here?
Thanks a lot for your help!
The text was updated successfully, but these errors were encountered:
Please initialize the data source for your jdbcmessageprovider.By calling jdbcMessageProvider.setDataSource("your dataSource");
so after
JdbcMessageProvider jdbcMessageProvider = new JdbcMessageProvider(); this line seems to be the issue.
//add following
jdbcMessageProvider.setDataSource(dataSource);
no, it wasn't proper solution for me due to I had to send datasource as an object, firstly get it from context.
I applied next logic:
< bean class="org.synyx.messagesource.jdbc.JdbcMessageProvider" id="jdbcMessageProvider">
< property name="dataSource" ref="dataSource"/>
< property name="keyColumn" value="messageKey"/>
< property name="tableName" value="message"/>
< property name="basenameColumn" value="basename"/>
< property name="delimiter" value="`"/>
</ bean>
< bean id="messageSource" class="org.synyx.messagesource.InitializableMessageSource">
< property name="messageProvider" ref="jdbcMessageProvider"/>
.....
< /bean>
and
NPE is off now, thanks a lot for your great solution!
Btw, is there any way how to ask messageSource to create new message and save it when returnUnresolvedCode = true?
It will be helpfull, bcoz of database will be auto populated when message is not found.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
here is my config:
< bean id="messageSource" class="org.synyx.messagesource.InitializableMessageSource">
< property name="messageProvider">
< bean class="org.synyx.messagesource.jdbc.JdbcMessageProvider">
< property name="dataSource" ref="dataSource"/>
< property name="keyColumn" value="messageKey"/>
< property name="tableName" value="message"/>
< property name="basenameColumn" value="basename"/>
< property name="delimiter" value="`"/>
</ bean>
</ property>
< property name="basenames">
< list>
< value>messages</ value>
< value>application</ value>
</ list>
</ property>
< property name="returnUnresolvedCode" value="true" />
</ bean>
here is how do I call it:
public void importMessages () {
FileSystemMessageProvider filesystemMessageProvider = new FileSystemMessageProvider("webapp/WEB-INF/i18n");
JdbcMessageProvider jdbcMessageProvider = new JdbcMessageProvider();
MessageProvider source = filesystemMessageProvider;
MessageAcceptor target = jdbcMessageProvider;
An exception:
ERROR org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task.
java.lang.NullPointerException
at org.synyx.messagesource.jdbc.JdbcMessageProvider.deleteMessages(JdbcMessageProvider.java:141)
at org.synyx.messagesource.jdbc.JdbcMessageProvider.setMessages(JdbcMessageProvider.java:76)
at org.synyx.messagesource.importer.Importer.importMessages(Importer.java:43)
...
As I see in log, basename has been sent to importer.
Could you please reply, if I'm missing something.
And I found small issue in doc you posted, there is
< property name="basename">
< list>
< value>messages</ value>
< value>application</ value>
</ list>
</ property>
Should be
< property name="basenameS">
< list>
< value>messages
< value>application
</ list>
</ property>
basenames - not basename.
Also is there any way to email your team or better way is to post here?
Thanks a lot for your help!
The text was updated successfully, but these errors were encountered: