2

Please help to resolve my problem, I am getting below error when I try to run my program on Apache Tomcat. I am using hibernate Core (5.2.9.Final) and Hibernate commons Annotations (5.0.1.Final) in struts2.

Logs information are below:

INFO: Server startup in 41821 ms
25240 [http-nio-8080-exec-7] INFO  org.hibernate.Version  - HHH000412: Hibernate Core {5.2.9.Final}
25247 [http-nio-8080-exec-7] INFO  org.hibernate.cfg.Environment  - HHH000206: hibernate.properties not found
25352 [http-nio-8080-exec-7] WARN  org.hibernate.orm.deprecation  - HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-configuration. Use namespace http://www.hibernate.org/dtd/hibernate-configuration instead.  Support for obsolete DTD/XSD namespaces may be removed at any time.
Hibernate Annotation Configuration loaded
Hibernate Annotation serviceRegistry created
26171 [http-nio-8080-exec-7] INFO  org.hibernate.annotations.common.Version  - HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
26964 [http-nio-8080-exec-7] WARN  org.hibernate.orm.connections.pooling  - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
26988 [http-nio-8080-exec-7] INFO  org.hibernate.orm.connections.pooling  - HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/scale_report?serverTimezone=UTC]
26989 [http-nio-8080-exec-7] INFO  org.hibernate.orm.connections.pooling  - HHH10001001: Connection properties: {user=root, password=****}
26989 [http-nio-8080-exec-7] INFO  org.hibernate.orm.connections.pooling  - HHH10001003: Autocommit mode: false
27023 [http-nio-8080-exec-7] INFO  org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl  - HHH000115: Hibernate connection pool size: 1 (min=1)
28642 [http-nio-8080-exec-7] INFO  org.hibernate.dialect.Dialect  - HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Initial SessionFactory creation failed.java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;

I use following jar files:

antlr-2.7.7<br>
classmate-1.3.0<br>
dom4j-1.6.1<br>
hibernate-commons-annotations-5.0.1.Final<br>
hibernate-core-5.2.9.Final<br>
hibernate-jpa-2.1-api-1.0.0.Final<br>
hibernate-entitymanager-4.2.21.Final<br>
jandex-2.0.3.Final<br>
javassist-3.20.0-GA<br>
jboss-logging-3.3.0.Final<br>
jboss-transaction-api_1.2_spec-1.0.1.Final<br>

com.azalea.ufl.barcode.1.0<br>
commons-collections-3.1<br>
commons-configuration-1.2<br>
commons-fileupload-1.2.1<br>
commons-lang-2.1<br>
commons-logging<br>
cvom<br>
CrystalCommon2<br>
CrystalReportsRuntime<br>
DatabaseConnectors<br>
derby<br>
ejb3-persistence<br>
freemarker-2.3.13<br>
icu4j<br>
jai_imageio<br>
JDBInterface<br>
jrcerom<br>
jstl-1.2<br>
jta-1.1<br>
keycodeDecoder<br>
log4j-1.2.15<br>
logging<br>
mssql-jdbc-7.0.0.jre8<br>
mysql-connector-java-8.0.15<br>
ognl-2.6.11<br>
pfjgraphics<br>
QueryBuilder<br>
sap.com~tc~sec~csi<br>
slf4j-api-1.5.8<br>
slf4j-log4j12-1.5.8<br>
struts2-convention-plugin-2.1.6<br>
struts2-core-2.1.6<br>
webreporting<br>
webreporting-jsf<br>
xmlbeans-2.3.0<br>
xpp3<br>
Xtreme<br>
xwork-2.1.2<br>
gudok
  • 4,029
  • 2
  • 20
  • 30
Amit Jha
  • 23
  • 1
  • 8

1 Answers1

1

Exceptions like this will be thrown usually when there is a problem on the clean-build-deploy process, try manually delete previous compiled code, if in Apache tomcat, go to the folder with deployments and manually delete any past residuals.

EDIT: For future references the specific Exception:

java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map

Is thrown by Hibernate when there's a conflict of libraries, (usually javax.persistence)

the approach suggested is to make sure that the libraries sub-dependencies (the dependencies used by these libraries) are not conflicted, the suggestion given is that itf it is possible to you, eliminate suspected libraries and check when the message reappears and then try to look for a compatible version.

White_King
  • 748
  • 7
  • 21
  • Thank for you reply @White_King, I follow your instruction but still issue persist. I am getting same error. I am printing below error complete message which is printing in jsp page. HTTP Status 500 - type Exception report message description The server encountered an internal error that prevented it from fulfilling this request. exception – Amit Jha Feb 26 '19 at 07:26
  • root cause java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map; org.hibernate.internal.CacheImpl.(CacheImpl.java:71) org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:28) org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:20) org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:58) – Amit Jha Feb 26 '19 at 07:26
  • private static SessionFactory sessionFactory; private static ServiceRegistry serviceRegistry; private static SessionFactory createSessionFactory() { try { Configuration configuration = new Configuration(); configuration.configure("hibernate.cfg.xml"); serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); return sessionFactory; } – Amit Jha Feb 26 '19 at 07:28
  • I see, the problem seems to be similar to this one: https://stackoverflow.com/questions/41761637/hibernate-5-2-7-java-lang-nosuchmethoderror-org-hibernate-engine-spi-sessionf Check it the solution works for you. – White_King Feb 26 '19 at 08:14
  • I already go through that link, but I did not find solution for my project. I am not using MAVEN. If you please specify any jar or library which I am missing here, it would be great. Appreciated you reply. – Amit Jha Feb 26 '19 at 08:23
  • It's not Maven binded (Maven's just a way to handle libraries automatically in this matter) The library that you have: hibernate-jpa-2.1-api-1.0.0.Final is probably using a dependency (persistence-api or similar) & then you must have another library (possibly ejb3-persistence) using the same dependency but with another version, that is why the compiler must be having troubles deciding what to choose. Usually the solution is to make sure both libraries are using the same version of the dependency. Note: I'm clearly separating the words dependency & library but in reality they're indistinctible – White_King Feb 26 '19 at 15:12
  • 1
    Appreciated your reply, Thank you White_King. I got the solution, I remove all the jar and adding one by one based on requirement now it working. – Amit Jha Feb 27 '19 at 03:40