2014-09-22 52 views
1

当我尝试在我的Grails应用程序中保存新记录时,我收到一个arrayIndexOutOfBounds异常。Grails 2.4.2域不会保存超过8个字段

我已经将问题缩小到只能保存8个字段。

这里是我的域类:

package nhvr 

class NhvrJourny { 

static constraints = { 
    nhvrNo nullable:true 
    journeyId nullable:true 
    width nullable:true 
    vLength nullable:true 
    height nullable:true 
    rearOverhang nullable:true 
     } 


    Long nhvrNo 
    String journeyId 
    String title 
    BigDecimal width 
    BigDecimal vLength 
    BigDecimal height 
    BigDecimal rearOverhang 

    String toString(){ 
     return "$nhvrNo $title" 
    } 
} 

林节省通过服务的数据。该方法是这样的:

def saveJourny(Map nhvrJourneyPars) { 

    if (nhvrJourneyPars?.dateArchived) 
     da = df.parse(nhvrJourneyPars.dateArchived) 

    Map journeyPars = [ 
      journeyId  : nhvrJourneyPars.journeyId, 
      title   : nhvrJourneyPars.title, 
      nhvrNo  : nhvrJourneyPars.nhvrNo, 
      width   : nhvrJourneyPars.width, 
      vLength  : nhvrJourneyPars.vLength, 
      height  : nhvrJourneyPars.height, 
      rearOverhang : nhvrJourneyPars.rearOverhang 
    ] 
    NhvrJourny nhvrJournyInstance = new NhvrJourny(journeyPars) 

    println "journeyPars:" 
    journeyPars.each{ 
     println "${it.key}: ${it.value}" 
    } 

    if (nhvrJournyInstance == null) { 
     println "nhvrJournyInstance is null" 
     notFound() 
     return 
    } 

    if (!nhvrJournyInstance.validate()) { 
     if (nhvrJournyInstance.hasErrors()) { 
      println "Errors: ${nhvrJournyInstance.errors.allErrors}" 
      respond nhvrJournyInstance.errors, view: 'create' 
      return 
     } 
    } 
    else{ 
     println "No errors in nhvrJourneysInstance." 
    } 

    println "nhvrJournyInstance.properties" 
    nhvrJournyInstance.properties.each{ 
     println " ${it.key}: ${it.value}" 
    } 
    nhvrJournyInstance.save(flush:true) 
    return nhvrJournyInstance 
} 

我可以看到,在被传递的数据,它看起来OK:

nhvrJournyInstance: {"journeyId":"j1","title":"test","nhvrNo":"2","width":3,"height":3,"vLength":21,"rearOverhang":1} 

这是目前返回一个异常的ArrayIndexOutOfBounds当我叫nhvrJournyInstance.save(冲洗: true)

如果我从Domain类中删除一个字段,那么数据将被保存。注意:虽然只显示七个字段,但ID和版本正在自动添加。

我一直在使用运行的应用程序从Windows上的IntelliJ 13.1.4 7 我的Grails版本测试是2.4.2和Java版本是1.7.0_60 数据库使用ojdbc6.jar

的Oracle 11g灿有人对此有所了解?这让我疯狂。

编辑 - 这里是堆栈跟踪:

14. Stacktrace follows: 
Message: 14 
    Line | Method 
->> 950 | computeBasicInfo   in oracle.jdbc.driver.OracleSql 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 623 | getSqlKind    in  '' 
| 1212 | <init> . . . . . . . . . in oracle.jdbc.driver.OraclePreparedStatement 
|  28 | <init>     in oracle.jdbc.driver.T4CPreparedStatement 
|  68 | allocatePreparedStatement in oracle.jdbc.driver.T4CDriverExtension 
| 3140 | prepareStatement   in oracle.jdbc.driver.PhysicalConnection 
| 3042 | prepareStatement . . . . in  '' 
| 6022 | prepareStatement   in  '' 
| 699 | $tt__saveJourney . . . . in nhvr.NhvrService 
|  58 | $tt__saveJourney   in nhvr.NhvrJourneyController 
| 198 | doFilter . . . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter 
|  63 | doFilter     in grails.plugin.cache.web.filter.AbstractFilter 
| 1145 | runWorker . . . . . . . . in java.util.concurrent.ThreadPoolExecutor 
| 615 | run      in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 745 | run . . . . . . . . . . . in java.lang.Thread 
enter code here 
+0

这听起来不对。你能发布与ArrayIndexOutOfBoundsException关联的堆栈跟踪吗?整件事情没有必要,但是显示足够的框架以回到服务中的代码行。 – 2014-09-22 12:27:59

+0

stacktrace完全符合我的服务中的行:nhvrJournyInstance.save(flush:true)。这是什么令人沮丧 – 2014-09-22 22:01:55

+0

你的意思是堆栈中的最后一帧是调用'.save(flush:true)'? – 2014-09-23 01:30:07

回答

2

它与ojdbc6.jar文件的版本,我用连接到一个数据库中的问题。

我已经下载了这个文件的另一个版本,这个文件大了500kb,现在它正在工作。

感谢杰夫的意见。