Grails 在groovy中保存时,无法将数据库状态与会话错误同步

Grails 在groovy中保存时,无法将数据库状态与会话错误同步,grails,groovy,Grails,Groovy,在groovy controller的save方法中保存/创建包时,我得到了以下错误和堆栈跟踪 Error 500: Executing action [save] of controller [se.accumulate.wizard.SubmissionController] caused exception: could not deserialize; nested exception is org.hibernate.type.SerializationException:

在groovy controller的save方法中保存/创建包时,我得到了以下错误和堆栈跟踪

Error 500: Executing action [save] of controller [se.accumulate.wizard.SubmissionController] caused exception:
  could not deserialize; nested exception is
    org.hibernate.type.SerializationException: could not deserialize java.io.StreamCorruptedException
      at java.util.Hashtable.reconstitutionPut(Hashtable.java:889)
      at java.util.Hashtable.readObject(Hashtable.java:861)
      at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
      at se.accumulate.wizard.PackagingService$$EnhancerByCGLIB$$2b5048f.createPackage(<generated>)
已显示所有日志检查1到4,并已创建预期的输出/文件,但已引发此异常

我的域类:(Submission.groovy哪个extneds向导)

我的DB表提交说明如下:(抱歉格式不正确)

字段类型空键默认值 “应用程序id”、“bigint(20)”、“否”、“空” “应用程序映像”、“blob”、“是”、“空” “应用程序名称”、“varchar(255)”、“是”、“空” “cms_id”,“varchar(255)”,“是”,“空” 'content\u provider\u id','bigint(20)','NO','NULL',' '由用户id创建','未签名的bigint(20),'否','',空'' “创建日期”、“日期时间”、“否”、“空” “部署id”、“bigint(20)”、“否”、“空” “设备映射”、“blob”、“是”、“空” “文件名”,“varchar(255)”,“是”,“空” “已确认”、“tinyint(1)”、“否”、“空” “上次更新”,“日期时间”,“否”,“空” '新的或现有的','整型(11)','否','',空'' “操作系统id”、“bigint(20)”、“否”、“空” “覆盖现有的应用程序详细信息”、“int(11)”、“否”、“空” 'customer_id','bigint(20)','YES','MUL',NULL',' “输出文件名”、“varchar(255)”、“是”、“空” “报告名称”、“varchar(255)”、“是”、“空” “应用程序名称”、“varchar(255)”、“是”、“空” “页面跟踪器”、“int(11)”、“是”、“空”

另一个将从createPackage调用的方法的一部分(更改此方法后,将显示错误)-我刚刚从文件名中过滤了“?”

def createXml(Submission submission){
    Application application = Application.get(submission.getApplicationId());
    ContentProvider contentProvider = ContentProvider.get(submission.getContentProviderId());

    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    Element rootElement = doc.createElement("game");
    rootElement.setAttribute("title", submission.applicationName);
    rootElement.setAttribute("short", submission.applicationShortName);
    rootElement.setAttribute("externalRef", application.cmsId);
    rootElement.setAttribute("contentPartner", contentProvider.name);

    if (submission.applicationImage != null) {
        Element image = doc.createElement("image");
        image.setAttribute("type", "thumbnail");
        image.setAttribute("mime-type", "image/png");
        image.setAttribute("width", "60");
        image.setAttribute("height", "60");
        image.setTextContent("thumbnail_60x60.png");
        rootElement.appendChild(image);
    }

    Properties ps = submission.deviceMapping;
    Properties dm = (Properties) ps;
    for (def device : dm) {
        device.key = device.key.split("\\?")[0];
        logger.debug("key=${device.key}, value=${device.value}")
        if (!(device.value == null || "null".equalsIgnoreCase(device.value))) {
            logger.info("Adding handset: " + device.value);
            Element handset = doc.createElement("handset");
            handset.setAttribute("name", device.value);

            String name = device.key;
            if (name.indexOf('/') >= 0) {
                String[] parts = name.split('/');
                name = parts[parts.length - 1];
            }

            if (name.toLowerCase().endsWith(".jad")) {
                // java and blackberry
                Element jadFile = doc.createElement("jadfile");
                jadFile.setTextContent("Applications/" + name);
                handset.appendChild(jadFile);

                /*
                name = getJarFileName();
                if (name.indexOf('/') >= 0) {
                    String[] parts = name.split('/');
                    name = parts[parts.length - 1];
                }*/

                Element jarFile = doc.createElement("jarfile");
                jarFile.setTextContent("Applications/" + name.replace(".jad", ".jar"));
                handset.appendChild(jarFile);
            }
            else {
                // android
                Element jarFile = doc.createElement("jarfile");
                jarFile.setTextContent("Applications/" + name);
                handset.appendChild(jarFile);
            }

            rootElement.appendChild(handset);
        }
    }
    doc.appendChild(rootElement);

    StringWriter xmlString = new StringWriter();
    try{
        Result result = new StreamResult(xmlString);
        Source source = new DOMSource(doc);

        // Write the DOM document to the file
        Transformer xformer = TransformerFactory.newInstance().newTransformer();
        xformer.transform(source, result);

    } catch (Exception e){
        e.printStackTrace();
    }
    logger.info("XML: " + xmlString.toString());

    return  xmlString;
}

