springmvc 集成activiti 保存model模型时 linnux 服务器上面报错,但在windows服务器上面却可以

 

问题一:Can't connect to X11 window server using 'localhost:11.0' as the value of

以下一行代码有可能解决问题,找到tomcat 的bin目录 catalina.sh 文件,加上

export CATALINA_OPTS="-Djava.awt.headless=true" 这一句

springmvc 集成activiti 保存model模型时 linnux 服务器上面报错,但在windows服务器上面却可以_第1张图片

问题二:java.lang.NoClassDefFoundError: Could not initialize class org.apache.batik.bridge.CursorManager

pom.xml文件里面配置 


    batik
    batik-script
    1.7

springmvc 集成activiti 保存model模型时 linnux 服务器上面报错,但在windows服务器上面却可以_第2张图片

问题三:在保存模型时

 

springmvc 集成activiti 保存model模型时 linnux 服务器上面报错,但在windows服务器上面却可以_第3张图片

 

方法一:

    @RequestMapping(value="/model/{modelId}/save", method = RequestMethod.PUT)
    @ResponseStatus(value = HttpStatus.OK)
    public void saveModel(@PathVariable String modelId, @RequestParam("name") String name,
                          @RequestParam("description") String description, @RequestParam("json_xml") String json_xml,
                          @RequestParam("svg_xml") String svg_xml) {
        try {
            Model model = repositoryService.getModel(modelId);
            ObjectNode modelJson = (ObjectNode) objectMapper.readTree(model.getMetaInfo());
            modelJson.put(MODEL_NAME, name);
            modelJson.put(MODEL_DESCRIPTION, description);
            model.setMetaInfo(modelJson.toString());
            model.setName(name);
            repositoryService.saveModel(model);
            repositoryService.addModelEditorSource(model.getId(), json_xml.getBytes("UTF-8"));
            InputStream svgStream = new ByteArrayInputStream(svg_xml.getBytes("UTF-8"));
            TranscoderInput input = new TranscoderInput(svgStream);
            PNGTranscoder transcoder = new PNGTranscoder();
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            TranscoderOutput output = new TranscoderOutput(outStream);
            transcoder.transcode(input, output);
            final byte[] result = outStream.toByteArray();
            repositoryService.addModelEditorSourceExtra(model.getId(), result);
            outStream.close();
        } catch (Exception e) {
            LOGGER.error("Error saving model", e);
            throw new ActivitiException("Error saving model", e);
        }
    }

按照方法一的写法,可能保存获取不到名称、描述等参数,可以参考方法二来接收:

方法二:如下

@RequestMapping(value = {"/model/{modelId}/save"}, method = {org.springframework.web.bind.annotation.RequestMethod.PUT})
    @ResponseStatus(HttpStatus.OK)
    public void saveModel(@PathVariable String modelId, @RequestBody MultiValueMap values) {
        try {
            Model model = this.repositoryService.getModel(modelId);
            System.out.println("ModelSaveRestResource.saveModel----------");
            ObjectNode modelJson = (ObjectNode) this.objectMapper.readTree(model.getMetaInfo());

            modelJson.put("name", (String) values.getFirst("name"));
            modelJson.put("description", (String) values.getFirst("description"));
            model.setMetaInfo(modelJson.toString());
            model.setName((String) values.getFirst("name"));

            this.repositoryService.saveModel(model);

            this.repositoryService.addModelEditorSource(model.getId(), ((String) values.getFirst("json_xml")).getBytes("utf-8"));

            InputStream svgStream = new ByteArrayInputStream(((String) values.getFirst("svg_xml")).getBytes("utf-8"));
            TranscoderInput input = new TranscoderInput(svgStream);

            PNGTranscoder transcoder = new PNGTranscoder();

            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            TranscoderOutput output = new TranscoderOutput(outStream);

            transcoder.transcode(input, output);
            byte[] result = outStream.toByteArray();
            this.repositoryService.addModelEditorSourceExtra(model.getId(), result);
            outStream.close();
        } catch (Exception e) {
            LOGGER.error("Error saving model", e);
            throw new ActivitiException("Error saving model", e);
        }
    }

 

你可能感兴趣的:(java)