Archive for March, 2011
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
.
Table … not found in tableMap=org.dbunit.dataset.OrderedTableNameMap[_tableNames=[], _tableMap={}, _caseSensitiveTableNames=false]
Case
On a unit test with JDBC / DBUnit, extending org.dbunit.DBTestCase
, I get this error:
Table 'Jonathan_Lalou_Table' not found in tableMap=org.dbunit.dataset.OrderedTableNameMap[_tableNames=[], _tableMap={}, _caseSensitiveTableNames=false]
Explanation and fix
Indeed, even when you provide a dataset through a flat XML file, DBUnit does not create the tables, but only fills them in. I know, this is paradoxal and most developpers would like to create implicitly the tables prior to filling them…
To fix the issue, add a block like this one, for instance when overriding the method getDataSet()
:
final PreparedStatement preparedStatement; preparedStatement = getDatabaseTester().getConnection().getConnection().prepareStatement("CREATE TABLE Jonathan_Lalou_Table ... "); preparedStatement.executeUpdate();
GWT / Sonar / Cannot invoke clone() on the array type… / The user-supplied array … is stored directly
I have to fix all critical “Violations” owing to Sonar.
Let’s consider a basic block:
public void setSushis(float[] sushis) { this.sushis = sushis; }
This piece of code raises this error in Sonar:
Security - Array is stored directly : The user-supplied array 'sushis' is stored directly.
In a naive step, I modified the code as this:
public void setSushis(float[] sushis) { this.sushis = sushis.clone(); }
This may have been OK… but, now, I get the following error within GWT compilation:
Cannot invoke clone() on the array type float[]
To fix the issue, I amended the code as follows:
public void setSushis(float[] theSushis) { this.sushis= new float[theSushis.length]; System.arraycopy(theSushis, 0, this.sushis, 0, theSushis.length); }
Disclaimer: even though I followed Sonar’s advice and requirements, I am a little skeptic about this kind of “violation”. 😐
weblogic.security.SecurityInitializationException: Authentication for user weblogic denied
Case
Starting a WebLogic 9.2 instance, I got this message:
Server subsystem failed. Reason: weblogic.security.SecurityInitializationException: Authentication for user weblogic denied
Anyway, I checked the admin login and passwords were OK, since I had never changed them.
Stacktrace
<Mar 18, 2011 11:14:03 AM CET> <Critical> <WebLogicServer> <BEA-000386> <Server subsystem failed. Reason: weblogic.security.SecurityInitializationException: Authentication for user weblogic denied weblogic.security.SecurityInitializationException: Authentication for user weblogic denied at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.doBootAuthorization(CommonSecurityServiceManagerDelegateImpl.java:947) at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.initialize(CommonSecurityServiceManagerDelegateImpl.java:1029) at weblogic.security.service.SecurityServiceManager.initialize(SecurityServiceManager.java:854) at weblogic.security.SecurityService.start(SecurityService.java:141) at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
Fix
- Go to
$DOMAIN_HOME/servers/admin/data/
- Rename
ldap
asldap.OLD
- Restart WebLogic admin
- Then, a file
$DOMAIN_HOME/servers/admin/security/boot.properties
should appear and contain the encrypted login and passwords.The issue should be fixed.
Failed to start Service “Cluster” (ServiceState=SERVICE_STOPPED, STATE_ANNOUNCE)
Case
I introduced an Oracle Coherence cache withing my application, which is deployed as a WAR within WebLogic Server. In a first step, I used an instance of Oracle Coherence / Coherence Web already built in WebLogic. Then, for a couple a reasons, I detroyed the Coherence cluster. Deploying the application, the following error appeared:
java.lang.RuntimeException: Failed to start Service "Cluster" (ServiceState=SERVICE_STOPPED, STATE_ANNOUNCE)
Complete Stacktrace
java.lang.RuntimeException: Failed to start Service "Cluster" (ServiceState=SERVICE_STOPPED, STATE_ANNOUNCE) at com.tangosol.coherence.component.util.daemon.queueProcessor.Service.start(Service.CDB:38) at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.start(Grid.CDB:38) at com.tangosol.coherence.component.net.Cluster.onStart(Cluster.CDB:366) at com.tangosol.coherence.component.net.Cluster.start(Cluster.CDB:11) at com.tangosol.coherence.component.util.SafeCluster.startCluster(SafeCluster.CDB:3)
Explanation and Fix
The Coherence cluster view available in WebLogic server is a view of the Tangosol configuration, available in the files tangosol-coherence*.xml
of Coherence’s JAR. To fix the issue, create a file tangosol-coherence-override.xml
, in your classpath. Fill the file with a minimum content, such as:
<?xml version='1.0'?> <!DOCTYPE coherence SYSTEM "coherence.dtd"> <coherence> <cluster-config> <multicast-listener> <time-to-live system-property="tangosol.coherence.ttl">0</time-to-live> <join-timeout-milliseconds>3000</join-timeout-milliseconds> </multicast-listener> <unicast-listener> <address>127.0.0.1</address> <port>8088</port> <port-auto-adjust>true</port-auto-adjust> <priority>8</priority> </unicast-listener> <packet-publisher> <packet-delivery> <timeout-milliseconds>30000</timeout-milliseconds> </packet-delivery> </packet-publisher> <service-guardian> <timeout-milliseconds system-property="tangosol.coherence.guard.timeout">35000</timeout-milliseconds> </service-guardian> </cluster-config> <logging-config> <severity-level system-property="tangosol.coherence.log.level">5</severity-level> <character-limit system-property="tangosol.coherence.log.limit">0</character-limit> </logging-config> </coherence>
Of course, you can amend and improve the file to match your requirements.
NB: in case your file is ignored by Coherence, override the property tangosol.coherence.override
with value tangosol-coherence-override.xml
.