在createXml方法中将属性更改为String,错误已被消除

替换为

java.util.Properties dm = submission.deviceMapping;
        for (String fileName : dm.keys()) {
            String device = dm.getProperty(fileName);
            fileName = fileName.split("\\?")[0];

对这个问题有什么想法吗?Tim…你有没有机会看一下我的代码,你有没有发现我遗漏了什么?我觉得我的计算机行为怪异,从另一台计算机上尝试了相同的代码,猜猜它起了什么作用…嗯,不确定是什么设置在我的计算机中引发了这个错误。当我得到一些解决方案时,我会把它贴在网上,同时欢迎任何其他的意见
def createXml(Submission submission){
    Application application = Application.get(submission.getApplicationId());
    ContentProvider contentProvider = ContentProvider.get(submission.getContentProviderId());

    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    Element rootElement = doc.createElement("game");
    rootElement.setAttribute("title", submission.applicationName);
    rootElement.setAttribute("short", submission.applicationShortName);
    rootElement.setAttribute("externalRef", application.cmsId);
    rootElement.setAttribute("contentPartner", contentProvider.name);

    if (submission.applicationImage != null) {
        Element image = doc.createElement("image");
        image.setAttribute("type", "thumbnail");
        image.setAttribute("mime-type", "image/png");
        image.setAttribute("width", "60");
        image.setAttribute("height", "60");
        image.setTextContent("thumbnail_60x60.png");
        rootElement.appendChild(image);
    }

    Properties ps = submission.deviceMapping;
    Properties dm = (Properties) ps;
    for (def device : dm) {
        device.key = device.key.split("\\?")[0];
        logger.debug("key=${device.key}, value=${device.value}")
        if (!(device.value == null || "null".equalsIgnoreCase(device.value))) {
            logger.info("Adding handset: " + device.value);
            Element handset = doc.createElement("handset");
            handset.setAttribute("name", device.value);

            String name = device.key;
            if (name.indexOf('/') >= 0) {
                String[] parts = name.split('/');
                name = parts[parts.length - 1];
            }

            if (name.toLowerCase().endsWith(".jad")) {
                // java and blackberry
                Element jadFile = doc.createElement("jadfile");
                jadFile.setTextContent("Applications/" + name);
                handset.appendChild(jadFile);

                /*
                name = getJarFileName();
                if (name.indexOf('/') >= 0) {
                    String[] parts = name.split('/');
                    name = parts[parts.length - 1];
                }*/

                Element jarFile = doc.createElement("jarfile");
                jarFile.setTextContent("Applications/" + name.replace(".jad", ".jar"));
                handset.appendChild(jarFile);
            }
            else {
                // android
                Element jarFile = doc.createElement("jarfile");
                jarFile.setTextContent("Applications/" + name);
                handset.appendChild(jarFile);
            }

            rootElement.appendChild(handset);
        }
    }
    doc.appendChild(rootElement);

    StringWriter xmlString = new StringWriter();
    try{
        Result result = new StreamResult(xmlString);
        Source source = new DOMSource(doc);

        // Write the DOM document to the file
        Transformer xformer = TransformerFactory.newInstance().newTransformer();
        xformer.transform(source, result);

    } catch (Exception e){
        e.printStackTrace();
    }
    logger.info("XML: " + xmlString.toString());

    return  xmlString;
}
Properties ps = submission.deviceMapping;
    Properties dm = (Properties) ps;
    for (def device : dm) {
        device.key = device.key.split("\\?")[0];
java.util.Properties dm = submission.deviceMapping;
        for (String fileName : dm.keys()) {
            String device = dm.getProperty(fileName);
            fileName = fileName.split("\\?")[0];