Tag - exception

java jpa exception    2017-07-19 22:15:22    1328
错误栈:
org.zkoss.zk.ui.UiException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.TransactionException: JDBC begin transaction failed:  at [file:/C:/Users/lyg21_000/git/Saas/target/classes/main.zul, line:26]
 at org.zkoss.bind.impl.MiscUtil.mergeExceptionInfo(MiscUtil.java:175) ~[zkbind-7.0.4.jar:7.0.4]
 at org.zkoss.bind.BindComposer.doBeforeComposeChildren(BindComposer.java:161) ~[zkbind-7.0.4.jar:7.0.4]
 at org.zkoss.zk.ui.impl.UiEngineImpl.doBeforeComposeChildren(UiEngineImpl.java:930) ~[zk-7.0.4.jar:7.0.4]
 at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:869) ~[zk-7.0.4.jar:7.0.4]
 at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:826) ~[zk-7.0.4.jar:7.0.4]
 at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:735) ~[zk-7.0.4.jar:7.0.4]
 at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:797) ~[zk-7.0.4.jar:7.0.4]
 at org.zkoss.zk.ui.imp
java exception    2017-07-19 22:14:16    1354
分析bug原因:
是因为某次下载jar包的时候出错,导致下文红色部分标注的jar包没有下载下来,在repository目录下,删除此jar包的文件夹,重新下载即可

我这里是junit3的jar包,但是也可能是其他jar包,这个是不确定的




[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project hello: Unable to generate classpath: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing: 
[ERROR] ---------- 
[ERROR] 1) org.apache.maven.surefire:surefire-junit3:jar:2.12.4 
[ERROR] 
[ERROR] Try downloading the file manually from the project website. 
[ERROR] 
[ERROR] Then, install it using the command: 
[ERROR] mvn install:install-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-junit3 -Dversion=2.12.4 -Dpackaging=jar -Dfile=/path/to/file 
[ERROR] 
[ERROR] Alternatively, if you host your own repository you can deploy the file there: 
[ERROR] mvn deploy:deploy-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-junit3 -Dversion=2.12.4 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] 
[ERROR] 
[ERR
hibernate java exception    2017-07-19 22:13:27    1114

Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist  

今天 用JPA保存数据的时候出现此错误。

 

原因:   ID生成策略  我设置的自动。但是代码里面还是手动给对象ID设置了值

 

解决方案: 去掉手动给ID设置值的代码即可。


如:

 @Id

 @GeneratedValue(strategy = GenerationType.IDENTITY)

 @Column(name = "id", unique = true, nullable = false)


这种情况下,会报错,因为对id仅仅是设置了主键,并没有设置自增长,将

    @GeneratedValue(strategy = GenerationType.IDENTITY)

去掉即可

 

 


 

by 刘迎光@萤火虫工作室 
OpenBI交流群:495266201 
MicroService 微服务交流群:217722918 
mail: liuyg#liuyingguang.cn 
博主首页(==防止爬虫==):http://blog.liuyingguang.cn

java mongodb exception    2017-07-19 21:43:42    768
分析:
    参考地址:https://github.com/brianfrankcooper/YCSB/issues/277
    应该是官方的update策略有变化,3.0以前,使用updateOne,3.0以后使用replaceOne
解决办法:
    将updateOne替换为replaceOne即可

完整错误栈:

java.lang.IllegalArgumentException: Invalid BSON field name _id
    at org.bson.AbstractBsonWriter.writeName(AbstractBsonWriter.java:494) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:188) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) ~[bson-3.2.2.jar:na]
    at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(UpdateCommandMessage.java:84) ~[mongodb-driver-core-3.2.2.jar:na]
    at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(Upd
java eclipse exception    2017-07-19 21:18:39    950
错误信息(我的错误类似,网络copy):

java.lang.Error: Unresolved compilation problems: 
The import javax.servlet.ServletContext cannot be resolved
The import javax.servlet.http.HttpSession cannot be resolved
The import javax.servlet.http.HttpSessionEvent cannot be resolved
The import javax.servlet.http.HttpSessionListener cannot be resolved
HttpSessionListener cannot be resolved to a type
ServletContext cannot be resolved to a type
HttpSessionEvent cannot be resolved to a type
HttpSession cannot be resolved to a type
context cannot be resolved
context cannot be resolved
context cannot be resolved
context cannot be resolved
context cannot be resolved
context cannot be resolved
context cannot be resolved
context cannot be resolved
context cannot be resolved
context cannot be resolved
context cannot be resolved
HttpSessionEvent cannot be resolved to a type
HttpSession cannot be resolved to a type




解决办法:
    原因有很多,解决办法也很多,参考地址:
        http://www.360doc.com/content/12/1015/17/4152160_241639166.shtml
        http://blog.csdn.net/chl