I am getting exception "Could not parse configuration" - nhibernate-mapping

below are the details of exception I got:
Exception in thread "main" org.hibernate.HibernateException: Could not
parse configuration:<br>
<br> hibernate.cfg.xml<br><br>
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
at com.javatpoint.mypackage.StoreData.main(StoreData.java:14)<br>
Caused by: org.dom4j.DocumentException:Read timed out Nested exception:
Read timed out<br> <br>
at org.dom4j.io.SAXReader.read(SAXReader.java:484)<br>
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
<br>
... 2 more
This is hibernate.hbm.xml I have coded. I am using MySQL through
XAMPP as backend. Could you please help to
solve this? 'hr' is database name which I am using. username is
root.password is left blank.
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="hbm2ddl.auto">update</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<propertyname="connection.url">jdbc:mysql://localhost:3306/hr</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property
name="connection.driver_class">com.mysql.jdbc.Driver</property>
<mapping resource="employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>

There is a typo in your hibernate.cfg.xml file: a space is missing between the tag name property and the attribute name name. Change this line:
<propertyname="connection.url">jdbc:mysql://localhost:3306/hr</property>
to this:
<property name="connection.url">jdbc:mysql://localhost:3306/hr</property>

Related

Spring 4 lazy-init not honoured for org.springframework.jms.listener.adapter.MessageListenerAdapter?

I'm trying to convert a Spring 3 app to Spring 4 (4.3.2.RELEASE) but I can't get org.springframework.jms.listener.adapter.MessageListenerAdapter to lazy load anymore.
To isolate the problem I removed all references to the following bean def but it still tries to load and throws a java.lang.NoClassDefFoundError: javax/jms/MessageListener, which is a runtime dependency that I am not providing on purpose in this setup:
<bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter" lazy-init="true" scope="prototype">
<property name="defaultListenerMethod" value="handleRequest"/>
<property name="defaultResponseDestination" ref="defaultResponseDestination" />
<property name="delegate" ref="stringRequestToStreamRequestHandler" />
</bean>
Is this expected behaviour or a bug?

can not resolve property tag with job parameter

I am trying to concatenate the job parameter, #{jobParameters['arg1']} with myfeed.query to dynamically pick the right query from the properties file. But it's not getting resolved.
below is the exception log
Caused by: org.springframework.jdbc.BadSqlGrammarException: Executing query; bad SQL grammar [${myfeed.queryZONE1}]
below is the code snippet in the xml file.
<bean id="itemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step">
<property name="dataSource" ref="dataSource" />
<property name="sql">
<value>${myfeed.query#{jobParameters['arg1']}}</value>
</property>
<property name="rowMapper">
<bean class="com.sgcib.loa.matrix.mapper.MyFeedRowMapper" />
</property>
</bean>
To do that, you will need to declare explicit properties for your PropertyPlaceholderConfigurer :
<bean id="propertiesConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties" ref="properties" />
</bean>
<bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location">
<value>file:xxxxxxx.properties</value>
</property>
</bean>
Then using Spring Expression Language (spEL), you can get the right property with :
<property name="sql" value="#{properties.getProperty('myfeed.query' + jobParameters['arg1'])}" /></property>
Note that this solution maintains compatibility with ${...} syntax.
The above solution does not work, tested solution is One ItemReader, 2 SQL Query, jdbcTemplate?
http://incomplete-code.blogspot.in/2013/06/dynamically-switch-sql-statements-in.html

NHibernate Configuration Settings

This is my Configuration file. I have a database that name is Basin.
My sql server editon is 2012 express.
also, My Project name is NHibernate_Test
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<propert name="query.substitutions">hqlFunction=SQLFUNC</propert>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Data Source=(local);Initial Catalog=Basin; Integrated Security=True; </property>
<property name="show_sql">true</property>
<mapping assembly="NHibernate_Test"/>
</session-factory> </hibernate-configuration> </configuration
But I am getting a error
Error : An exception occurred parsing configuration :The element 'session-factory' in namespace 'urn:nhibernate-configuration-2.2' has invalid child element 'propert' in namespace 'urn:nhibernate-configuration-2.2'. List of possible elements expected: 'property, mapping, class-cache, collection-cache, event, listener' in namespace 'urn:nhibernate-configuration-2.2'.
It is at the line:
<propert name="query.substitutions">hqlFunction=SQLFUNC</propert>
exactly as in the exception:
..has invalid child element 'propert' in namespace..
we need
<property...
see the property with y at the end

Non jta datasource connection on JBoss AS 7.1

Hi i'm new baby for Jboss:D.
This error few day my headache.
javax.persistence.PersistenceException: Exception [EclipseLink-4003]
(Eclipse Persistence Services - 2.3.1.v20111018-r10243):
org.eclipse.persistence.exceptions.DatabaseException Exception
Description: Configuration error. Class
[com.microsoft.jdbc.sqlserver.SQLServerDriver] not found.
My JBoss standalone.xml driver tag:
<driver name="MSSQLXA" module="com.microsoft.sqlserver"> <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class></driver>
My application persistence.xml:
<persistence-unit name="Entities" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<property name="eclipselink.ddl-generation"
value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
<property name="javax.persistence.jdbc.driver"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<property name="javax.persistence.jdbc.url"
value="jdbc:sqlserver://192.168.100.5:1433;databaseName=ADiamond;"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password"
value="diamond"/>
<property name="eclipselink.jdbc.exclusive-connection.mode"
value="Transactional"/>
<property name="eclipselink.cache.shared.default" value="false"/>
<property name="javax.persistence.cache.storeMode" value="REFRESH"/>
</properties>
Thanks.
Throwing an error saying that JDBC driver class was not found. Download SQL Server JDBC driver and copy in to <JBOSS_HOME>\common\lib folder and check your program.

NHibernate Oracle Connection?

I am setting up an Oracle connection for NHibernate for the first time. I have copied the Oracle.DataAccess.dll file into my bin folder. No matter what I try, I keep getting the same error:
Could not load type >NHibernate.Driver.OracleDataClientDriver. Possible cause: no assembly name specified.
I am using the following configuration:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="DefaultSessionFactory">
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.Oracle9Dialect</property>
<property name="connection.driver_class">>NHibernate.Driver.OracleDataClientDriver</property>
<property name="connection.connection_string">Data Source=DB;User ID=USERPassword=****;</property>
<property name="show_sql">true</property>
<mapping assembly="NHibernateExample.DataAccess"/>
</session-factory>
</hibernate-configuration>
I have previously only set up NHibernate for SQL Server. Am I missing anything here?
Did you copy and paste the code? because there's an extra > in there, in the connection.driver_class line
Semi colon seperator missed between user id value and password.
Excellent step by step tutorial on connecting NHibernate to Oracle:
http://nhbwithoracle.blogspot.com/
Once I had a similar problem, and I fixed it by adding hibernate to the property names, in your case:
<property name="hibernate.connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="hibernate.dialect">NHibernate.Dialect.Oracle9Dialect</property>
<property name="hibernate.connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
<property name="hibernate.connection.connection_string">Data Source=DB;User ID=USERPassword=****;</property>
Hope it helps