Java.lang.ClassCastException:java.sql.Timestamp cannot is cast to java.sql.Date under weblogic11_64

Source: Internet
Author: User


The project needs to switch servers, switch from server2003 to server2008, weblogic11_64 for new environments, oracle11g

After the project deployment is run, everything else is OK, and the following error is reported when querying a database field of type Date:

Java.lang.ClassCastException:java.sql.Timestamp cannot is cast to Java.sql.Date


According to the general idea, this exception, is the code of the existence of the type of casting, as long as the place of the conversion of the cast to a reasonable type of conversion logic can be.

However, considering the process of system migration, and did not make any code changes, since the old environment can execute this code, the new environment error, may be in the process of switching compatibility or jar package conflict issues.


The resolution process is as follows:

First, problem positioning

1, suspect is the JDK version problem, so in my machine to replace the same version of the JDK, the results of local operation is normal, to exclude the cause of the JDK, 2, the suspected Oracle version of the problem, the local connection to the new environment database, running normally, to exclude Orale version of the problem;

3, install the same version of WebLogic locally, configure Jndi and deploy the local deployment package, run, the same problem, problem location!


Second, the problem analysis

Error location is the processing of hibernate query results, hibernate package query results into list<map> type, may be Hibernatejar package problem, but in the configuration WebLogic environment, Hibernate's Antlr-2.7.6.jar has been entered into the Startweblogic.cmd file according to the data, so it is suspected that the JDBC driver package in WebLogic should be re-referenced according to the configuration Antlr-2.7.6.jar. Summary


Third, the solution steps (the configuration of the Hibernatejar together, convenient for later configuration, this part of the reference to other information)

1. Find Antlr-2.7.6.jar and Ojdbc14.jar (copy directly from the Web-inf\lib directory)

2, copy it to WebLogic's installation directory $weblogic_root$\wlserver_10.3\server\lib (theoretically can be any other directory)

3, found in the WebLogic installation directory

$weblogic _root$\user_projects\domains\base_domain\bin\startweblogic.cmd File
4. Open the Startweblogic.cmd with a text editor and find
Set classpath=%save_classpath%

Set save_classpath=
Add the following configuration between the previous two lines
@REM Hibernate3
Set Pre_classpath=%wl_home%\server\lib\antlr-2.7.6.jar;%wl_home%\server\lib\ojdbc14.jar
Set classpath=%pre_classpath%;%classpath%

5, save, and then restart WebLogic.


Re-test the program, the problem is solved!



This article is from the "Catcher in the Rye" blog, make sure to keep this source http://4614839.blog.51cto.com/4604839/1670229

Java.lang.ClassCastException:java.sql.Timestamp cannot is cast to java.sql.Date under weblogic11_64

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.