NutzCN Logo
问答 org.nutz.lang.born.BorningException
发布于 3132天前 作者 qq_613b261e 4077 次浏览 复制 上一个帖子 下一个帖子
标签:

2016-4-20 9:34:20.232 DEBUG [http-bio-8080-exec-12] Found mapping for [GET] path=/menu/allTreeNode : MenuModule.allTreeNode(...)
2016-4-20 9:34:20.233 DEBUG [http-bio-8080-exec-12] Get 'menuModule'<class com.jenkin.nutz.module.MenuModule>
2016-4-20 9:34:20.235 DEBUG [http-bio-8080-exec-12] SELECT * FROM tmenu order by seq
2016-4-20 9:34:20.237 INFO [http-bio-8080-exec-12] Fail to value by setter
org.nutz.castor.FailToCastObjectException: Fail to cast from <java.lang.String> to <com.jenkin.nutz.bean.Tmenu> for {0} because:
BorningException:Fail to born 'com.jenkin.nutz.bean.Tmenu'
by args: [
@(0)]
at org.nutz.castor.Castors.cast(Castors.java:258)
at org.nutz.castor.Castors.castTo(Castors.java:320)
at org.nutz.lang.inject.InjectBySetter.inject(InjectBySetter.java:25)
at org.nutz.dao.impl.entity.field.AbstractEntityField.setValue(AbstractEntityField.java:53)
at org.nutz.dao.impl.entity.field.NutMappingField.injectValue(NutMappingField.java:77)
at org.nutz.dao.impl.entity.NutEntity.getObject(NutEntity.java:210)
at org.nutz.dao.impl.sql.pojo.PojoQueryEntityCallback$1.createObject(PojoQueryEntityCallback.java:23)
at org.nutz.dao.pager.ResultSetLooping.doLoop(ResultSetLooping.java:47)
at org.nutz.dao.impl.sql.pojo.PojoQueryEntityCallback.invoke(PojoQueryEntityCallback.java:27)
at org.nutz.dao.impl.jdbc.NutPojo.onAfter(NutPojo.java:108)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:234)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:43)
at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:250)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:64)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:205)
at org.nutz.dao.impl.NutDao.query(NutDao.java:436)
at org.nutz.dao.impl.NutDao.query(NutDao.java:441)
at com.jenkin.nutz.service.MenuService.allTreeNode(MenuService.java:27)
at com.jenkin.nutz.module.MenuModule.allTreeNode(MenuModule.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:23)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:40)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:113)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:64)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:182)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.lang.born.BorningException: Fail to born 'com.jenkin.nutz.bean.Tmenu'
by args: [
@(0)]
at org.nutz.lang.Mirror.born(Mirror.java:929)
at org.nutz.castor.castor.String2Object.cast(String2Object.java:16)
at org.nutz.castor.castor.String2Object.cast(String2Object.java:1)
at org.nutz.castor.Castors.cast(Castors.java:252)
... 54 more
2016-4-20 9:34:20.248 WARN [http-bio-8080-exec-12] Error@/menu/allTreeNode :
org.nutz.dao.DaoException: java.lang.RuntimeException: Fail to set '0'[ null ] by setter com.jenkin.nutz.bean.Tmenu.'setTmenu()' because [org.nutz.lang.born.BorningException: Fail to born 'com.jenkin.nutz.bean.Tmenu'
by args: [
@(0)]]: Fail to born 'com.jenkin.nutz.bean.Tmenu'
by args: [
@(0)]
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:76)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:205)
at org.nutz.dao.impl.NutDao.query(NutDao.java:436)
at org.nutz.dao.impl.NutDao.query(NutDao.java:441)
at com.jenkin.nutz.service.MenuService.allTreeNode(MenuService.java:27)
at com.jenkin.nutz.module.MenuModule.allTreeNode(MenuModule.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:23)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:40)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:113)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:64)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:182)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Fail to set '0'[ null ] by setter com.jenkin.nutz.bean.Tmenu.'setTmenu()' because [org.nutz.lang.born.BorningException: Fail to born 'com.jenkin.nutz.bean.Tmenu'
by args: [
@(0)]]: Fail to born 'com.jenkin.nutz.bean.Tmenu'
by args: [
@(0)]
at org.nutz.lang.Lang.makeThrow(Lang.java:99)
at org.nutz.lang.inject.InjectBySetter.inject(InjectBySetter.java:31)
at org.nutz.dao.impl.entity.field.AbstractEntityField.setValue(AbstractEntityField.java:53)
at org.nutz.dao.impl.entity.field.NutMappingField.injectValue(NutMappingField.java:77)
at org.nutz.dao.impl.entity.NutEntity.getObject(NutEntity.java:210)
at org.nutz.dao.impl.sql.pojo.PojoQueryEntityCallback$1.createObject(PojoQueryEntityCallback.java:23)
at org.nutz.dao.pager.ResultSetLooping.doLoop(ResultSetLooping.java:47)
at org.nutz.dao.impl.sql.pojo.PojoQueryEntityCallback.invoke(PojoQueryEntityCallback.java:27)
at org.nutz.dao.impl.jdbc.NutPojo.onAfter(NutPojo.java:108)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:234)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:43)
at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:250)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:64)
... 41 more

