Tesseract - ERROR net.sourceforge.tess4j.Tesseract - null - java

Created a java application that uses Tesseract in order to convert a given image or pdf to a string format, when running it on my machine as a unit test using junit it runs great but when running the full system which is a restFul API run by tomcat that receives the image and runs Tesseract it gives me the following error:
23:22:36.511 [http-nio-9999-exec-3] ERROR
net.sourceforge.tess4j.Tesseract - null
java.lang.NullPointerException: null at
net.sourceforge.tess4j.util.PdfUtilities.convertPdf2Png(PdfUtilities.java:107)
at
net.sourceforge.tess4j.util.PdfUtilities.convertPdf2Tiff(PdfUtilities.java:48)
at
net.sourceforge.tess4j.util.ImageIOHelper.getIIOImageList(ImageIOHelper.java:343)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:213) at
net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:197) at
ocr.OcrUtil.getString(OcrUtil.java:54) at
com.tapd.server.api.handlers.IRSHandler.uploadIRSImage(IRSHandler.java:65)
at
com.tapd.server.api.WebAPIService.updateParentIrsForm(WebAPIService.java:250)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at
org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at
org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at
org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:309)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) at
org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) at
org.glassfish.jersey.internal.Errors.process(Errors.java:315) at
org.glassfish.jersey.internal.Errors.process(Errors.java:297) at
org.glassfish.jersey.internal.Errors.process(Errors.java:267) at
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at
org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:292)
at
org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1139)
at
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:460)
at
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386)
at
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334)
at
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
at
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
at
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source) [2016-09-14 23:22:36,512]
[ERROR] java.lang.NullPointerException
My guess is that the tessdata folder is not located in the right place and when packaged into a Jar and run by tomcat it is misplaced, but I couldn't figure out where it should be located and I have double checked to see that all Jars are deployed correctly.
Edit: so it appears that Tesseract can't handle the path when it is on a remote server such as AWS S3, so the question is why? and how can I allow it to use a path from S3? (yes the file is public)

My guess is that there is GhostscriptException which is not logged properly, and this is causing NullPointerException:
https://github.com/nguyenq/tess4j/blob/212d72bc2ec8b3a4d4f5a18f1eb01a0622fc5521/src/main/java/net/sourceforge/tess4j/util/PdfUtilities.java#L107
106 } catch (GhostscriptException e) {
107 logger.error(e.getCause().toString(), e);
108 } finally {
In line 107 - e.getCause() is (probably) null, calling null.toString() throws NPE.
(from the specs - getCause can be null:
https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html#getCause(), GhostscriptException is also allowing the cause to be null: http://grepcode.com/file/repo1.maven.org/maven2/org.ghost4j/ghost4j/1.0.0/org/ghost4j/GhostscriptException.java)
To verify this answer (without recompiling the whole tess4j) you could start your program in the debug mode and put a breakpoint at line 107. This will give you information about the real Exception.

As #Piotr R mentioned the error was ghostscriptException.getCause() is null and the reason for that is that the path configured in the file object sent to Tesseract was not a valid one, now the definition of valid for Tesseract is a bit different then yours, he consider only a local address as valid, so when setting a file located on AWS S3 even if it's public it will throw an error.
The solution was saving it locally and deleting it after Tesseract is done.

Resources I used: Windows 10 (tried on Windows Server 2016 as well), JAVA, MAVEN
Status: Working good on my local as well as VM
Download Tess4J-3.4.8 from here http://tess4j.sourceforge.net/ and set your ENV variable path under Advance System Setting
Get repo from MAVEN -
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.ghost4j</groupId>
<artifactId>ghost4j</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.lept4j</groupId>
<artifactId>lept4j</artifactId>
<version>1.7.0</version>
</dependency>
Get libtesseract302.dll and copy to "C:\Windows\System32" folder
from here http://api.256file.com/libtesseract302.dll/en-download-56466.html
do not forget to set your ENV variable path under Advance System Setting
Download and install Visual C++ 2015 Redistributable or VC++ 2017 Redistributable (I installed both )
from here https://programmer.help/blogs/net.sourceforge.tess4j.tesseractexception-java.lang.nullpointerexception.html
then do restart your PC
on Safer side can have some Jar files if you dont have already in local - Please see image
do not forget to set your ENV variable path for JARs under Advance System Setting

Related

How do I fix SEVERE: Allocate exception for servlet after Project clean?

I am working on a dynamic web project using JSP and multiple servlets with tomcat Apache and Eclipse.
I was having multiple problems with Eclipse today and I ran a clean on the project to try to fix some of the issues that I was having and ever since, I'm getting the following error every time a servlet is called.
SEVERE: Allocate exception for servlet [RegisterServlet]
java.lang.ClassNotFoundException: com.ogi.controller.RegisterServlet
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1372)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1195)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:545)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:526)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:763)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:544)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:353)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:616)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:831)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1629)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:830)
This project was working completely fine on localhost before the clean and I have all of the servlets defined in my web.xml file. CATALINA has an environmental variable and I already have the Jar files in my project.
I'm not sure why these errors are occurring and would appreciate some direction on how to attempt to fix this.

