《疯狂Workflow讲义——基于Activiti的工作流应用开发》学习笔记之一·环境搭建之编码问题

时间:2021-09-23 10:09:11

        在对activiti有了一定了解之后,开始按《疯狂Workflow讲义——基于Activiti的工作流应用开发》中的步骤搭建环境,新建项目,创建resource文件夹,使用第2张的First.bpmn,activiti.cfg.xml,First.java,修改activiti.cfg.xml中的mysql数据库名act、用户名root、密码123456,改成自己对应的Mysql中的配置(需要新建一个Database,不需要新建表)运行时报错:

2015-3-25 19:31:13 org.activiti.engine.ProcessEngines initProcessEnginFromResource
信息: initializing process engine for resource file:/F:/1/eclipseWorkspace/lcglxt/bin/activiti.cfg.xml
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/F:/1/eclipseWorkspace/lcglxt/lib/slf4j-jdk14-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/F:/1/eclipseWorkspace/lcglxt/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
2015-3-25 19:31:15 org.activiti.engine.impl.ProcessEngineImpl <init>
信息: ProcessEngine default created
2015-3-25 19:31:15 org.activiti.engine.ProcessEngines initProcessEnginFromResource
信息: initialised process engine default
2015-3-25 19:31:15 org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
信息: Processing resource bpmn/First.bpmn
2015-3-25 19:31:15 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
信息: XMLSchema currently not supported as typeLanguage
2015-3-25 19:31:15 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
信息: XPath currently not supported as expressionLanguage
2015-3-25 19:31:15 org.activiti.engine.impl.bpmn.parser.BpmnParse parseProcessDefinitions
信息: Process with id='process1' hasn't the attribute isExecutable set. Please maintain it, so you are compatible to future activiti versions.
2015-3-25 19:31:15 org.activiti.engine.impl.interceptor.CommandContext close
严重: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '麟瑖V砣[憈X暘%F牸I2擷?|梤\\ 蔎璀苶t喹z珥兟??o覀wA 0?xe丘O轿' at line 2
### The error may involve org.activiti.engine.impl.persistence.entity.ResourceEntity.insertResource-Inline
### The error occurred while setting parameters
### SQL: insert into ACT_GE_BYTEARRAY(ID_, REV_, NAME_, BYTES_, DEPLOYMENT_ID_, GENERATED_)     values (?, 1, ?, ?, ?, ?)
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '麟瑖V砣[憈X暘%F牸I2擷?|梤\\ 蔎璀苶t喹z珥兟??o覀wA 0?xe丘O轿' at line 2
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:134)
    at org.activiti.engine.impl.db.DbSqlSession.flushInserts(DbSqlSession.java:459)
    at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:369)
    at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:157)
    at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:109)
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
    at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
    at org.activiti.engine.impl.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:54)
    at org.activiti.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:106)
    at org.crazyit.activiti.First.main(First.java:28)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '麟瑖V砣[憈X暘%F牸I2擷?|梤\\ 蔎璀苶t喹z珥兟??o覀wA 0?xe丘O轿' at line 2
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
    at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1379)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
    ... 10 more


解决办法:

activiti.cfg.xml中对mysql的配置,添加关于字符编码的参数:

<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/task?useUnicode=true&amp;characterEncoding=utf-8" />



参考资料:http://bbs.csdn.net/topics/390594702