Cannot find cache named - spring-bean

I'm trying to use gemfire in my app to do caching. Here's my properties:
<context:component-scan base-package="my-base-package"/>
<context:annotation-config/>
<!-- Gemfire transation manager -->
<gfe:transaction-manager id="transactionManager" cache-ref="propertyGemfireCache"/>
<!-- Gemfire properties -->
<util:properties id="gemfire-props"
location="classpath:conf/environments/gemfire.properties"/>
<!-- Gemfire Client cache -->
<gfe:client-cache id="propertyGemfireCache" properties-ref="gemfire-props"
pool-name="gemfire-pool" pdx-serializer-ref="pdxSerializer" pdx-persistent="true"/>
<!-- Gemfire PDX serializer -->
<bean id="pdxSerializer" class="com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer">
<property name="serializableClasses">
<list>
<value>com\.acmecorp\.enterprise\.property\..*,java\.util\..*</value>
</list>
</property>
</bean>
<!-- Gemfire connection pool -->
<bean id="gemfire-pool" class="org.springframework.data.gemfire.client.PoolFactoryBean">
<property name="subscriptionEnabled" value="true"/>
<property name="freeConnectionTimeout" value="60000"/>
<property name="prSingleHopEnabled" value="true"/>
<property name="locators" ref="gemfireLocators"/>
</bean>
<bean id="gemfireCacheManager" class="org.springframework.data.gemfire.support.GemfireCacheManager"
p:cache-ref="propertyGemfireCache"/>
<gfe:client-region id="myRegion" name="${cache.region.name}" statistics="true"
cache-ref="propertyGemfireCache" shortcut="LOCAL">
<gfe:region-ttl timeout="86400"/>
</gfe:client-region>
<bean id="myTemplate" class="org.springframework.data.gemfire.GemfireTemplate">
<property name="region" ref="myRegion"/>
</bean>
<cache:advice id="myAdvice" cache-manager="gemfireCacheManager">
<cache:caching>
<cache:cacheable cache="myRegion" method="getSomeData"
key="''+#data"/>
</cache:caching>
</cache:advice>
<aop:config>
<aop:advisor advice-ref="myAdvice"
pointcut="execution( * *..ServiceImpl.getData(..)) and within(another-my-package.service.impl..*)"/>
</aop:config>
Property cache.region.name is equal to correct_region_name.
If I run my app i will get an error like:
Cannot find cache named 'myRegion' for CacheableOperation[] caches=[myRegion]
But if I replace "myRegion" with the correct region, which is correct_region_name. So it would look like this:
<cache:cacheable cache="correct_region_name" method="getSomeData"
key="''+#data"/>
Everything will work perfectly, but i don't need that. Any Help?

Spring (Data GemFire) looks up the Cache "name" in Spring's Cache Abstraction by the name of the Region (a.k.a. Cache; which is not necessarily the bean ID, which is set here, since the RegionLookupFactoryBean implements BeanNameAware).
You might try...
<cache:cacheable cache="${gemfire.region.name}" method="getSomeData" key="''+#data"/>

I think there may be an issue with using the property place holder ${cache.region.name} in the client-cache config and the order in which Spring resolves these things. Does it work if you hard code the region name there?

Related

How to configure an attribute to be edited with a RichTextBox editor in SmartEdit?

I noticed that CMSParagraphComponent's content attribute can be edited using a RichTextBox like depicted in below image:
I want to edit my custom attribute in the same way(with the depicted RichTextBox). How can I do that ?
I tried configuring the backoffice-config.xml to use the wysiwyg:
<context merge-by="type" type="MyType" component="editor-area" module="moduleBackoffice">
<editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea">
<editorArea:tab merge-mode="replace" name="hmc.properties">
<editorArea:section name="hmc.properties">
<editorArea:attribute
editor="com.hybris.cockpitng.editor.localized(com.hybris.cockpitng.editor.wysiwyg)"
qualifier="customStringAttribute"/>
</editorArea:section>
</editorArea:tab>
</editorArea:editorArea>
</context>
But this only reflects in backoffice and has no effect on SmartEdit.
How can I use the RichTextBox in smartEdit ?
Hybris version: 6.7.0.3
This can be resolved by creating below Spring bean:
<bean class="de.hybris.platform.cmsfacades.types.service.impl.DefaultComponentTypeAttributeStructure" p:typecode="MyType" p:qualifier="customStringAttribute">
<property name="populators">
<set>
<ref bean="richTextComponentTypeAttributePopulator" />
<ref bean="requiredComponentTypeAttributePopulator" />
</set>
</property>
</bean>
I added above defined bean in my ${extensionname}-spring.xml, restarted the server and everything worked as expected. The MyType's customStringAttribute is now configurable from smartedit in the exact same way as CMSParagraphComponent's content is.

