Category: JEE

JPA: How to resolve the “java.sql.SQLException: Io exception: Size Data Unit (SDU) mismatch” error in Java/JEE/JPA

I was developing a JPA JEE application were this strange and vague error appeared and stopped me from storing OrderHeader/OrderItem POJO’s.

Internal Exception: java.sql.SQLException: Io exception: Size Data Unit (SDU) mismatch.

This SDU error is rather vague and does not reveal the true problem in the executed SQL or Schema or constraint violation!
After many trials, here is the way I was able to identify the real Oracle DB error !

  1. Take the OrderHeader/OrderItems classes into a new JSE batch project.
  2. in NB , right-click –> insert code–> Persist EntityClass
  3. Add the following properties to “persistence.xml” for more detailed logging:
<properties>
 <property name="toplink.logging.level" value="FINEST"/>
 <property name="eclipselink.logging.parameters" value="true"/>
 </properties>

After the previous update you should be able to see in the Glassfish logs, all the executed SQL’s and even their bind variables.

<pre>Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Io exception: Size Data Unit (SDU) mismatch
Error Code: 17002
Call: INSERT INTO XYZ (x , y, z) values (?,?,?)
 bind => [655, 5, 62]
Query: InsertObjectQuery(zyx.entity.TocOrderItem[ ])
 at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1605)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:893)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:957)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:630)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
 at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1995)
...
Caused by: oracle.net.ns.NetException: Size Data Unit (SDU) mismatch
at oracle.net.ns.Packet.receive(Packet.java:264)
at oracle.net.ns.DataPacket.receive(DataPacket.java:92)
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:172)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:117)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:92)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:77)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1034)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1010)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:588)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:953)
... 97 more

And now run the new batch project and you will see the (ORA-) error clearly.  Mine was related to some XMLType / Oracle Fields in the records I want to save (out of scope).

The problem as it seems to be : that the EJB Container shields and wraps some of the returned error codes and connections; this produces the vague SDU error. The solution uses the good-old-normal JSE not JEE  JVM which will allow a more interaction between your program and JDBC.

The Enterprise applications of the future.

I had the privilege to attend JAZOON software development conference in Zurich. I heard a lot of buzzwords and  jargon there about the new technologies of the software development. from the group of seminars and keynotes there I generated a picture about the perfect Enterprise application in the future. In this article I try to paint this picture.

Read more »

SOAP in 100 minutes

If you are an enterprise developer, then you must have came across SOAP (Simple Object Access Protocol).

When you are first introduced to it, you drown in a ocean of terms and jargon that eventually kills the purpose of it (Simple).

In this this 100 minutes tutorial I try to introduce the reader to SOAP jargon without being stuck in the Jargon Quick sand. I try to introduce terms naturally and gradually as they are needed and as much as possible try to provide visual exhibits to reduce the number of words.

Read more »

Java Troubleshooting: Application running inside Glassfish, unable to call a webservice

Flash Forward:  3 days already trying to troubleshooting the java code for “PrivilegedActionException” Exception , it turns out it is one parameter in Glassfish that needs to be properly adjusted.

Lets go back from the beginning: 3 days ago I was writing a JEE enterprise applciation , simply  a webpage that retrieves data from a DB2 database and then based on a user’s choice it call a webservice for some of the records in the result-set.

I followed GlassFish-Developer’s-guide to call an WS-RPC webservice. the server providing this WS-RPC is somewhere located inside our enterprise network.

Read more »

Oracle Virtual machine “OTN Developer Days” appliance.

If you are a developer and need your own Oracle environment to try out and test ideas without disrupting your main development environment, then I propose using a Virtual Machine with Developer Days appliance.

Choose what type of environment you want from this link and start following the instructions. I prefer the Developer Days appliance , since it requires reasonable resources and more related to my work. This virtual Machine contains:

  • Oracle Enterprise Linux 5
  • Oracle Database 11g Release 2 Enterprise Edition
  • Oracle TimesTen In-Memory Database Cache
  • Oracle XML DB
  • Oracle SQL Developer
  • Oracle SQL Developer Data Modeler
  • Oracle Application Express 4.0
  • Oracle JDeveloper
  • Hands-On-Labs (accessed via the Toolbar Menu in Firefox)

Read more »