db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From OggieOne64 <oggieon...@hotmail.com>
Subject Re: A truncation error was encountered trying to shrink VARCHARTA 'XX-RESOLVE-XX' to length 255.
Date Mon, 26 Apr 2010 18:32:23 GMT

Thanks! Derby Version is (from Manifest):
Bundle-Name: Apache Derby 10.5
Bundle-Version: 10.5.3000000.802917

I have made a few changes and this is where things stand now.
Domain Object (CastMember) as follows :

byte[] headShot
	
	static constraints = {
		headShot(nullable: true , maxSize:2097152 )
	}	

	static mapping = { 
        id generator:'identity'
        headShot type: 'blob'
    } 

I checked the table in the database and the column HEAD_SHOT is BLOB.

In my controller I am doing the following.

while( itr.hasNext() ) {
	MultipartFile file = request.getFile( itr.next() )
	byte[] myBytes = file.getBytes()
	def castMember = CastMember.findById(params.characterID)
	castMember.headShot = Hibernate.createBlob(myBytes)
	validateAndSave ( castMember )
}    
	   			
The new stacktrace is this,


2010-04-26 13:22:41,315 [31952613@qtp0-4] DEBUG
controller.CharacterController  - >>>upload
2010-04-26 13:22:41,346 [31952613@qtp0-4] ERROR
errors.GrailsExceptionResolver  -
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot
 cast object 'org.hibernate.lob.SerializableBlob@1b5302d' with class
'org.hibernate.lob.SerializableBlob' to class 'java.lang.Number'
org.codehaus.groovy.runtime.InvokerInvocationException:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast
object 'org.hibernat
e.lob.SerializableBlob@1b5302d' with class
'org.hibernate.lob.SerializableBlob' to class 'java.lang.Number'
        at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:92)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1061)
        at
groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:910)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:892)
        at groovy.lang.Closure.call(Closure.java:279)
        at groovy.lang.Closure.call(Closure.java:274)
        at
org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleAction(SimpleGrailsControllerHelper.java:363)
        at
org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.executeAction(SimpleGrailsControllerHelper.java:243)
        at
org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleURI(SimpleGrailsControllerHelper.java:203)
        at
org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleURI(SimpleGrailsControllerHelper.java:138)
        at
org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController.handleRequest(SimpleGrailsController.java:88)
        at
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at
org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:264)
        at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
        at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
        at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1124)
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
        at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
        at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
        at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361)
        at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
        at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
        at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:334)
        at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
        at
org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:293)
        at
org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:269)
        at
org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:261)
        at
org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:181)
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
        at
org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:171)
        at
org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:110)
        at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
        at
org.codehaus.groovy.grails.web.servlet.filter.GrailsReloadServletFilter.doFilterInternal(GrailsReloadServletFilter.java:101)
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
        at
org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:65)
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
        at
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
        at
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
        at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
        at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361)
        at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
        at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
        at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:324)
        at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
        at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:741)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:213)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403)
        at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
        at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException:
Cannot cast object 'org.hibernate.lob.SerializableBlob@1b5302d' with class
'o
rg.hibernate.lob.SerializableBlob' to class 'java.lang.Number'
        at CastMember.setProperty(CastMember.groovy)
        at CharacterController$_closure2.doCall(CharacterController:48)
        at CharacterController$_closure2.doCall(CharacterController)

Thanks in advance!!

Doug


Kristian Waagan-4 wrote:
> 
> On 26.04.10 17:45, OggieOne64 wrote:
>>
>> Thanks for responding but the problem is that I am trying to insert an
>> image
>> (not text). The field is of type Blob.
>> Any other ideas? BTW: How can I verify what version of derby is running?
>> My
>> derby.jar is dated 8/10/2009
> 
> Hi Doug,
> 
> Can you post the stack trace from the exception?
> Are you sure Hibernate is mapping the column to the right column type?
> 
> Regarding the Derby version, one way to figure it out is invoke the 
> command below with at least one of the Derby jars (i.e. derby.jar, 
> derbyclient.jar etc) in the classpath:
> java -cp <yourclasspath> org.apache.derby.tools.sysinfo
>        		 or potentially
> java -jar derbyrun.jar sysinfo
> 
> I don't remember exactly, but I think you can use JDBC meta data calls 
> as well. You can also look at some files inside one of the jars, for 
> instance the manifest file, and if you start ij the version is printed 
> (not the full version, i.e. only 10.5).
> 
> 
> Regards,
> -- 
> Kristian
> 
>>
>> Thanks,
>> Doug
>>
>>
>>
>> Knut Anders Hatlen wrote:
>>>
>>> On 04/24/10 17:18, Doug McGavin wrote:
>>>> I am using the latest version of Derby with Hibernate and getting the
>>>> following error when trying to save an image (the exact same code works
>>>> with MySQL) :
>>>>
>>>> [7613120@qtp0-8] ERROR util.JDBCExceptionReporter  -
>>>>
>>>> A truncation error was encountered trying to shrink VARCHARTA
>>>> 'XX-RESOLVE-XX' to length 255.
>>>>
>>>> I have read that this is a known bug but I don't seem to be able to
>>>> find
>>>> how it was resolved or how to work around it in my code.
>>>
>>> Hi Doug,
>>>
>>> I think this error means you're trying to insert a string that's longer
>>> than 255 characters into a VARCHAR(255) column. Derby will try to
>>> truncate the string if it has trailing spaces, but the above exception
>>> will be thrown if that's not enough to make it fit in the column.
>>>
>>> In Derby 10.5 and later, the error message should show the string you're
>>> trying to insert instead of the rather cryptic string 'XX-RESOLVE-XX'.
>>> (The error message was changed in DERBY-961.)
>>>
>>> --
>>> Knut Anders
>>>
>>>
>>
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/A-truncation-error-was-encountered-trying-to-shrink-VARCHARTA-%27XX-RESOLVE-XX%27-to-length-255.-tp28350914p28368508.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message