How to configure Payara JDBCRealm/jdbcDigestRealm to store passwords in httpd style

I'm using a JDBCRealm with JAAS Context=jdbcDigestRealm in Payara to do http digest auth. If I set it up to use clear text passwords in my user database, everything works as expected. But I would like to store the passwords as MD5(username:realm:password) in the database, much like Apache httpd does. Unfortunately cannot find settings in the JDBCRealm to handle that. Storing clear text passwords is of course not desirable.
How should I configure the settings of the JDBCRealm in Payara to allow using passwords stored as MD5(username:realm:password) ?
This is my working setup with clear text passwords:
<auth-realm classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm" name="digestrealm">
<property name="jaas-context" value="jdbcDigestRealm"></property>
<property name="datasource-jndi" value="jdbc/userrepo"></property>
<property name="user-table" value="usertable"></property>
<property name="user-name-column" value="username"></property>
<property name="password-column" value="password"></property>
<property name="group-table" value="grouptable"></property>
<property name="group-name-column" value="groupname"></property>
<property name="charset" value="UTF-8"></property>
<property name="digest-algorithm" value="None"></property>
</auth-realm>
I found the answer myself after browsing through the Payara source code a while. By setting the property "Encoding" to "Hashed" on the JDBC realm, passwords in the database are assumed to be in format MD5(username:realm:password).
This feature seems to be entirely undocumented.
<auth-realm classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm" name="digestrealm">
<property name="jaas-context" value="jdbcDigestRealm"></property>
<property name="datasource-jndi" value="jdbc/userrepo"></property>
<property name="user-table" value="usertable"></property>
<property name="user-name-column" value="username"></property>
<property name="password-column" value="password"></property>
<property name="group-table" value="grouptable"></property>
<property name="group-name-column" value="groupname"></property>
<property name="charset" value="UTF-8"></property>
<property name="digest-algorithm" value="None"></property>
<property name="encoding" value="HASHED"></property>
</auth-realm>

inbound-channel-adapter cannot ignore "directory" tag element when using custom scanner

I use spring integration 4.2.6.RELEASE and try to create custom file watcher
something like this:
<int-file:inbound-channel-adapter id="filesInAdapter" directory="#{pojoUtil.sourceRootDir}" auto-create-directory="true"
channel="filesInChannel" scanner="watchDirectoryScanner" auto-startup="true">
<int:poller ref="globalPoller"/>
</int-file:inbound-channel-adapter>
<!-- directory scanner org.springframework.integration.file.WatchServiceDirectoryScanner -->
<!--id.lsa.scb.spring.integration.scanner.CustomScanner-->
<bean id="nioLocker" class="org.springframework.integration.file.locking.NioFileLocker"/>
<bean id="watchDirectoryScanner" class="id.lsa.scb.spring.integration.scanner.AdrFileScanner">
<constructor-arg value="#{pojoUtil.sourceRootDir}"/>
<property name="autoStartup" value="true"/>
<property name="filter" ref="compositeFilter"/>
<property name="locker" ref="nioLocker"/>
<property name="adrUtil" ref="pojoUtil"/>
</bean>
How to ignore directory tag element in int-file:inbound-channel-adapter? Because I thought we don't need that if the directory initiated in custom the file scanner. I have customize the file scanner so it can registering a list of directory into file watcher without need to watch the root of that list.
This has been resolved in 4.3 which should be released in the next week or so. It's available in the release candidate.
For now, you need to specify the directory in both places.

