Hello All.

I have JBOSS 4.0.0 and a CMP Entity Bean called Image.  The bean has a field 
called content, which I have defined as byte[].

I load my image via a URL and encode it in Base64:

  | URL imageUrl = new URL( "http://...."; );
  | URLConnection imageConnection = imageUrl.openConnection(); 
  | InputStream imageStream = imageConnection.getInputStream();
  | int fileLength = imageConnection.getContentLength();
  | ByteArrayOutputStream encodedImage = new ByteArrayOutputStream( fileLength 
);
  | Base64.OutputStream encodeStream = new Base64.OutputStream( encodedImage );
  | int totalRead = 0;
  | int bytesRead = 0;
  | byte buffer[] = new byte[fileLength];
  | while( (totalRead < fileLength) && (bytesRead != -1) ) {
  |     bytesRead = imageStream.read( buffer, totalRead, fileLength - totalRead 
);
  |     if ( bytesRead != -1 ) totalRead += bytesRead;
  | }
  | encodeStream.write( buffer );
  | dsImage.setContent( encodedImage.toByteArray() );
  | 
The standardjbosscmp-jdbc.xml is set up thus for Oracle9i:

  | <mapping>
  |    <java-type>java.lang.Object</java-type>
  |    <jdbc-type>BLOB</jdbc-type>
  |    <sql-type>BLOB</sql-type>
  |    <!--
  |    | Change this from BLOB to RAW(n) if you know your
  |    | serialized object will be <= n bytes and n <= 2000
  |    -->
  | </mapping>
  | 
The database table has CONTENT set up with type BLOB:

  | CREATE TABLE IMAGE
  | (
  |   IMAGE_ID NUMBER(10) NOT NULL,
  |   IMAGE_CATEGORY_ID NUMBER(10) NOT NULL,
  |   MIME_TYPE_ID NUMBER(10) NOT NULL,
  |   NAME VARCHAR2(50) NOT NULL,
  |   DESCRIPTION VARCHAR2(200),
  |   HEIGHT_IN_PIXELS NUMBER(5) NOT NULL,
  |   WIDTH_IN_PIXELS NUMBER(5) NOT NULL,
  |   SIZE_IN_BYTES NUMBER(10) NOT NULL,
  |   CONTENT BLOB NOT NULL,
  |   CREATED_DATE DATE DEFAULT SYSDATE NOT NULL,
  |   CREATED_USER VARCHAR2(50) DEFAULT USER NOT NULL,
  |   MODIFIED_DATE DATE DEFAULT NULL,
  |   MODIFIED_USER VARCHAR2(50) DEFAULT NULL,
  |   DELETED_USER VARCHAR2(50) DEFAULT NULL,
  |   DELETED_DATE DATE DEFAULT NULL,
  |   CONSTRAINT PK_IMAGE
  |     PRIMARY KEY ( IMAGE_ID ) );
  | 
When I attempt to create the Entity, JBOSS Errors:

  | 12:05:58,982 ERROR [Image] Could not create entity
  | java.sql.SQLException: Io exception: Connection reset
  |     at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
  |     at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
  |     at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
  |     at 
oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2150)
  |     at 
oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2015)
  |     at 
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2877)
  |     at 
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
  |     at 
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:316)
  |     at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.executeInsert(JDBCAbstractCreateCommand.java:328)
  |     at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.performInsert(JDBCAbstractCreateCommand.java:286)
  |     at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:137)
  |     at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:572)
  |     at 
org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:222)
  |  .
  |  .
  |  .
  | 
The program client outputs:

  | java.rmi.UnmarshalException: Error unmarshaling return; nested exception 
is: 
  |     java.lang.ClassNotFoundException: 
org.jboss.resource.connectionmanager.JBossLocalXAException (no security 
manager: RMI class loader disabled)
  |     at 
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:217)
  |     at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
  |     at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown 
Source)
  |     at 
org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:118)
  |     at 
org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
  |     at 
org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
  |     at 
org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
  |     at 
org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
  |     at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
  |  .
  |  .
  |  .
  | 
I have based my work on 
http://www.theserverside.com/blogs/showblog.tss?id=UsingBLOBDataType.
Have I missed something?  Could there be a problem with JBOSS or with the 
Oracle JDBC?
Any help greatly appreciated.  I would like to stay with CMP for this as the 
images are no bigger than 30k and everyone here prefers CMP (including myself).

Thanks in advance.

Matt.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3866855#3866855

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3866855


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to