Im using jboss server and primefaces also. I want to use google captcha for my login page. At First it's ok and the captcha showed up, but I want capctha public key and private key stored in properties file. I was made a configuration like this :
web.xml
<listener>
<listener-class>
com.putra.web.CaptchaConfig
</listener-class>
</listener>
<context-param>
<param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name> <!-- SECRET KEY -->
<param-value>${PRIVATE_CAPTCHA_KEY}</param-value>
</context-param>
<context-param>
<param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name> <!-- PUBLIC KEY -->
<param-value>${PUBLIC_CAPTCHA_KEY}</param-value>
</context-param>
CaptchaConfig.java
public class CaptchaConfig implements ServletContextListener {
private static final Logger LOG = LoggerFactory.getLogger(CaptchaConfig.class);
@Override
public void contextDestroyed(final ServletContextEvent event) {
}
@Override
public void contextInitialized(final ServletContextEvent event) {
final String props = "/captcha.properties";
final Properties propsFromFile = new Properties();
try {
LOG.info("### Load captcha config file ###");
propsFromFile.load(getClass().getResourceAsStream(props));
} catch (final IOException e) {
LOG.info("### Error load captcha config file ###");
}
for (String prop : propsFromFile.stringPropertyNames()) {
LOG.info("### Properties Name : {} ###", prop);
LOG.info("### Properties Value : {} ###", propsFromFile.getProperty(prop));
System.setProperty(prop, propsFromFile.getProperty(prop));
}
}
}
captcha.properties
PRIVATE_CAPTCHA_KEY=6Lc2QvgdAAAAAC9rcBbP2RfvVXPf2_xxxxxxxxxx
PUBLIC_CAPTCHA_KEY=6Lc2QvgdAAAAAH2Psp5-ILyWLenJJ4xxxxxxxxxx
I got no error when running the project but the problem is the captcha doesn't show up. What's wrong?
Solved by change :
<spec-descriptor-property-replacement>
false
</spec-descriptor-property-replacement>
to
<spec-descriptor-property-replacement>
true
</spec-descriptor-property-replacement>
on my standalone-full.xml. Thank you!