环境:
jboss 4.0.2
Eclipse 3.0.1
MySql 4.1.12
在JBOSS中部署 ENTITY Ejb 的时候,老是报错:
org.jboss.deployment.DeploymentException: Error while creating table test; - nested throwable: (java.sql.SQLException: Syntax error or access violation message from server: "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 'NOT NULL, addre varchar, CONSTRAINT pk_test PRIMARY KEY (name))' at line 1")
打开 log:
在log4j.xml文件加入:
<appender name="CMP" class="org.jboss.logging.appender.RollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="log/cmp.log"/>
<param name="Append" value="false"/>
<param name="MaxFileSize" value="500KB"/>
<param name="MaxBackupIndex" value="1"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
</layout>
</appender>
<category name="org.jboss.ejb.plugins.cmp">
<priority value="DEBUG" />
<appender-ref ref="CMP"/>
</category>
重新部署,查看产生的CMP LOG,找到create 语句,在MySql的客户端运行,确实出错。
找到create 语句出错的地方,然后在 jbosscmp-jdbc.xml 中将相应的错误项更正。
问题解决。