JBOSS deployment having HibernateException on oracle major version 11 - java

Trying to deploy application ear file with following settings in JBoss-4.2.3.GA
jboss-app.xml
<jboss-app>
<loader-repository>
com.xxxx.xxx:loader=<ear-name>
<loader-repository-config>
java2ParentDelegation=false
</loader-repository-config>
</loader-repository>
</jboss-app>
persistence.xml (just a snippet)
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/XXXXFactory"/>
Got following logger info during deployment, I am not sure why an exception is listed in an INFO logger, can I not bother about this?
16:30:07,239 INFO [STDOUT] 16:30:07,238 INFO [SettingsFactory] JDBC driver: Oracle JDBC driver, version: 11.2.0.3.0
javax.ejb.EJBException: org.hibernate.HibernateException: unknown Oracle major version [11]
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
Caused by: org.hibernate.HibernateException: unknown Oracle major version [11]
at org.hibernate.dialect.DialectFactory$1.getDialectClass(DialectFactory.java:135)
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:65)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
Note: We are using JBoss-Seam-2.2.0.GA
Tried: this, this and that
Please let me know if any additional information is required, I am trying to pull back the libs available in jboss to the ear.
Update: Tries
Figured out that the application is using 2 different sessions and
there is one hibernate.cfg.xml also for another legacy code, there
is no dialect specified in it.
So added Oracle10g dialect to
cfg.xml, it stopped throwing above mentioned unknown oracle
version error, but it exceptioned as it couldn't load the
10gDialect.
Beauty is both the sessions are pointing to the same datasource.

Try to add
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
also to JBoss/server/default/deploy/ejb3.deployer/META-INF/persistence.properties.
It works for me with JBoss-4.2.3.GA's bundled Hibernate 3.2.4.sp1 and ojdbc5 11.1.0.6.0 (both in JBoss global libs).
Update
Also recheck that an older version of hibernate is not present somewhere in classpath.
JBoss-Seam-2.2.0.GA distribution bundles hibernate 3.3.1.GA while Hibernate dialect for Oracle Database 11g? suggests that at least Hibernate 3.3.2+ is required for recent JDBC drivers.
JBoss-4.2.3.GA's bundled Hibernate 3.2.4.sp1 may have some modern staff backported.

I've never faced this kind of exception but to me it sounds very clear:
The Hibernate's DialectFactory should maintain some kind mapping of data base engine type
(including version) to the actual dialect. The whole issue is that you don't have a regitered mapping to Oracle 11
As a first bet I would take a look on this particular class. I don't know what version of hibernate do you have, but it looks like Oracle 11 is simply not supported, at least by the source I've found (Take a look here) Take a look on that ''MAPPERS'' hash map and you'll see... Open source rules here ;)
So I think the best would be upgrading the hibernate to the last version (just check that in the last version the mapper is updated).
Or at least debug the application server to figure out what does parameters are passed to the method and so.
Of course its also possible to build your custom version of Hibernate but I don't think it should be considered as a preferable solution.
I would also consider to override the default dialect as you've already found by yourself in 'that' article :) I don't see why it shouldn't work, but again you'd better debug it.
Maybe you should tell the JBoss somewhere that it should use your dialect as well...
Hope this helps

public String getDialectClass(int majorVersion) throws Throwable
{
switch(majorVersion)
{
case 8: // '\b'
return (DialectFactory.class$org$hibernate$dialect$Oracle8iDialect != null ? DialectFactory.class$org$hibernate$dialect$Oracle8iDialect : (DialectFactory.class$org$hibernate$dialect$Oracle8iDialect = DialectFactory._mthclass$("org.hibernate.dialect.Oracle8iDialect"))).getName();
case 9: // '\t'
return (DialectFactory.class$org$hibernate$dialect$Oracle9iDialect != null ? DialectFactory.class$org$hibernate$dialect$Oracle9iDialect : (DialectFactory.class$org$hibernate$dialect$Oracle9iDialect = DialectFactory._mthclass$("org.hibernate.dialect.Oracle9iDialect"))).getName();
case 10: // '\n'
return (DialectFactory.class$org$hibernate$dialect$Oracle10gDialect != null ? DialectFactory.class$org$hibernate$dialect$Oracle10gDialect : (DialectFactory.class$org$hibernate$dialect$Oracle10gDialect = DialectFactory._mthclass$("org.hibernate.dialect.Oracle10gDialect"))).getName();
case 11: // '\013'
return (DialectFactory.class$org$hibernate$dialect$Oracle10gDialect != null ? DialectFactory.class$org$hibernate$dialect$Oracle10gDialect : (DialectFactory.class$org$hibernate$dialect$Oracle10gDialect = DialectFactory._mthclass$("org.hibernate.dialect.Oracle10gDialect"))).getName();
}
throw new HibernateException("unknown Oracle major version [" + majorVersion + "]");
}
actually this is the code in DialectFactory so when your database version changes above 11 you will have this problem i have added extra switch case its resolved my problem

