Search
Calendar
July 2017
S M T W T F S
« Sep    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
Your widget title
Archives

Posts Tagged ‘Oracle’

PostHeaderIcon java.sql.SQLException: Wrong data type: NUMBER in statement [CREATE TABLE … (… NUMBER]

Case

In a JDBC DAO, I execute a query to retrieve an object. I get this error:

java.sql.SQLException: Wrong data type: NUMBER in statement [CREATE TABLE Jonathan_Table (TableColumn NUMBER]

Stacktrace

java.sql.SQLException: Wrong data type: NUMBER in statement [CREATE TABLE Jonathan_Table (TableColumn NUMBER]
 at org.hsqldb.jdbc.Util.throwError(Unknown Source)
 at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
 at com.bnpp.pb.risklayer.services.dao.jdbc.JdbcPrimeRiskServerDaoUnitTest.getDataSet(JdbcPrimeRiskServerDaoUnitTest.java:57)
 at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:154)

Explanation and fix

My original DB is under Oracle, but my DBUnit tests works on HSQL. Yet, types NUMBER and VARCHAR2 are not available under HSQL, this is why the exception is raised.
To fixe the issue, rewrite your scripts, replacing NUMBER and VARCHAR2 with NUMERIC and VARCHAR.

PostHeaderIcon Oracle / OUI-10038

Case

Trying to install Oracle Agent on a Windows XP SP2 desktop, I get the following error:

ERROR: OUI-10038:You do not have the necessary permissions to write to the inventory at \Oracle\Inventory. Please make sure that you have the appropriate permissions to perform the installation.

Fix

Edit the registry. For the key HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\inst_loc, replace the value \Oracle\Inventory with C:\Oracle\Inventory

PostHeaderIcon SQL*Plus Does Not Update a Stored Procedure

Case

You have a stored procedure that you would like to update. The script is OK with TOAD, but raises an error when launched via SQL*Plus.

Fix

Add a slash (‘/’) or a dot (‘.’) at the end of file.

PostHeaderIcon Use a JDBC datasource from WebLogic’s JNDI

Case

Your application is connected to a database. The configuration of the DB connexion is set in a Spring file. You would like the connexion to be set in WebLogic, so that no URL/login/password lays in your source code.

Steps

WebLogic

Create a new data source:

  • go the WebLogic console >
    • JDBC >
      • DataSource >
        • New >
          • set the name, JNDI name (eg: database.jndi.name), DB type  (Oracle, Sybase, …) >
            • Next >
              • Select the driver >
                • Next >
                  • Select the targeted server(s)

This will

  1. create a new file <yourDomain>/config/jdbc/<datasourceName>-XXXX-jdbc.xml.
  2. add a <jdbc-system-resource> block in <yourDomain>/config/config.xml

Spring

Replace the block:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${database.driver}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
 </bean>

with:

<jee:jndi-lookup id="dataSource" jndi-name="${database.jndi.name}" />

PostHeaderIcon java.lang.OutOfMemoryError: PermGen space

Case:

I have to redeploy many times a day a WAR on a WebLogic 10 server, using Hotspot (Sun JVM) with Java 6. After some cycles deploy/undeploy, Hotspot crashes with the following error:

java.lang.OutOfMemoryError: PermGen space

Complete stacktrace:

2010-08-17 11:26:56,718 ERROR context.ContextLoader               - Context initialization failed
java.lang.IllegalStateException: Unable to load Java 1.5 dependent class [org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver]
        at org.springframework.beans.factory.support.AutowireUtils.createAutowireCandidateResolver(AutowireUtils.java:125)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:103)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory(AbstractRefreshableApplicationContext.java:176)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:121)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
        at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
        at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1863)
        at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3126)
        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1512)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:486)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
        at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:1267)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:409)
        at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:43)
        at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
        at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
        at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
        at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
        at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
        at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
        at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.OutOfMemoryError: PermGen space
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:328)
        at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:285)
        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253)
        at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
        at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:37)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:328)
        at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:285)
        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253)
        at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
        at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:37)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:242)
        at org.springframework.beans.factory.support.AutowireUtils.createAutowireCandidateResolver(AutowireUtils.java:120)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:103)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory(AbstractRefreshableApplicationContext.java:176)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:121)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
<Aug 17, 2010 11:26:56 AM CEST> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: java.lang.IllegalStateException: Unable to load Java
1.5 dependent class [org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver].
java.lang.IllegalStateException: Unable to load Java 1.5 dependent class [org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver]
        at org.springframework.beans.factory.support.AutowireUtils.createAutowireCandidateResolver(AutowireUtils.java:125)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:103)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory(AbstractRefreshableApplicationContext.java:176)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:121)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
        Truncated. see log file for complete stacktrace

Caused By: java.lang.OutOfMemoryError: PermGen space
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:328)
        Truncated. see log file for complete stacktrace
>
<Aug 17, 2010 11:26:56 AM CEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1282037204562' for task '9'. Error is: 'weblogic.application.ModuleException: '
weblogic.application.ModuleException:
        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1514)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:486)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        Truncated. see log file for complete stacktrace

Caused By: java.lang.OutOfMemoryError: PermGen space
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:328)
        Truncated. see log file for complete stacktrace
>

A short explanation

The error seems to be linked to the garbage collection. From what I could read on the web, static objects used in CGlib (and/or jars depending on the library, such as the wide spread Hibernate, Spring, etc.) are the source of the crash.

Fix

Switching HotSpot to Oracle/BEA’s JVM, aka JRockit, makes the error (almost) disappear.
Alternatively, if you can’t change the JVM, a workaround consists in upgrading the following parameter on JVM launching:
-XX:MaxPermSize=256m