-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: In need of help uploading file to bytea
PostPosted: Fri Aug 05, 2005 10:38 am 
Newbie

Joined: Thu Jul 07, 2005 1:47 pm
Posts: 6
Hibernate 3.0.2
Postgres 7.4
JBoss 4.0.2
Tapestry 3.0.3

I am trying to upload a file from a form in my tapestry webapp. And get the following exception:

Code:
14:15:12,227 INFO  [STDOUT] Hibernate: insert into DOCUMENTLOCKER (visibility, document, title, description, filename, type, appinfoid, appverid, assessinfoid, companyid, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
14:15:12,230 ERROR [JTATransaction] JTA commit failed
org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=me.com/53, BranchQual=, localId=53] status=STATUS_NO_TRANSACTION; - nested throwable: (java.lang.IllegalArgumentException: \0 not allowed)
        at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:344)
        at org.jboss.tm.TxManager.commit(TxManager.java:200)
        at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:126)
        at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:130)
        at com.domain.util.HibernateUtil.commitTransaction(HibernateUtil.java:105)
        at com.view.pages.AddDocumentationPage.formSubmit(AddDocumentationPage.java:65)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


My persistant object that contains a bytea field is called 'locker' the bytea field is named 'document'.

Here is the a portion of my code that I use to attempt to save the file inputstream which is obtained from my upload form:

Code:
HibernateUtil.beginTransaction();
locker.setDocument(ByteUtils.getBytesFromStream(inputstream));
HibernateUtil.saveOrUpdate(locker);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();



I also have no problems using this same code on a Servlet that I wrote to initialize a few fields in my database.

Any help will be greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 10:54 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
What's the Document's hibernate type ? bytea is a Postgres type. How do you define it in your mapping files ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 10:56 am 
Newbie

Joined: Thu Jul 07, 2005 1:47 pm
Posts: 6
it is defined as a binary in my mapping files
and byte[] in the associated class.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 11:10 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
Are you sure you bytea field is the problem

See http://archives.postgresql.org/pgsql-jd ... g00298.php for details

I think hibernate isn't the problem, try doing the same thing with jdbc before and when it works with it, go with hibernate

Seb


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 11:46 am 
Newbie

Joined: Thu Jul 07, 2005 1:47 pm
Posts: 6
Thanks so much, you were right I had a char field that was putting a /0 and caused the problem. I guess I just assumed it was the bytea field causing the problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.