Related

Non supported character set (add orai18n.jar in your classpath)

I am successfully connecting to a Oracle 11g database using objdc8 version 18.3.0.0. When I try to upgrade ojdbc to version 19.3.0.0 I get the following error:
org.hibernate.engine.jdbc.spi.SqlExceptionHelper: Non supported character set (add orai18n.jar in your classpath): WE8PC850
Adding orai18n to the classpath solves the issue, but I don't understand why I need it for ojdbc 19.3.0.0 when it worked perfectly fine without it for ojdbc 18.3.0.0. Has there been some non backwards compatible change that now requires it?
Prior to 19c, the JDBC-thin driver was using a partial implementation of the conversion table for WE8PC850. Starting in 19c it, more correctly, mandates the full conversion table which is included in orai18n.jar. The same thing applies to other character sets that are binary supersets of US7ASCII.

Required character converter is not available. ERRORCODE=-4220, SQLSTATE=null

The application I migrate to Java8 was running on Java7. After the migration i had to update the db2jcc.jar to latest version and yet I have the error below:
Required character converter is not available. ERRORCODE=-4220, SQLSTATE=null
I have checked and tried the topic Getting error code 4220 with null SQL State
My DB version : DB2 v10.5.0.11
The db2 Jar I use : db2jcc-9.5.jar
Has anyone faced this before?
Regards
Your question included
My DB version : DB2 v10.5.0.11
The db2 Jar I use : db2jcc-9.5.jar
The exception text included:
[Camel Thread #2 - JmsConsumer[null]] WARN **** - SQLException: com.ibm.db2.jcc.a.SqlException:
[jcc][t4][10199][10462][3.52.95] Required character converter is not available. ERRORCODE=-4220, SQLSTATE=null
Notice the db2 jdbc driver version, [3.52.95] included in the exception text.
This is an old driver that comes with db2 version 9.5 fixpack2a, long out of support.
You need to be using a recent type 4 jdbc driver for Db2, and the version of the db2 jdbc driver will appear in the exception text as a three part number with a dot separating the parts.
For Db2-LUW v10.5 the currently available version of the db2 type 4 jdbc driver is 4.19.80 although you can use higher versions.
You can download the recent jdbc driver versions from this IBM website, you will need to register with IBM first, although the download is free.

an issue with compatibility: old jboss/hibernate vs Oracle 12c

i'm Oracle-DBA trying to upgrade our Oracle-11g databases onto Oracle-12c. Our web-developers tell me, there is a big problem to work our old applications (a lot of them were developed with old JBOSS 4.2.2 and old Hibernate 3.4.0/3.1.0) to the new the Oracle-database(12c)
Our developers send me this information:
**Application:
seam-version -> 2.2.2.Final
hibernate-annotations-version -> 3.4.0.GA
hibernate-validator-version -> 3.1.0.GA
jsf-facelets-version -> 1.1.14
rich-faces-version -> 3.3.3.Final
als Dependency: hibernate-core version 3.3.0.SP1 for Compilieren.
OracleDialect: org.hibernate.dialect.Oracle10gDialect
JBOSS 4.2.2.GA
Hibernate-Version: 3.2.4.sp1
Hibernate Annotations Version: 3.2.1.GA
Hibernate EntityManager Version: 3.2.1.GA
Oracle JDBC Driver for 11g - ojdbc14
Oracle JDBC Driver for 12c - ojdbc6
so, if you call a PROCEDURE XXXXXXXXX (o_res out sys_refcursor, p_yyyyy IN NUMBER, .... )
it throws this problem:
....
INFO | Caused by: org.hibernate.HibernateException: Problem while trying to load or access OracleTypes.CURSOR value
.....................
INFO | Caused by: java.lang.IllegalAccessException: Class org.hibernate.dialect.Oracle9Dialect can not access a member of class oracle.jdbc.driver.OracleTypes with modifiers ""
Bug: https://hibernate.atlassian.net/browse/HHH-3159
although, according this link we should had get a problem even with Oracle-11g, not while trying to upgrade to 12c! ( "With Oracle 11g, the deprecated package oracle.jdbc.driver no longer exists and this causes issues with all OracleDialect classes making it impossible to use Hibernate."(с) )
here one can read:
"Try to use org.hibernate.dialect.Oracle10gDialect, seems to be the highest possible version in Hibernate 4.3.9.
A dialect for 12c seems to be present in later versions, see this."
(we have even an older version of Hibernate - 3.2.4 ! )
a newer Hibernate (> 3.2.4 ), if i've got it right, is not compatibe with the old Jboss 4.2.2. (is it?! Please disagree with me (=with my colleagues) if you can)
what could be a right decision or workaround to make the 12c-Oracle-upgrade?
Thank you very much in advance!

Wrong column type (oracle) Found: number, expected: boolean

I am using jdk 1.6.45 spring 3.1 hibenate 4 jpa-2 junit 4 and maven
when i run the junit
I am getting the below error
Issue Description
If I remove the below line in persistance xml .., validation skipped and working fine
<property name="hibernate.hbm2ddl.auto" value="validate" />
what needs to be done to the execute junit validation
I have changed org.hibernate.dialect.OracleDialect to org.hibernate.dialect.Oracle10gDialect
Not It is working perfect.

"No suitable driver" problem with Hibernate3, PostgreSQL 8.3 and Java 5

Does anybody know what's going on here:
I run hibernate 3.2.6 against a PostgreSQL 8.3 (installed via fink) database on my Mac OS X. The setup works fine when I use Java 6 and the JDBC 4 driver (postgresql-8.3-603.jdbc4). However, I need this stuff to work with Java 5 and (hence) JDBC 3 (postgresql-8.3-603.jdbc3). When I change the jar in the classpath and switch to Java 5 (I do this in eclipse), I get the following error:
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
<Rows clipped for readability>
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
What's the problem here? I cannot see it. Here is my hibernate configuration:
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:postgresql:test</property>
<property name="connection.username">postgres</property>
<property name="connection.password">p</property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
<mapping resource="com/mydomain/MyClass.hbm.xml"/>
</session-factory>
</hibernate-configuration>
EDIT: The longer, more usual form of the connection URL: jdbc:postgresql://localhost/test has the exact same behaviour.
The driver jar is definitely in the classpath, and I also do not manage to get any errors with this direct JDBC test code:
public static void main(String[] args) throws Exception {
Class.forName("org.postgresql.Driver");
Connection con=DriverManager.getConnection("jdbc:postgresql://localhost/test","postgres", "p");
}
I don't see you specifying the driver class in your Hibernate configuration. Try adding the following:
<hibernate-configuration>
<session-factory>
.
.
<property name="connection.driver_class">org.postgresql.Driver</property>
.
</session-factory>
</hibernate-configuration>
did you notice that the connection url is incomplete
<property name="connection.url">jdbc:postgresql:test</property>
as opposed to
<property name="connection.url">jdbc:postgresql://localhost/test</property>
You say "work with Java 5 and (hence) JDBC 3 (postgresql-8.3-603.jdbc3)." Maybe this is a faulty assumption.
The download page is confusing to me. It seems to imply that for Java 1.5 you need JDBC3 but it's not 100% clear. I'm not sure why the JDBC4 driver won't work with Java 1.5 (we use a DB2 JDBC4 driver with Java 1.5).
Have you tried the JDBC4 driver with Java 1.5?
One of the new JDBC4 features is automatic loading via the Service Provider mechanism. By including a META-INF/services/java.sql.Driver file in the jar file, there is no longer the need to do Class.forName(""). This only works with the 1.6 JVM.
I had the same problem "no suiteble driver found" using a servlet the solution to register a driver is:
Class driverClass = Class.forName("org.postgresql.Driver");
DriverManager.registerDriver((Driver) driverClass.newInstance());
Found the solution here:
http://www.java2s.com/Tutorial/Java/0340__Database/DriverManagergetDriversenumeratealltheloadedJDBCdrivers.htm
http://codingexplorer.wordpress.com/2009/09/06/%E2%80%9Cno-suitable-driver%E2%80%9D-for-postgresql/

Categories