0

I am migrating a project from Java 6 to Java 11. In the project I have the following dependency:

<dependency> <groupId>com.octo.captcha</groupId> <artifactId>jcaptcha</artifactId> <version>1.0</version> </dependency> 

As part of migration have based the whole project on Spring Boot with version 2.7.18 and removed most of the old libraries. When I try to use the jcaptcha library, I get an error:

Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/ImageFormatException

Fix 1: I have tried to change the version of jcaptcha into jcaptcha-all, but then another exception is raising:

java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException

Fix 2: I have also updated the ehcache for higher version, but then yet another exception occurred:

[java.io.StreamCorruptedException: unexpected end of block data]
net.sf.ehcache.CacheException: java.io.StreamCorruptedException: unexpected end of block data

I have tried also to shuffle other libraries to find the working solution but so far I did not mage. Is there a way to use com.octo.captcha jcaptcha library in a Java 11 project?

5
  • Last version of the library com.octo.jcaptcha was released in 2013. It is unlikely that is compatible with the current Java ecosystem, which is what those errors are showing. jcaptcha-all seems even older. I would not expect it to work any better. I can only suggest to search for a modern, maintained library and replace the usage in the application. Commented Jan 27 at 17:05
  • @aled I am trying to find something right now. Most of the posts on SO for this kind of solution are around 10 years old.. the most popular solution is reCaptcha from Google which I do not want to use, since I do not want to make http requests to external services. Commented Jan 28 at 6:55
  • You might be aware that asking for recommendations of libraries or anything outside Stack Overflow is off-topic by the current guidelines of Stack Overflow. Commented Jan 28 at 12:12
  • @aled yes I am aware. Thats why my original question is about migration of specific library with solutions I have tried. Commented Jan 28 at 18:10
  • 1
    I understand. Just be aware that the old library may just not be compatible. Commented Jan 28 at 18:33

1 Answer 1

0

In the end I have removed the dependency to the captcha from com.octo.captcha: I replaced it with:

<dependency> <groupId>cn.apiclub.tool</groupId> <artifactId>simplecaptcha</artifactId> <version>1.2.2</version> </dependency> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.