I use a spring bean to create the DefaultManageableImageCaptchaService instead of a class (I'm not sure it's useful for my request)
<bean id="captchaService" class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService"></bean>
to create the DefaultManageableImageCaptchaService singleton.
I'm using commons-collections-3.2.
Everything is fine under windows xp, but on the solaris one, I got this error.
Error while starting Tomcat
Assertion failed: p != NULL, file ../../../src/share/native/sun/awt/font/t2k/t1.c, line 1974
And Tomcat doesn't load completely.
I don't know if it is a system environment error (I've find that kind of stuff : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5070518 which isn't very explicit) but the jCaptcha lib seems to be the one using fonts.
How to check usable fonts ?
Thanks
SunOS 5.9 Generic_122300-16 sun4u sparc SUNW,Sun-Fire-V210
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Hello
Could you provide the stacktrace for helps us improving the fonts loading ?
Do you try the work around proposed in the sun bug report ?
setenv JAVA_FONTS /usr/openwin/lib/X11/fonts/TrueType
Does it works if you try with a JDK5 ?
If it is still not working you could choose explicit fonts in CaptchaEngine configuration, please take a look at http://forge.octo.com/jcaptcha/confluence/display/general/JCaptcha+and+the+SpringFramework
Regards
There is no stacktrace, the described error appends when I start Tomcat.
Yeah I tried to setenv (actually I tried an "export JAVA_FONTS /usr/openwin/lib/X11/fonts/TrueType" because setenv isn't known).
I'll try some spring configurations.
Thanks for your reply.
Removing pcfont.pfa solves the problem. I'm not sure if it's an important file, but everything works fine without it !
Good, this file is related to the a2ps tool.
See http://www.infres.enst.fr/~demaille/
If you doesnt need it, its a good work around
Thanks for reporting !
Hi,
I 've got a similar error.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'selfRegisterCAController' defined in ServletContext resource /WEB-INF/controller/cas.xml: Cannot resolve reference to bean 'captchaService' while setting bean property 'captchaService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'captchaService' defined in ServletContext resource /WEB-INF/controller/captcha.xml: Cannot resolve reference to bean 'imageEngine' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'imageEngine' defined in ServletContext resource /WEB-INF/controller/captcha.xml: Cannot resolve reference to bean 'CaptchaFactory' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CaptchaFactory' defined in ServletContext resource /WEB-INF/controller/captcha.xml: Cannot resolve reference to bean 'wordtoimage' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wordtoimage' defined in ServletContext resource /WEB-INF/controller/captcha.xml: Cannot resolve reference to bean 'fontGenRandom' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fontGenRandom' defined in ServletContext resource /WEB-INF/controller/captcha.xml: Cannot resolve reference to bean 'fontArial' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fontArial' defined in ServletContext resource /WEB-INF/controller/captcha.xml: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.awt.Font]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
It works fine in XP but neither in Vista nor in Linux.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="captchaEngine"
class="com.octo.captcha.engine.image.gimpy.DefaultGimpyEngine" />
<bean id="captchaService"
class="com.octo.captcha.service.multitype.GenericManageableCaptchaService">
<constructor-arg index="0"><ref bean="imageEngine"/></constructor-arg>
<constructor-arg index="1"><value>180</value></constructor-arg>
<constructor-arg index="2"><value>180000</value></constructor-arg>
</bean>
<bean id="captchaController" class="imi.controller.cas.JCaptchaController">
<property name="captchaService"><ref bean="captchaService"/></property>
</bean>
<bean class="com.octo.captcha.engine.GenericCaptchaEngine" id="imageEngine">
<constructor-arg index="0">
<list>
<ref bean="CaptchaFactory"/>
</list>
</constructor-arg>
</bean>
<bean id="CaptchaFactory" class="com.octo.captcha.image.gimpy.GimpyFactory" >
<constructor-arg><ref bean="wordgen"/></constructor-arg>
<constructor-arg><ref bean="wordtoimage"/></constructor-arg>
</bean>
<bean id="wordgen" class= "com.octo.captcha.component.word.wordgenerator.DictionaryWordGenerator" >
<constructor-arg><ref bean="filedict"/></constructor-arg>
</bean>
<bean id="filedict" class="com.octo.captcha.component.word.FileDictionary" >
<constructor-arg index="0"><value>toddlist</value></constructor-arg>
</bean>
<bean id="wordtoimage" class="com.octo.captcha.component.image.wordtoimage.ComposedWordToImage" >
<constructor-arg index="0"><ref bean="fontGenRandom"/></constructor-arg>
<constructor-arg index="1"><ref bean="backGenUni"/></constructor-arg>
<constructor-arg index="2"><ref bean="simpleWhitePaster"/></constructor-arg>
</bean>
<bean id="fontGenRandom" class="com.octo.captcha.component.image.fontgenerator.RandomFontGenerator" >
<constructor-arg index="0"><value>40</value></constructor-arg>
<constructor-arg index="1"><value>50</value></constructor-arg>
<constructor-arg index="2">
<list>
<ref bean="fontArial"/>
<ref bean="fontVerdana"/>
</list>
</constructor-arg>
</bean>
<bean id="fontArial" class="java.awt.Font" >
<constructor-arg index="0"><value>Arial</value></constructor-arg>
<constructor-arg index="1"><value>0</value></constructor-arg>
<constructor-arg index="2"><value>10</value></constructor-arg>
</bean>
<bean id="fontVerdana" class="java.awt.Font" >
<constructor-arg index="0"><value>Verdana</value></constructor-arg>
<constructor-arg index="1"><value>0</value></constructor-arg>
<constructor-arg index="2"><value>10</value></constructor-arg>
</bean>
<bean id="backGenUni" class="com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator" >
<constructor-arg index="0"><value>300</value></constructor-arg>
<constructor-arg index="1"><value>100</value></constructor-arg>
</bean>
<bean id="simpleWhitePaster" class="com.octo.captcha.component.image.textpaster.SimpleTextPaster" >
<constructor-arg type="java.lang.Integer" index="0"><value>3</value></constructor-arg>
<constructor-arg type="java.lang.Integer" index="1"><value>5</value></constructor-arg>
<constructor-arg type="java.awt.Color" index="2">
<ref bean="colorBlack"/>
</constructor-arg>
</bean>
<bean id="colorBlack" class="java.awt.Color" >
<constructor-arg index="0"><value>0</value></constructor-arg>
<constructor-arg index="1"><value>0</value></constructor-arg>
<constructor-arg index="2"><value>0</value></constructor-arg>
</bean>
</beans>
There is no pcfont.pfa (at least in the Vista machine) to remove.
Any clues?