You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bryan <ni...@gmail.com> on 2004/07/30 14:19:59 UTC

Re: OT/ Tomcat, Hibernate and MYSQL problem ( byte to blob )

I am using the following mysql driver 

-rwxr-xr-x    1 Administ Aucun      321671 Jul  2 13:47 /c/bryan-website/jakarta
-tomcat-5.0.14/common/lib/mysql-connector-java-3.1.1-alpha-bin.jar

and it has worked fine for me previously .

I would carry out some checks on the struts action to verify the size
of the data.

Also check for the following 
<form enctype="multipart/form-data" 

--b

On Fri, 30 Jul 2004 12:30:45 +0200, Mark Lowe <ma...@boxstuff.com> wrote:
> Hi Bryan
> 
> Just downloaded the latest, but the action just prints a test message..
> 
> System.out.println("at least i managed to get called");
> 
> The problem isn't with form file, thats fine.. Its when I try and save
> to the db
> 
> //hibernate stuff
> 
> /**
> * @hibernate.property column="image" type="blob"
> */
> public byte[] getImage() {
>         return image;
> }
> 
> public void setImage(byte[] image) {
>         this.image = image;
> }
> 
> Now i created a custom user type like were required with older versions
> of hibernate..
> 
> /**
> * @hibernate.property column="image"
> type="com.sparrow.hibernate.type.Image"
> */
> 
> http://www.hibernate.org/73.html
> 
> but when i try and save now i get a null pointer exception with not
> much else to go on (before it was a class cast exception). I'd have
> thought that creating a custom user type was a bit old hat as 2.0 loved
> it..
> 
> The only other thing i can think its down to is the jdbc driver.. Which
> i'm investigating now.
> 
> 
> 
> 
> On 30 Jul 2004, at 12:08, Bryan Hunt wrote:
> 
> > My app is able to do it no problem, back and forth.
> >
> > You can get the source code from http://jestate.revoltingdigits.com/
> >
> > ie.jestate.struts.action.ImageUploadAction
> >
> > My code is a  mess at the moment but that code is working.
> >
> > --b
> >
> >
> > Mark Lowe wrote:
> >
> >> I've had the same thing happen using DBCP and C3PO, I believe its the
> >> driver rather than the pooling. As I said we've a app thats live, and
> >> i haven't touched it in months using DBCP.
> >>
> >> [OT] subject change.. Have you had any joy with byte[] to blob
> >> mapping for file uploads with hibernate 2.1.4? I created a custom
> >> usertype, but i get a npe. 2.0 delbt with life, but things appear to
> >> have taken a step backwards. (please dont make me go the the scary
> >> hibernate forum :) )
> >>
> >>
> >> On 30 Jul 2004, at 11:34, Joe Hertz wrote:
> >>
> >>> I noticed this behavior with 3.0.14.
> >>>
> >>> This _really_ sounds like this entry in the Hibernate FAQ to me:
> >>>
> >>> http://www.hibernate.org/117.html#A13
> >>>
> >>> I wouldn't use DBCP though as Gavin King is apparently fed up with
> >>> it,
> >>> and built-in support for it is being yanked in the next major
> >>> version of
> >>> Hibernate.
> >>>
> >>>> -----Original Message-----
> >>>> From: Marco Mistroni [mailto:mmistroni@waersystems.com]
> >>>> Sent: Friday, July 30, 2004 5:08 AM
> >>>> To: 'Struts Users Mailing List'
> >>>> Subject: RE: OT/ Tomcat, Hibernate and MYSQL problem
> >>>>
> >>>>
> >>>> Hello,
> >>>>     If I remember correct, mysql connector 3.0.11
> >>>>
> >>>> Regards
> >>>>     marco
> >>>>
> >>>> -----Original Message-----
> >>>> From: Mark Lowe [mailto:mark.lowe@boxstuff.com]
> >>>> Sent: 30 July 2004 09:36
> >>>> To: Struts Users Mailing List
> >>>> Subject: Re: OT/ Tomcat, Hibernate and MYSQL problem
> >>>>
> >>>> Marco
> >>>>
> >>>> What jdbc driver are you using?
> >>>>
> >>>> They was a shady version 3 behaving like this.
> >>>>
> >>>>
> >>>> On 30 Jul 2004, at 10:05, Joe Hertz wrote:
> >>>>
> >>>>> Hibernate's internal connection pooling isn't meant for production
> >>>>> because it does things just like that.
> >>>>>
> >>>>> Suggest you use c3p0 for the pooling.
> >>>>>
> >>>>>> From my hibernate.cfg.xml, I only had to add this:
> >>>>>
> >>>>>
> >>>>>        <property name="c3p0.minPoolSize">5</property>
> >>>>>        <property name="c3p0.maxPoolSize">20</property>
> >>>>>        <property name="c3p0.timeout">1800</property>
> >>>>>        <property name="c3p0.max_statement">50</property>
> >>>>>
> >>>>> HTH
> >>>>>
> >>>>> -Joe
> >>>>>
> >>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: Marco Mistroni [mailto:mmistroni@waersystems.com]
> >>>>>> Sent: Friday, July 30, 2004 3:58 AM
> >>>>>> To: 'Struts Users Mailing List'
> >>>>>> Subject: OT/ Tomcat, Hibernate and MYSQL problem
> >>>>>>
> >>>>>>
> >>>>>> Hello,
> >>>>>>
> >>>>>>     First of all, I apologize for the off topic issue..
> >>>>>> I know this is not the list, but I tried hibernate forums, and
> >>>>>> Searched the web with no solution.. hopefully some of u
> >>>>>
> >>>> had the Same
> >>>>
> >>>>>> problem and solved it..
> >>>>>>
> >>>>>>
> >>>>>> I m experiencing problems with Hibernate in tomcat,
> >>>>>
> >>>> talking to mysql.
> >>>>
> >>>>>>
> >>>>>> My situation is that I didn't define any connection pools
> >>>>>
> >>>> in tomcat,
> >>>>
> >>>>>> but left it to Hibernate to handle that...
> >>>>>>
> >>>>>> After leaving the application running for 11 hours, I got
> >>>>>
> >>>> following
> >>>>
> >>>>>> exception
> >>>>>>
> >>>>>> hi all,
> >>>>>> i have a webapp taht uses Hibernate and MYSQL, running on top of
> >>>>>> tomcat.
> >>>>>>
> >>>>>> i am letting Hibernate handle the connections to mysql db, since i
> >>>>>> have no connection pools defined in tomcat. after running the
> >>>>>> application for nearly 9 hours, when i tried to use my app
> >>>>>
> >>>> to connect
> >>>>
> >>>>>> to the database i got following exception:
> >>>>>>
> >>>>>> Caused by: net.sf.hibernate.JDBCException: Could not
> >>>>>
> >>>> execute query at
> >>>>
> >>>>>> net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1476)
> >>>>>> at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:45)
> >>>>>> at com.myapp.hibernate.HibernatePersistenceManager.query(Hibernat
> >>>>>> ePersisten
> >>>>>> ceManager.java:205)
> >>>>>> ... 31 more
> >>>>>> Caused by: java.sql.SQLException: Communication link failure:
> >>>>>> java.net.SocketException, underlying cause: Software caused
> >>>>>
> >>>> connection
> >>>>
> >>>>>> abort: recv failed
> >>>>>>
> >>>>>> ** BEGIN NESTED EXCEPTION **
> >>>>>>
> >>>>>> java.net.SocketException
> >>>>>> MESSAGE: Software caused connection abort: recv failed
> >>>>>>
> >>>>>> STACKTRACE:
> >>>>>>
> >>>>>> java.net.SocketException: Software caused connection abort: recv
> >>>>>> failed
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> now i have searched the web and found two possible
> >>>>>
> >>>> alternatives.. one
> >>>>
> >>>>>> was to add following problems to hibernate config file.. <property
> >>>>>> name="connection.autoReconnect">true</property>
> >>>>>> <property name="connection.autoReconnectForPools">true</property>
> >>>>>> <property
> >>>>>> name="connection.is-connection-validation-required">true</
> >>>>>> property>
> >>>>>>
> >>>>>>
> >>>>>> but this does not work, as ihave added thos eproperties to
> >>>>>
> >>>> hibernate
> >>>>
> >>>>>> properties file and i am still getting same exception
> >>>>>>
> >>>>>>
> >>>>>> then I tried to add ?autoReconnect=true  to JBDC URL, but
> >>>>>
> >>>> that didn't
> >>>>
> >>>>>> work either coz I left application running for 11 hours and after
> >>>>>> that I got same exception...
> >>>>>>
> >>>>>> can anyone help me out?
> >>>>>>
> >>>>>> THANX in advance and regards
> >>>>>>     marco
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> l: user-help@struts.apache.org
> >>>>>>
> >>>>>>
> >>>>>>
> >>>> --------------------------------------------------------------------
> >>>> -
> >>>>
> >>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>>>> For additional commands, e-mail: user-help@struts.apache.org
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> --------------------------------------------------------------------
> >>>> -
> >>>>
> >>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>>> For additional commands, e-mail: user-help@struts.apache.org
> >>>>
> >>>>
> >>>>
> >>>> --------------------------------------------------------------------
> >>>> -
> >>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>> For additional commands, e-mail: user-help@struts.apache.org
> >>>>
> >>>>
> >>>> --------------------------------------------------------------------
> >>>> -
> >>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>> For additional commands, e-mail: user-help@struts.apache.org
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: OT/ Tomcat, Hibernate and MYSQL problem ( byte to blob )