9 回复

整个pojo贴一下

package com.jenkin.nutz.bean;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Many;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.Table;

/**
* tmenu
* @author otom3
* @date 2016-04-20
/
@Table("tmenu")
public class Tmenu implements Serializable {
private static final long serialVersionUID = 1L;
/
*
* tmenu
*/
@Name
private java.lang.String id;//ID
@Column
private java.lang.String iconcls;//ICONCLS
@Column
private java.math.BigDecimal seq;//SEQ
@Column
private java.lang.String text;//TEXT
@Column
private java.lang.String url;//URL

@Many(field = "PID", target = Tmenu.class)
private Tmenu tmenu;//PID
public Tmenu getTmenu() {
    return tmenu;
}
public void setTmenu(Tmenu tmenu) {
       this.tmenu = tmenu;
}
private Set<Tmenu> tmenus = new HashSet<Tmenu>(0);
public Set<Tmenu> getTmenus() {
    return tmenus;
}
public void setTmenus(Set<Tmenu> tmenus) {
    this.tmenus = tmenus;
}
public java.lang.String getId(){
    return this.id;
}
public void setId(java.lang.String id){
    this.id    = id;
}
public java.lang.String getIconcls(){
    return this.iconcls;
}
public void setIconcls(java.lang.String iconcls){
    this.iconcls   = iconcls;
}
public java.math.BigDecimal getSeq(){
    return this.seq;
}
public void setSeq(java.math.BigDecimal seq){
    this.seq   = seq;
}
public java.lang.String getText(){
    return this.text;
}
public void setText(java.lang.String text){
    this.text  = text;
}
public java.lang.String getUrl(){
    return this.url;
}
public void setUrl(java.lang.String url){
    this.url   = url;
}

}

@wendal(wendal) 前面那个异常是因为我没有标示外键多对一关联,nutz只有一对多关联

@wendal(wendal) private Tmenu tmenu;//PID是父menu,怎么写子menu和父menu的多对一关系

怎么这个类没有PID属性呢? 关联属性是必须写出来的

@wendal(wendal) 自关联多对一怎么写呢

跟普通的@One没区别

public class Tmenu {
    @Id
    private String id;
    private String pid;
	@One(target=Tmenu, field="pid")
    private Tmenu parent;
    // 其他属性及getter/setter
}

@wendal(wendal) package com.jenkin.nutz.bean;

import java.io.Serializable;
import java.util.List;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Many;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Table;

/**
* tmenu
* @author otom3
* @date 2016-04-20
/
@Table("tmenu")
public class Tmenu implements Serializable {
private static final long serialVersionUID = 1L;
/
*
* tmenu
*/
@Name
private java.lang.String id;//ID
@Column
private java.lang.String iconcls;//ICONCLS
@Column
private java.math.BigDecimal seq;//SEQ
@Column
private java.lang.String text;//TEXT
@Column
private java.lang.String url;//URL
@Column("PID")
private String pid;

 public String getPid() {
    return pid;
}
public void setPid(String pid) {
    this.pid = pid;
}

@One(target=Tmenu.class, field="pid")
private Tmenu parent;//多对一

 public Tmenu getParent() {
    return parent;
}
public void setParent(Tmenu parent) {
    this.parent = parent;
}
@Many(field = "pid", target = Tmenu.class)
private List<Tmenu> children;//一对多
public List<Tmenu> getChildren() {
    return children;
}
public void setChildren(List<Tmenu> children) {
    this.children = children;
}
public java.lang.String getId(){
    return this.id;
}
public void setId(java.lang.String id){
    this.id    = id;
}
public java.lang.String getIconcls(){
    return this.iconcls;
}
public void setIconcls(java.lang.String iconcls){
    this.iconcls   = iconcls;
}
public java.math.BigDecimal getSeq(){
    return this.seq;
}
public void setSeq(java.math.BigDecimal seq){
    this.seq   = seq;
}
public java.lang.String getText(){
    return this.text;
}
public void setText(java.lang.String text){
    this.text  = text;
}
public java.lang.String getUrl(){
    return this.url;
}
public void setUrl(java.lang.String url){
    this.url   = url;
}

}

@One(target=Tmenu.class, field="pid")
private Tmenu parent;//多对一
加了@one注解后,断点测试parent一直都是空的啊,难道不会调用这个
public void setParent(Tmenu parent) {
this.parent = parent;
}方法给parent赋值吗?

@qq_613b261e fetchLinks之后关联关系才会有值

添加回复
请先登陆
回到顶部