Using Sphinx4 and es_MX_broadcast_cont_2500

I currently work in developing an audio transcriber of short Spanish(MX) interviews (length~2min). I've been surfing on the web but can't find this one, maybe it's too easy :/ . While running the .jar i get this warning for (i presume) all the word with accents in the /etc/h4.dict from the es_MX_broadcast... voxforge package and no transcription or other errors at all.
...
WARNING dictionary The dictionary is missing a phonetic transcription for the word 'kyrgyzst�'
'WARNING dictionary The dictionary is missing a phonetic transcription for the word 'explotaci�'
WARNING dictionary The dictionary is missing a phonetic transcription for the word 'inclu�'
...
My clue is that maybe there are some configuration issues with the text encoder but maybe i need to create the language model. I really want to train it, but first i need it working. Here is the linguist/dictionary/language_model/acoustic_model part of config.xml file
<component name="lexTreeLinguist"
type="edu.cmu.sphinx.linguist.lextree.LexTreeLinguist">
<property name="logMath" value="logMath"/>
<property name="acousticModel" value="wsj"/>
<property name="languageModel" value="trigramModel"/>
<property name="dictionary" value="dictionary"/>
<property name="addFillerWords" value="false"/>
<property name="fillerInsertionProbability" value="1E-10"/>
<property name="generateUnitStates" value="false"/>
<property name="wantUnigramSmear" value="true"/>
<property name="unigramSmearWeight" value="1"/>
<property name="wordInsertionProbability"
value="${wordInsertionProbability}"/>
<property name="silenceInsertionProbability"
value="${silenceInsertionProbability}"/>
<property name="languageWeight" value="${languageWeight}"/>
<property name="unitManager" value="unitManager"/>
</component>
<component name="dictionary"
type="edu.cmu.sphinx.linguist.dictionary.FastDictionary">
<property name="dictionaryPath"
value="/home/csampez/Desktop/JavaDev/Sphinx/sphinx4/models/acoustic/es_MX_broadcast_cont_2500/etc/h4.dict"/>
<property name="fillerPath"
value="/home/csampez/Desktop/JavaDev/Sphinx/sphinx4/models/acoustic/es_MX_broadcast_cont_2500/etc/filler.dict"/>
<property name="addSilEndingPronunciation" value="false"/>
<property name="wordReplacement" value="<sil>"/>
<property name="unitManager" value="unitManager"/>
</component>
<component name="trigramModel"
type="edu.cmu.sphinx.linguist.language.ngram.large.LargeTrigramModel">
<property name="unigramWeight" value=".7"/>
<property name="maxDepth" value="3"/>
<property name="logMath" value="logMath"/>
<property name="dictionary" value="dictionary"/>
<property name="location"
value="/home/csampez/Desktop/JavaDev/Sphinx/sphinx4/models/acoustic/es_MX_broadcast_cont_2500/etc/H4.arpa.Z.DMP"/>
</component>
<component name="wsj"
type="edu.cmu.sphinx.linguist.acoustic.tiedstate.TiedStateAcousticModel">
<property name="loader" value="wsjLoader"/>
<property name="unitManager" value="unitManager"/>
</component>
<component name="wsjLoader" type="edu.cmu.sphinx.linguist.acoustic.tiedstate.Sphinx3Loader">
<property name="logMath" value="logMath"/>
<property name="unitManager" value="unitManager"/>
<property name="location" value="/home/csampez/Desktop/JavaDev/Sphinx/sphinx4/models/acoustic/es_MX_broadcast_cont_2500/model_parameters/hub4_spanish_itesm.cd_cont_2500"/>
</component>
------- THIS IS NEW INFORMATION (10/3/2013)----------
Thanks but it isn't the problem. The file was already UTF8 and i've already set the JAVA TOOLS OPTION to UTF8, also run the .jar with the -Dfile.encoding and anything changed, i get the same list. It's strange because i've tried to figure out whether is another dictionary list in the files, but i'm clueless. It's something really weird because the h4.dict is in uppercase and the warnings in lower case, also there are some words with accent that don't appear in the warning list. I tried to save another .dict file with fewer words but it didn't work, in fact more words appeared in the warnings.
I don't know if it matters that i'm not using a .jar for the acoustic model like the ones used in the other demos or if there's a relation with the fact that there's no transcription or other errors at all.
I really hope anyone can help me figure out, in the meanwhile i'll be trying harder.
Many thanks on advance
You need to convert file to UTF-8
You need to use java option -Dfile.encoding=utf-8 to make sure java VM thinks that all input files are in UTF-8
Most importantly, es_MX_broadcast_cont requires specific feature extractor. You need to replace DeltasFeatureExtractor with S3FeatureExtractor in config file. Otherwise accuracy will be zero.