Getting An AccessDeniedException with Tomcat?

I want to have access to static resources outside my webapp so that they don't get destroyed every time I redeploy, but I can't seem to get them
I have a servlet that is meant to serve these images via a FileOutputStream, but it can't get the file when I deploy it on my tomcat server - it gives me a java.nio.file.AccessDeniedException.
Error from Catalina Log File
13-Feb-2020 16:53:10.621 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [fileGetter] in context with path [] threw exception
java.nio.file.AccessDeniedException: C:\Users\micro\Pictures\WebsiteStuff\BlogPosts\Test Image 2020-02-12.jpg
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:235)
at java.base/java.nio.file.Files.newByteChannel(Files.java:374)
at java.base/java.nio.file.Files.newByteChannel(Files.java:425)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
at java.base/java.nio.file.Files.newInputStream(Files.java:159)
at java.base/java.nio.file.Files.copy(Files.java:3195)
at ImageGetterServlet.doGet(ImageGetterServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:830)
This is especially strange given that I have allowed permission to the directory in my Catalina.policy file.
Catalina.Policy
grant {
...
permission java.io.FilePermission "C:${file.separator}Users${file.separator}micro${file.separator}Pictures${file.separator}WebsiteStuff", "read, write";
};
For whatever reason, this exact same code (minus the permission) works perfectly in Intellij. However, here it is not able to access the file.
Could anyone let me know why this is happening? Did I set the wrong permission/put the permission in the wrong place?
EDIT: It is NOT a permission problem
I granted everything in Catalina.policy java.security.AllPermission but to no avail, I’m getting the same exception.
I found out what was wrong. Tomcat cannot access anything inside the Users folder - probably a Windows 10 specific problem.
I just put my directory in question in the C: drive so that the path is now C:/WebsiteStuff and everything worked fine.

Tomcat server not working anymore after a stop and restart

I've got an error related to tomcat server. I shut down my server (took a while) and then when a start the server back, an error appears :
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [com.amadeus.security.CCDVAccess#2a9cce4a] with key 'CCDVAccess'; nested exception is javax.management.InstanceAlreadyExistsException: com.amadeus.security:name=CCDVAccess
org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625)
org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:550)
org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:432)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:795)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:632)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1627)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:830)
org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$4.completed(Nio2Endpoint.java:639)
org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$4.completed(Nio2Endpoint.java:617)
org.apache.tomcat.util.net.SecureNio2Channel$1.completed(SecureNio2Channel.java:873)
org.apache.tomcat.util.net.SecureNio2Channel$1.completed(SecureNio2Channel.java:806)
sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
sun.nio.ch.Invoker$2.run(Invoker.java:218)
sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
I know that the error is not related to the code, because nothing change.
I try
to stop and restart many times,
to change the version of the WAR I was using.
to delete the logs and the folder work/catalina
I do not know what else I should try, so I hope some of you has I idea about that. I really think the issue is coming from tomcat but I'm not sure.
Thank for your help
Sébastien
Edit: I solved my issue it was a stupid mistake. I did a backup of my WAR file without changing the extension... Therefore tomcat was launching 2 identicals servers.
Thanks guys for your help
it seems you have two Spring Boot apps in the same JVM so you need to segregate the MBean namespace.
the first log error tell you that.
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable
to register MBean [com.amadeus.security.CCDVAccess#2a9cce4a] with key
'CCDVAccess'; nested exception is
javax.management.InstanceAlreadyExistsException:
com.amadeus.security:name=CCDVAccess
for further clarification
https://github.com/spring-cloud/spring-cloud-config/issues/118.

Exceptions in projects after Tomcat server upgrade

We are trying to upgrade our Tomcat version from 7.0.73 to a newer version. On ANY higher version everything runs fine except our "DBPrism Servlet Engine". It deploys without any issues, but when running the test it throws the following exception in the C-Prompt:
14-Sep-2017 13:00:36.074 SEVERE [http-nio-8080-exec-3]
org.apache.tomcat.util.digester.Digester.getParser Digester.getParser:
org.xml.sax.SAXNotRecognizedException: SAX feature 'http://apache.org/xml/features/allow-java-encodings' not recognized.
at oracle.xml.parser.v2.NonValidatingParser.setFeature(NonValidatingParser.java:1696)
at oracle.xml.parser.v2.SAXParser.setFeature(SAXParser.java:266)
at oracle.xml.jaxp.JXSAXParserFactory.newSAXParser(JXSAXParserFactory.java:88)
at org.apache.tomcat.util.digester.Digester.getParser(Digester.java:599)
at org.apache.tomcat.util.digester.Digester.getXMLReader(Digester.java:771)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1441)
at org.apache.catalina.authenticator.jaspic.PersistentProviderRegistrations.loadProviders(PersistentProviderRegistrations.java:84)
at org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.loadPersistentRegistrations(AuthConfigFactoryImpl.java:329)
at org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl.<init>(AuthConfigFactoryImpl.java:69)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at javax.security.auth.message.config.AuthConfigFactory$1.run(AuthConfigFactory.java:76)
at javax.security.auth.message.config.AuthConfigFactory$1.run(AuthConfigFactory.java:66)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:65)
at org.apache.catalina.authenticator.AuthenticatorBase.findJaspicProvider(AuthenticatorBase.java:1199)
at org.apache.catalina.authenticator.AuthenticatorBase.getJaspicProvider(AuthenticatorBase.java:1192)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:466)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1374)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
I Have looked at multiple posts from different sites to no avail,
any help would be greatly appreciated
Current setup: Windows 10 with latest JDK - 1.8_144
The solution proposed here worked for me: java.lang.SecurityException: org.xml.sax.SAXNotRecognizedException: Feature: http://apache.org/xml/features/allow-java-encodings
Shutdown the Tomcat server.
Using a text editor open the catalina.properties file. It is usually located in /install-path-to-tomcat/conf/. Make a copy of this file before you continue further.
At the very top of the file add the following properties:
javax.xml.parsers.DocumentBuilderFactory = com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
javax.xml.transform.TransformerFactory = com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
javax.xml.parsers.SAXParserFactory = com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
javax.xml.datatype.DatatypeFactory = com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl
Unfortunately, I can't make easily config changes to Tomcat, I am still looking on how to fix this from the web application that I 'm trying to deploy.

