vlad wrote:
Quote:
Correct me if I am wrong. I do not need persistence.xml file anymore right ?
You don't need it if you are using the Hibernate-specific bootstrap.
Quote:
And then, I changed the connection to a singleton connection though I am abit stumped how to chain it to the hibernate utility....
I see that you want to create a ProxyDataSource, but did you provide that to Hibernate?
You could pass a custom DataSource to Hibernate via the hibernate.connection.datasource configuration property which can take:
- a JNDI string
- a DataSource object reference
However, you need to switch to the new boostrap API since this one, based on Configuration object, will be deprecated soon. Check out
this GitHub test case for more details about how to do that.
Hi,
I got the below error but I am not sure what's happening regarding the connection portion.
Code:
2017-09-18 11:15:58,996 http-nio-8013-exec-6 ERROR Null object returned for Jdbc in appenders.
2017-09-18 11:15:59,000 http-nio-8013-exec-6 ERROR No ConnectionSource provided: connectionSource
2017-09-18 11:15:59,003 http-nio-8013-exec-6 ERROR Unable to inject fields into builder class for plugin type class org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender, element Jdbc. org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element Jdbc are invalid
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:198)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
Code:
2017-09-18 11:15:59,014 http-nio-8013-exec-6 ERROR Null object returned for Jdbc in appenders.
2017-09-18 11:15:59,071 http-nio-8013-exec-6 ERROR Unknown object "Logger" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"].
2017-09-18 11:15:59,102 http-nio-8013-exec-6 ERROR Unknown object "Logger" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"].
2017-09-18 11:15:59,104 http-nio-8013-exec-6 ERROR Unknown object "logger" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"].
2017-09-18 11:15:59,108 http-nio-8013-exec-6 ERROR Unknown object "logger" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"].
2017-09-18 11:15:59,111 http-nio-8013-exec-6 ERROR Unknown object "Root" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"].
2017-09-18 11:15:59,113 http-nio-8013-exec-6 ERROR Unable to locate appender "databaseAppender" for logger config "root"
Initial SessionFactory creation failed.org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Sep 18, 2017 11:16:02 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [tutorController] in context with path [/Hi5S] threw exception [Servlet execution threw an exception] with root cause
javax.naming.NameNotFoundException: Name [hi5"/>] is not bound in this Context. Unable to find [hi5"].
at org.apache.naming.NamingContext.lookup(NamingContext.java:818)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.NamingContext.lookup(NamingContext.java:829)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.NamingContext.lookup(NamingContext.java:829)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.NamingContext.lookup(NamingContext.java:829)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:134)
at javax.naming.InitialContext.lookup(InitialContext.java:421)
at org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:97)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:98)
I have included the below inside hibernate.cfg.xml and removed all the username, password as one of the advice given in stackoverflow.
Code:
<!-- Connection Pool Size (built-in) -->
<property name="connection.pool.size">1</property>
<!-- SQL Dialect -->
<property name="dialect">org.hibernate.dialect.MySQLMyISAMDialect</property>
For now, I am using the JPA that comes with 'J2ee framework'.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="Hi5S" transaction-type="JTA" >
<class>model.Subject</class>
<class>model.Tutor</class>
<properties>
<!-- Configuring JDBC properties -->
<property name="hibernate.connection.datasource" value="java:comp/env/jdbc/hi5"/>
</properties>
</persistence-unit>
</persistence>
Am not able to figure out what's wrong after doing all the 'necessary' and not sure what's amiss.
Hope to have some advice. tks.