Red5. No scope with my project

i can't create my application with Red5 server. I've got an error
NetConnection.Connect.Rejected: No scope 'TestEcho' on this server.
NetConnection.Connect.Closed
I did something like ping application to test that everything works fine. My class looks like this:
package org.red5.core;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.service.ServiceUtils;
public class Application extends ApplicationAdapter {
public void appDisconnect(IConnection conn)
{
super.appDisconnect(conn);
}
public boolean appStart()
{
return true;
}
public void appStop()
{}
public boolean appConnect(IConnection conn, Object[] params)
{
return true;
}
public Object echo(Object p)
{
return p;
}
}
Also i have red5-web.xml and red5-web.properties
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!--
Defines a properties file for dereferencing variables
-->
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/red5-web.properties" />
</bean>
<!--
Defines the web context
-->
<bean id="web.context" class="org.red5.server.Context"
autowire="byType" />
<!--
Defines the web scopes
-->
<bean id="web.scope" class="org.red5.server.WebScope"
init-method="register">
<property name="server" ref="red5.server" />
<property name="parent" ref="global.scope" />
<property name="context" ref="web.context" />
<property name="handler" ref="web.handler" />
<property name="contextPath" value="${webapp.contextPath}" />
<property name="virtualHosts" value="${webapp.virtualHosts}" />
</bean>
<!--
Defines the web handler which acts as an applications endpoint
-->
<bean id="web.handler"
class="org.red5.core.Application"
singleton="true" />
</beans>
And
webapp.contextPath=/TestEcho
webapp.virtualHosts=127.0.0.1
So, it's strange but in echo-demo application i can't get connection to rtmp://localhost:1935/TestEcho
And i'd like to notice that demo applications work good, for example, oflaDemo. Where is the problem?....
which version do you use?
if you use red5 1.0, please use
<bean id="web.scope" class="org.red5.server.scope.WebScope" init-method="register">
instead of
<bean id="web.scope" class="org.red5.server.WebScope" init-method="register">
Check the below things
check your folder name with in webapp folder. It should be "TestEcho"
check webAppRootKey in your web.xml file
enable debug in logback.xml in red5 conf folder. check your log while starting.
Ref: https://github.com/arulrajnet/red5Demo/wiki/Different-context-name
I am a bigginer in Red5. I have also Struggled with the same problem. After searching Plenty of forums I have figured it out. In my searching process I have gone through your query also. So I thought it would be helpful if I post solution here.
The problem is with having duplicate red5.jar file. In my scenario I have one jar file in my RED5_HOME and the other in myapp/WEB-INF/lib folder. We should not have two Red5.jar files. red5.jar must be in RED5_HOME directory. So I have removed all the jars including red5.jar from myapp/WEB-INF/lib folder. It Solved my issue.
I just had the very same issue, it was configuration issue with the virtualHost name.
I fixed by changing red5-web.properties from webapp.virtualHosts=localhost to webapp.virtualHosts=*.
Hope it helps
Check something very simple - if you are on Windows - red5 installs and starts a services by default. Then you might have manually copied another version of red5 - which you use for development. That is what happened with me - there was a Windows Service - running red5 - long forgotten. Whereas I was actually running another version of red5 form my filesystem.

Resources