Posted by Mark Lowe <ma...@boxstuff.com>.
On 30 Jul 2004, at 14:19, bryan wrote:

> I am using the following mysql driver
>
> -rwxr-xr-x    1 Administ Aucun      321671 Jul  2 13:47  
> /c/bryan-website/jakarta
> -tomcat-5.0.14/common/lib/mysql-connector-java-3.1.1-alpha-bin.jar
>
> and it has worked fine for me previously .
>
> I would carry out some checks on the struts action to verify the size
> of the data.

Sure that stuff works.. Its when i attempt to save the object that has  
a property or type byte[] (class cast exception) and a trusty old NPE  
when i use my own custom type. Its really annoying, given that it works  
with 2.0.. Perhaps those crazy hibernate kids thought it was too easy.

>
> Also check for the following
> <form enctype="multipart/form-data"
>
> --b
>
> On Fri, 30 Jul 2004 12:30:45 +0200, Mark Lowe <ma...@boxstuff.com>  
> wrote:
>> Hi Bryan
>>
>> Just downloaded the latest, but the action just prints a test  
>> message..
>>
>> System.out.println("at least i managed to get called");
>>
>> The problem isn't with form file, thats fine.. Its when I try and save
>> to the db
>>
>> //hibernate stuff
>>
>> /**
>> * @hibernate.property column="image" type="blob"
>> */
>> public byte[] getImage() {
>>         return image;
>> }
>>
>> public void setImage(byte[] image) {
>>         this.image = image;
>> }
>>
>> Now i created a custom user type like were required with older  
>> versions
>> of hibernate..
>>
>> /**
>> * @hibernate.property column="image"
>> type="com.sparrow.hibernate.type.Image"
>> */
>>
>> http://www.hibernate.org/73.html
>>
>> but when i try and save now i get a null pointer exception with not
>> much else to go on (before it was a class cast exception). I'd have
>> thought that creating a custom user type was a bit old hat as 2.0  
>> loved
>> it..
>>
>> The only other thing i can think its down to is the jdbc driver..  
>> Which
>> i'm investigating now.
>>
>>
>>
>>
>> On 30 Jul 2004, at 12:08, Bryan Hunt wrote:
>>
>>> My app is able to do it no problem, back and forth.
>>>
>>> You can get the source code from http://jestate.revoltingdigits.com/
>>>
>>> ie.jestate.struts.action.ImageUploadAction
>>>
>>> My code is a  mess at the moment but that code is working.
>>>
>>> --b
>>>
>>>
>>> Mark Lowe wrote:
>>>
>>>> I've had the same thing happen using DBCP and C3PO, I believe its  
>>>> the
>>>> driver rather than the pooling. As I said we've a app thats live,  
>>>> and
>>>> i haven't touched it in months using DBCP.
>>>>
>>>> [OT] subject change.. Have you had any joy with byte[] to blob
>>>> mapping for file uploads with hibernate 2.1.4? I created a custom
>>>> usertype, but i get a npe. 2.0 delbt with life, but things appear to
>>>> have taken a step backwards. (please dont make me go the the scary
>>>> hibernate forum :) )
>>>>
>>>>
>>>> On 30 Jul 2004, at 11:34, Joe Hertz wrote:
>>>>
>>>>> I noticed this behavior with 3.0.14.
>>>>>
>>>>> This _really_ sounds like this entry in the Hibernate FAQ to me:
>>>>>
>>>>> http://www.hibernate.org/117.html#A13
>>>>>
>>>>> I wouldn't use DBCP though as Gavin King is apparently fed up with
>>>>> it,
>>>>> and built-in support for it is being yanked in the next major
>>>>> version of
>>>>> Hibernate.
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Marco Mistroni [mailto:mmistroni@waersystems.com]
>>>>>> Sent: Friday, July 30, 2004 5:08 AM
>>>>>> To: 'Struts Users Mailing List'
>>>>>> Subject: RE: OT/ Tomcat, Hibernate and MYSQL problem
>>>>>>
>>>>>>
>>>>>> Hello,
>>>>>>     If I remember correct, mysql connector 3.0.11
>>>>>>
>>>>>> Regards
>>>>>>     marco
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Mark Lowe [mailto:mark.lowe@boxstuff.com]
>>>>>> Sent: 30 July 2004 09:36
>>>>>> To: Struts Users Mailing List
>>>>>> Subject: Re: OT/ Tomcat, Hibernate and MYSQL problem
>>>>>>
>>>>>> Marco
>>>>>>
>>>>>> What jdbc driver are you using?
>>>>>>
>>>>>> They was a shady version 3 behaving like this.
>>>>>>
>>>>>>
>>>>>> On 30 Jul 2004, at 10:05, Joe Hertz wrote:
>>>>>>
>>>>>>> Hibernate's internal connection pooling isn't meant for  
>>>>>>> production
>>>>>>> because it does things just like that.
>>>>>>>
>>>>>>> Suggest you use c3p0 for the pooling.
>>>>>>>
>>>>>>>> From my hibernate.cfg.xml, I only had to add this:
>>>>>>>
>>>>>>>
>>>>>>>        <property name="c3p0.minPoolSize">5</property>
>>>>>>>        <property name="c3p0.maxPoolSize">20</property>
>>>>>>>        <property name="c3p0.timeout">1800</property>
>>>>>>>        <property name="c3p0.max_statement">50</property>
>>>>>>>
>>>>>>> HTH
>>>>>>>
>>>>>>> -Joe
>>>>>>>
>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Marco Mistroni [mailto:mmistroni@waersystems.com]
>>>>>>>> Sent: Friday, July 30, 2004 3:58 AM
>>>>>>>> To: 'Struts Users Mailing List'
>>>>>>>> Subject: OT/ Tomcat, Hibernate and MYSQL problem
>>>>>>>>
>>>>>>>>
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>>     First of all, I apologize for the off topic issue..
>>>>>>>> I know this is not the list, but I tried hibernate forums, and
>>>>>>>> Searched the web with no solution.. hopefully some of u
>>>>>>>
>>>>>> had the Same
>>>>>>
>>>>>>>> problem and solved it..
>>>>>>>>
>>>>>>>>
>>>>>>>> I m experiencing problems with Hibernate in tomcat,
>>>>>>>
>>>>>> talking to mysql.
>>>>>>
>>>>>>>>
>>>>>>>> My situation is that I didn't define any connection pools
>>>>>>>
>>>>>> in tomcat,
>>>>>>
>>>>>>>> but left it to Hibernate to handle that...
>>>>>>>>
>>>>>>>> After leaving the application running for 11 hours, I got
>>>>>>>
>>>>>> following
>>>>>>
>>>>>>>> exception
>>>>>>>>
>>>>>>>> hi all,
>>>>>>>> i have a webapp taht uses Hibernate and MYSQL, running on top of
>>>>>>>> tomcat.
>>>>>>>>
>>>>>>>> i am letting Hibernate handle the connections to mysql db,  
>>>>>>>> since i
>>>>>>>> have no connection pools defined in tomcat. after running the
>>>>>>>> application for nearly 9 hours, when i tried to use my app
>>>>>>>
>>>>>> to connect
>>>>>>
>>>>>>>> to the database i got following exception:
>>>>>>>>
>>>>>>>> Caused by: net.sf.hibernate.JDBCException: Could not
>>>>>>>
>>>>>> execute query at
>>>>>>
>>>>>>>> net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1476)
>>>>>>>> at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:45)
>>>>>>>> at  
>>>>>>>> com.myapp.hibernate.HibernatePersistenceManager.query(Hibernat
>>>>>>>> ePersisten
>>>>>>>> ceManager.java:205)
>>>>>>>> ... 31 more
>>>>>>>> Caused by: java.sql.SQLException: Communication link failure:
>>>>>>>> java.net.SocketException, underlying cause: Software caused
>>>>>>>
>>>>>> connection
>>>>>>
>>>>>>>> abort: recv failed
>>>>>>>>
>>>>>>>> ** BEGIN NESTED EXCEPTION **
>>>>>>>>
>>>>>>>> java.net.SocketException
>>>>>>>> MESSAGE: Software caused connection abort: recv failed
>>>>>>>>
>>>>>>>> STACKTRACE:
>>>>>>>>
>>>>>>>> java.net.SocketException: Software caused connection abort: recv
>>>>>>>> failed
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> now i have searched the web and found two possible
>>>>>>>
>>>>>> alternatives.. one
>>>>>>
>>>>>>>> was to add following problems to hibernate config file..  
>>>>>>>> <property
>>>>>>>> name="connection.autoReconnect">true</property>
>>>>>>>> <property  
>>>>>>>> name="connection.autoReconnectForPools">true</property>
>>>>>>>> <property
>>>>>>>> name="connection.is-connection-validation-required">true</
>>>>>>>> property>
>>>>>>>>
>>>>>>>>
>>>>>>>> but this does not work, as ihave added thos eproperties to
>>>>>>>
>>>>>> hibernate
>>>>>>
>>>>>>>> properties file and i am still getting same exception
>>>>>>>>
>>>>>>>>
>>>>>>>> then I tried to add ?autoReconnect=true  to JBDC URL, but
>>>>>>>
>>>>>> that didn't
>>>>>>
>>>>>>>> work either coz I left application running for 11 hours and  
>>>>>>>> after
>>>>>>>> that I got same exception...
>>>>>>>>
>>>>>>>> can anyone help me out?
>>>>>>>>
>>>>>>>> THANX in advance and regards
>>>>>>>>     marco
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> l: user-help@struts.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>> ------------------------------------------------------------------ 
>>>>>> --
>>>>>> -
>>>>>>
>>>>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ------------------------------------------------------------------ 
>>>>>> --
>>>>>> -
>>>>>>
>>>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------ 
>>>>>> --
>>>>>> -
>>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------ 
>>>>>> --
>>>>>> -
>>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------- 
>>>>> --
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>>> -------------------------------------------------------------------- 
>>>> -
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org