|
I am running into an odd problem with my application. The app was developed and tested with HSQLDB, and worked fine. When I built a WAR file & deployed it on a server, one particular bit of code (crucial to the app, of course) failed.
The code def assessment = Assessment.findByPostingAndAssessor(posting, judge) The error: Caused by: java.sql.SQLException: No value specified for parameter 2 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2214) at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2138) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1853) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1808) at org.hibernate.loader.Loader.doQuery(Loader.java:697) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2228) I looked around on Google, and found this rather old blog post http://blog.flurdy.com/2008/09/no-value-specified-for-parameter-when.html which alludes to this problem and says it was caused by a bad version of hibernate. But that's three years old; I am now using grails 1.3.7 with hibernate plugin 1.3.7. Furthermore, I couldn't figure out where to find the maven specifications that the blog post describes so that I could edit them. And none of my other apps is exhibiting this problem. I tried using the finder as above, and tried manually to create a criteria query, but both produced the same error. Neither value passed to the method is null. I really really really need this to work ASAP, so I am wondering if anyone has any ideas of what to try next. For the record, the full stack trace is attached as a file. Thanks, Gene hibernate-exception.txt |
|
Have you turned on Hibernate logging to try to see the sql generated? On Sep 2, 2011 9:16 PM, "Gene Golovchinsky" <[hidden email]> wrote:
> I am running into an odd problem with my application. The app was developed > and tested with HSQLDB, and worked fine. When I built a WAR file & deployed > it on a server, one particular bit of code (crucial to the app, of course) > failed. > > The code > > def assessment = Assessment.findByPostingAndAssessor(posting, judge) > > > The error: > > Caused by: java.sql.SQLException: No value specified for parameter 2 > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) > at > com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2214) > at > com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2138) > at > com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1853) > at > org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) > at org.hibernate.loader.Loader.getResultSet(Loader.java:1808) > at org.hibernate.loader.Loader.doQuery(Loader.java:697) > at > org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) > at org.hibernate.loader.Loader.doList(Loader.java:2228) > > > I looked around on Google, and found this rather old blog post > > http://blog.flurdy.com/2008/09/no-value-specified-for-parameter-when.html > > which alludes to this problem and says it was caused by a bad version of > hibernate. But that's three years old; I am now using grails 1.3.7 with > hibernate plugin 1.3.7. Furthermore, I couldn't figure out where to find the > maven specifications that the blog post describes so that I could edit them. > > And none of my other apps is exhibiting this problem. I tried using the > finder as above, and tried manually to create a criteria query, but both > produced the same error. Neither value passed to the method is null. > > I really really really need this to work ASAP, so I am wondering if anyone > has any ideas of what to try next. > > For the record, the full stack trace is attached as a file. > > Thanks, > > Gene > > http://grails.1312388.n4.nabble.com/file/n3787337/hibernate-exception.txt > hibernate-exception.txt > > > > > -- > View this message in context: http://grails.1312388.n4.nabble.com/problem-using-mysql-with-hibernate-grails-v1-3-7-tp3787337p3787337.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > |
|
In reply to this post by Gene Golovchinsky
Might be a data problem. Make sure that judge is not null.
--------------------------- www.maf.org/rhoads www.ontherhoads.org On Fri, Sep 2, 2011 at 7:15 PM, Gene Golovchinsky <[hidden email]> wrote: > I am running into an odd problem with my application. The app was developed > and tested with HSQLDB, and worked fine. When I built a WAR file & deployed > it on a server, one particular bit of code (crucial to the app, of course) > failed. > > The code > > def assessment = Assessment.findByPostingAndAssessor(posting, judge) > > > The error: > > Caused by: java.sql.SQLException: No value specified for parameter 2 > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) > at > com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2214) > at > com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2138) > at > com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1853) > at > org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) > at org.hibernate.loader.Loader.getResultSet(Loader.java:1808) > at org.hibernate.loader.Loader.doQuery(Loader.java:697) > at > org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) > at org.hibernate.loader.Loader.doList(Loader.java:2228) > > > I looked around on Google, and found this rather old blog post > > http://blog.flurdy.com/2008/09/no-value-specified-for-parameter-when.html > > which alludes to this problem and says it was caused by a bad version of > hibernate. But that's three years old; I am now using grails 1.3.7 with > hibernate plugin 1.3.7. Furthermore, I couldn't figure out where to find the > maven specifications that the blog post describes so that I could edit them. > > And none of my other apps is exhibiting this problem. I tried using the > finder as above, and tried manually to create a criteria query, but both > produced the same error. Neither value passed to the method is null. > > I really really really need this to work ASAP, so I am wondering if anyone > has any ideas of what to try next. > > For the record, the full stack trace is attached as a file. > > Thanks, > > Gene > > http://grails.1312388.n4.nabble.com/file/n3787337/hibernate-exception.txt > hibernate-exception.txt > > > > > -- > View this message in context: http://grails.1312388.n4.nabble.com/problem-using-mysql-with-hibernate-grails-v1-3-7-tp3787337p3787337.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Jonathan Rosenberg
I've checked that the data are not null; the relevant logging information is this:
11/09/02 17:56:15 DEBUG hibernate.SQL: select this_.id as id22_0_, this_.version as version22_0_, this_.assessor_id as asse ssor3_22_0_, this_.comment as comment22_0_, this_.date_created as date5_22_0_, this_.last_updated as last6_22_0_, this_.val ue as value22_0_ from assessment this_ where this_.id=? and this_.assessor_id=? 11/09/02 17:56:15 TRACE type.LongType: binding '2' to parameter: 1 11/09/02 17:56:15 ERROR util.JDBCExceptionReporter: No value specified for parameter 2 11/09/02 17:56:15 ERROR docusearch.UiController: Could not save assessment org.hibernate.exception.SQLGrammarException: could not execute query Thanks, Gene |
|
I assume you have current version of mysql jdbc connector? On Sep 2, 2011 11:05 PM, "Gene Golovchinsky" <[hidden email]> wrote:
> I've checked that the data are not null; the relevant logging information is > this: > > > 11/09/02 17:56:15 DEBUG hibernate.SQL: select this_.id as id22_0_, > this_.version as version22_0_, this_.assessor_id as asse > ssor3_22_0_, this_.comment as comment22_0_, this_.date_created as > date5_22_0_, this_.last_updated as last6_22_0_, this_.val > ue as value22_0_ from assessment this_ where this_.id=? and > this_.assessor_id=? > 11/09/02 17:56:15 TRACE type.LongType: binding '2' to parameter: 1 > 11/09/02 17:56:15 ERROR util.JDBCExceptionReporter: No value specified for > parameter 2 > 11/09/02 17:56:15 ERROR docusearch.UiController: Could not save assessment > org.hibernate.exception.SQLGrammarException: could not execute query > > Thanks, > > Gene > > -- > View this message in context: http://grails.1312388.n4.nabble.com/problem-using-mysql-with-hibernate-grails-v1-3-7-tp3787337p3787419.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > |
|
In reply to this post by Gene Golovchinsky
Kind of a shot in the dark: could it be a datatype issue?
Does this work? def assessment = Assessment.findByAssessor( judge) --------------------------- www.maf.org/rhoads www.ontherhoads.org On Fri, Sep 2, 2011 at 9:05 PM, Gene Golovchinsky <[hidden email]> wrote: > I've checked that the data are not null; the relevant logging information is > this: > > > 11/09/02 17:56:15 DEBUG hibernate.SQL: select this_.id as id22_0_, > this_.version as version22_0_, this_.assessor_id as asse > ssor3_22_0_, this_.comment as comment22_0_, this_.date_created as > date5_22_0_, this_.last_updated as last6_22_0_, this_.val > ue as value22_0_ from assessment this_ where this_.id=? and > this_.assessor_id=? > 11/09/02 17:56:15 TRACE type.LongType: binding '2' to parameter: 1 > 11/09/02 17:56:15 ERROR util.JDBCExceptionReporter: No value specified for > parameter 2 > 11/09/02 17:56:15 ERROR docusearch.UiController: Could not save assessment > org.hibernate.exception.SQLGrammarException: could not execute query > > Thanks, > > Gene > > -- > View this message in context: http://grails.1312388.n4.nabble.com/problem-using-mysql-with-hibernate-grails-v1-3-7-tp3787337p3787419.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Jonathan Rosenberg
I am using mysql-connector-java-5.1.7-bin.jar
|
|
In reply to this post by bdrhoa
I'll check if this works. But I really do want to test for both posting & assessor, as that's the unique value.
|
|
In reply to this post by bdrhoa
The single parameter finder works. Here is the log:
11/09/02 20:38:59 DEBUG hibernate.SQL: select this_.id as id0_0_, this_.version as version0_0_, this_.assessor_id as assess or3_0_0_, this_.comment as comment0_0_, this_.date_created as date5_0_0_, this_.last_updated as last6_0_0_, this_.value as value0_0_ from assessment this_ where this_.assessor_id=? 11/09/02 20:38:59 TRACE type.LongType: binding '2' to parameter: 1 Some assessment [null] by com.fxpal.docusearch.Searcher : 2 This last line is printed by my code after the findByAssessor() call returns null. (As it should, since I cannot create any assessments at the moment!) The rest of the log is as before: 11/09/02 20:38:59 DEBUG hibernate.SQL: select this_.id as id0_0_, this_.version as version0_0_, this_.assessor_id as assess or3_0_0_, this_.comment as comment0_0_, this_.date_created as date5_0_0_, this_.last_updated as last6_0_0_, this_.value as value0_0_ from assessment this_ where this_.id=? and this_.assessor_id=? 11/09/02 20:38:59 TRACE type.LongType: binding '2' to parameter: 1 11/09/02 20:38:59 ERROR util.JDBCExceptionReporter: No value specified for parameter 2 11/09/02 20:38:59 ERROR docusearch.UiController: Could not save assessment org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select this_.id as id0_0_, t his_.version as version0_0_, this_.assessor_id as assessor3_0_0_, this_.comment as comment0_0_, this_.date_created as date5 _0_0_, this_.last_updated as last6_0_0_, this_.value as value0_0_ from assessment this_ where this_.id=? and this_.assessor _id=?]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java: 629) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411) ... Thanks for thinking about this! Gene |
|
It shouldn't make any difference, but just for grins try:
def assessment = Assessment.findByAsessorAndPosting(judge,posting) I'd also load up a few records in your bootstrap. Does it work when you have matching data? You can try playing with this by in the console. Does it work from there? If none of that works, trying using criteria and/or hql. But I can tell you that in general, dynamic finders like that do work. --------------------------- www.maf.org/rhoads www.ontherhoads.org On Fri, Sep 2, 2011 at 9:42 PM, Gene Golovchinsky <[hidden email]> wrote: > The single parameter finder works. Here is the log: > > > 11/09/02 20:38:59 DEBUG hibernate.SQL: select this_.id as id0_0_, > this_.version as version0_0_, this_.assessor_id as assess > or3_0_0_, this_.comment as comment0_0_, this_.date_created as date5_0_0_, > this_.last_updated as last6_0_0_, this_.value as > value0_0_ from assessment this_ where this_.assessor_id=? > 11/09/02 20:38:59 TRACE type.LongType: binding '2' to parameter: 1 > Some assessment [null] by com.fxpal.docusearch.Searcher : 2 > > This last line is printed by my code after the findByAssessor() call returns > null. (As it should, since I cannot create any assessments at the moment!) > > The rest of the log is as before: > > 11/09/02 20:38:59 DEBUG hibernate.SQL: select this_.id as id0_0_, > this_.version as version0_0_, this_.assessor_id as assess > or3_0_0_, this_.comment as comment0_0_, this_.date_created as date5_0_0_, > this_.last_updated as last6_0_0_, this_.value as > value0_0_ from assessment this_ where this_.id=? and this_.assessor_id=? > 11/09/02 20:38:59 TRACE type.LongType: binding '2' to parameter: 1 > 11/09/02 20:38:59 ERROR util.JDBCExceptionReporter: No value specified for > parameter 2 > 11/09/02 20:38:59 ERROR docusearch.UiController: Could not save assessment > org.springframework.dao.InvalidDataAccessResourceUsageException: could not > execute query; SQL [select this_.id as id0_0_, t > his_.version as version0_0_, this_.assessor_id as assessor3_0_0_, > this_.comment as comment0_0_, this_.date_created as date5 > _0_0_, this_.last_updated as last6_0_0_, this_.value as value0_0_ from > assessment this_ where this_.id=? and this_.assessor > _id=?]; nested exception is org.hibernate.exception.SQLGrammarException: > could not execute query > at > org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java: > 629) > at > org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) > at > org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411) > ... > > Thanks for thinking about this! > > Gene > > -- > View this message in context: http://grails.1312388.n4.nabble.com/problem-using-mysql-with-hibernate-grails-v1-3-7-tp3787337p3787445.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
The thing is that this code works fine when I run it as run-app. So it's not sn issue with my code, I think. It seems like something that hibernate isn't doing right. Gene Sent from my iPhone
|
|
It could just as easily be a Grails problem in creating the findBy... method. Can you work around it with HQL or criteria?
-- Jonathan Rosenberg Founder & Executive Director Tabby's Place, a Cat Sanctuary http://www.tabbysplace.org/ On Sat, Sep 3, 2011 at 12:20 PM, Gene Golovchinsky <[hidden email]> wrote:
|
|
I tried Criteria & it causes the same problem. Again, the code works when I run the program via 'grails run-app' but doesn't work when I run as a war file.
Thanks, Gene |
|
Are you using different environments when doing run-app vs war?
-- Jonathan Rosenberg Founder & Executive Director Tabby's Place, a Cat Sanctuary http://www.tabbysplace.org/ On Sat, Sep 3, 2011 at 12:57 PM, Gene Golovchinsky <[hidden email]> wrote: I tried Criteria & it causes the same problem. Again, the code works when I |
|
No difference -- I get the same error in both cases.
|
|
In reply to this post by Gene Golovchinsky
Just in case, try:
grails prod run-app or grails run-war and grails prod run-war And test your application. But I think it would be better to provide a small test application reproducing the issue. Best regards, Daniel. Gene Golovchinsky wrote: > I tried Criteria & it causes the same problem. Again, the code works when I > run the program via 'grails run-app' but doesn't work when I run as a war > file. > > Thanks, > > Gene > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Gene Golovchinsky
Can you log a dump() of each object just before you make the call to findBy... & see what you get?
-- Jonathan Rosenberg Founder & Executive Director Tabby's Place, a Cat Sanctuary http://www.tabbysplace.org/ On Sat, Sep 3, 2011 at 1:36 PM, Gene Golovchinsky <[hidden email]> wrote: No difference -- I get the same error in both cases. |
|
In reply to this post by Gene Golovchinsky
Hi Gene,
did you try to 'grails clean' before deployment? Would you mind posting your Domain-Model? Is your assessor 'judge' properly loaded? You could write a HQL query containing a WHERE clause matching to the assessor.id Greets, Jan On 9/3/11 3:15 AM, Gene Golovchinsky wrote: > I am running into an odd problem with my application. The app was developed > and tested with HSQLDB, and worked fine. When I built a WAR file& deployed > it on a server, one particular bit of code (crucial to the app, of course) > failed. > > The code > > defassessment = Assessment.findByPostingAndAssessor(posting, judge) > > > The error: > > Caused by: java.sql.SQLException: No value specified for parameter 2 > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) > at > com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2214) > at > com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2138) > at > com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1853) > at > org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) > at org.hibernate.loader.Loader.getResultSet(Loader.java:1808) > at org.hibernate.loader.Loader.doQuery(Loader.java:697) > at > org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) > at org.hibernate.loader.Loader.doList(Loader.java:2228) > > > I looked around on Google, and found this rather old blog post > > http://blog.flurdy.com/2008/09/no-value-specified-for-parameter-when.html > > which alludes to this problem and says it was caused by a bad version of > hibernate. But that's three years old; I am now using grails 1.3.7 with > hibernate plugin 1.3.7. Furthermore, I couldn't figure out where to find the > maven specifications that the blog post describes so that I could edit them. > > And none of my other apps is exhibiting this problem. I tried using the > finder as above, and tried manually to create a criteria query, but both > produced the same error. Neither value passed to the method is null. > > I really really really need this to work ASAP, so I am wondering if anyone > has any ideas of what to try next. > > For the record, the full stack trace is attached as a file. > > Thanks, > > Gene > > http://grails.1312388.n4.nabble.com/file/n3787337/hibernate-exception.txt > hibernate-exception.txt > > > > > -- > View this message in context: http://grails.1312388.n4.nabble.com/problem-using-mysql-with-hibernate-grails-v1-3-7-tp3787337p3787337.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Jonathan Rosenberg
The dumps look fine. I will try to build a test app I guess, to see what I can reproduce.
|
|
In reply to this post by Daniel Henrique Alves Lima
I have built a small test app that illustrates the issue. The app creates two domain classes (one Posting and one Searcher, and tries to create an Assessment that ties the two together. Before creating a new Assessment, it tries to find a matching existing one. This is the operation that fails.)
If you run this app in development mode with 'grails run-app' (i.e., with an HSQLDB memory database), it behaves correctly. If you run it as 'gralis prod run-app' it fails because it forgets to bind the second parameter to the findBy...() method. Thanks, Gene test.zip |
| Powered by Nabble | Edit this page |