java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session

i am trying to integrate my already working spring project with hibernate, but this is the error i am getting on start up.
EVERE: Servlet.service() for servlet [appServlet] in context with path [/TelephoneDirectory] threw exception [Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;] with root cause
java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
at org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:322)
at org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(SessionFactoryUtils.java:233)
at org.springframework.orm.hibernate3.HibernateTemplate.getSession(HibernateTemplate.java:457)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:393)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:904)
at com.emumba.telephonedirectory.repository.JdbcPersonDao.getPersonsList(JdbcPersonDao.java:36)
at com.emumba.telephonedirectory.service.SimpleDirectoryManager.getAllPersons(SimpleDirectoryManager.java:23)
at com.emumba.telephonedirectory.web.HomeController.home(HomeController.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I have googled it but all i could find was that similar problems were caused by duplicates in classpath but i have looked very closely and i dont think their are any duplicates in my classpath. (may be i am wrong.) Heres a screen shot of jars in my classpath
i am stuck, any help will be greatly appreciated
EDIT: Search for org.hibernate.SessionFactory gives
The problem is that you have hibernate-core-4.0.0.Final.jar in your classpath, but Spring 3.1 uses hibernate-core-3.6.0.Final.jar (see here Spring 3.1 artifact and dependencies).
Remove Hibernate 4.0 and put Hibernate 3.6 instead in your classpath.
BTW, there might some more such miss matches. It's better to use maven to take care of dependencies.
EDIT - some more details
In Hibernate 3.6 the interface Session was in package org.hibernate.classic whereas in Hibernate 4.0 it was moved to the package org.hibernate.
In Hibernate 3.6 the SessionFactory.openSession no longer returns an org.hibernate.classic.Session, rather it returns an org.hibernate.Session. This is a refactor that breaks client code...
If you are using Eclipse as IDE and maven as a build tool, try to check build path entries. Sometimes, old JARs are added as classpath entries which are not overridden by maven clean or update.
You would need to remove those entries.
Refer below image
Above entries should not be present in build path, since they are not overridden by maven clean.
I was having similar kind of trouble; used a different version of apache-camel-extra helped resolving the problem
compile group: 'org.apache-extras.camel-extra', name: 'camel-hibernate', version: '2.18.0'
Our application setup
gradle
apache-camel
spring
hibernate
spring-jta and atomikos
This error is caused by transitive dependency of maven managed projects. Child will be using a particular version of an artefact but the parent would fetch a later version. In my case, I had to use
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.11.Final</version>
</dependency>
</dependencies>
In the parent pom (i.e, I have specified the dependency version again in parent pom) to avoid this conflict.

Categories