多数据源 启动报错 空指针异常

中国研究生人才网_91student 发布于 2016/09/26 18:07
阅读 140
收藏 0

@JFinal 你好,想跟你请教个问题:

public void configPlugin(Plugins me) {
// 配置数据库连接池插件
Prop p = PropKit.use("jdbc.properties");
DruidPlugin adruidPlugin = new DruidPlugin(p.get("jdbc.url"), p.get("jdbc.user"), p.get("jdbc.password"));
adruidPlugin.addFilter(new StatFilter());
me.add(adruidPlugin);
/* AutoTableBindPlugin autoTableBindPlugin = new AutoTableBindPlugin(druidPlugin, TableNameStyle.LOWER);
autoTableBindPlugin.setShowSql(true);
autoTableBindPlugin.setContainerFactory(new CaseInsensitiveContainerFactory());
me.add(autoTableBindPlugin);*/

ActiveRecordPlugin  arp =  new ActiveRecordPlugin("64Data",adruidPlugin);
arp.setShowSql(true);
arp.setContainerFactory(new CaseInsensitiveContainerFactory(true));   //设置大小写不敏感
arp.addMapping("area", "id", Area.class);
arp.addMapping("blog_upvote", "upvote_id", BlogUpvote.class);
arp.addMapping("co_activity", "co_activity_id", CoActivity.class);
arp.addMapping("CO_ACTIVITY_FILE", "CO_ACTIVITY_FILE_ID", CoActivityFile.class);
arp.addMapping("CO_COMMENT", "CO_COMMENT_ID", CoComment.class);
arp.addMapping("CO_COMMENT_REPLY", "CO_COMMENT_REPLY_ID", CoCommentReply.class);
arp.addMapping("CO_COMMENT_UPVOTE", "ID", CoCommentUpvote.class);
arp.addMapping("co_doc", "co_doc_id", CoDoc.class);
arp.addMapping("co_doc_comment", "id", CoDocComment.class);
arp.addMapping("co_doc_remark", "id", CoDocRemark.class);
arp.addMapping("co_member", "id", CoMember.class);
arp.addMapping("comment_t", "comment_id", CommentT.class);
arp.addMapping("comment_upvote", "upvote_id", CommentUpvote.class);
arp.addMapping("CO_MSG", "CO_MSG_ID", CoMsg.class);
arp.addMapping("course_answer", "course_answer_id", CourseAnswer.class);
arp.addMapping("COURSE_HOMEWORK", "COURSE_HOMEWORK_ID", CourseHomeWork.class);
arp.addMapping("course_question", "course_question_id", CourseQuestion.class);
arp.addMapping("crouse_model_tree", "crouse_model_tree_id", CrouseMode.class);
arp.addMapping("degree_points", "degree_id_id", DegreePoints.class);
arp.addMapping("dic", "id", Dic.class);
arp.addMapping("dic_define", "id", DicDefine.class);
arp.addMapping("discuss_upvote", "upvote_id", DiscussUpvote.class);
arp.addMapping("homework_file", "homework_file_id", HomeworkFile.class);
arp.addMapping("knowledge_tree", "knowledge_tree_id", KnowLedgeTree.class);
arp.addMapping("MSG_SESSION", "MSG_SESSION_ID", MsgSession.class);
arp.addMapping("org_site", "org_site_id", OrgSite.class);
arp.addMapping("points_inc_top100", "points_inc_id", PointsIncTop.class);
arp.addMapping("points_top100", "points_id", PointsTop.class);
arp.addMapping("q_answer", "q_answer_id", Qanswer.class);
arp.addMapping("questionnare", "questionnare_id", Questionnare.class);
arp.addMapping("re_activity", "re_activity_id", ReActivity.class);
arp.addMapping("RE_ACTIVITY_FILE", "RE_ACTIVITY_ID", ReActivityFile.class);
arp.addMapping("RE_ACTIVITY_MARK", "RE_ACTIVITY_MARK_ID", ReActivityMark.class);
arp.addMapping("RE_COMMENT", "RE_COMMENT_ID", ReComment.class);
arp.addMapping("re_member", "id", ReMember.class);
arp.addMapping("RE_MSG", "RE_MSG_ID", ReMsg.class);
arp.addMapping("R_LOG_RESOURCE", "LOG_RSC_ID", RLogResource.class);
arp.addMapping("r_log_rsc_count", "log_rsc_id", RLogRscCount.class);
arp.addMapping("R_LOG_TEACH_EXT", "TEACH_EXT_ID", RLogTeachExt.class);
arp.addMapping("room", "room_id", Room.class);
arp.addMapping("room_apply", "room_apply_id", RoomApply.class);
arp.addMapping("room_count", "room_id", RoomCount.class);
arp.addMapping("room_course", "room_course_id", RoomCourse.class);
arp.addMapping("room_file", "train_topic_resource_id", RoomFile.class);
arp.addMapping("room_homework", "room_homework_id", RoomHomework.class);
arp.addMapping("room_photo", "room_photo_id", RoomPhoto.class);
arp.addMapping("room_resource", "room_resource_id", RoomResource.class);
arp.addMapping("room_team", "team_id", RoomTeam.class);
arp.addMapping("room_user", "room_user_id", RoomUser.class);
arp.addMapping("room_user_course", "room_user_course_id", RoomUserCourse.class);
arp.addMapping("R_PHY_CRS_QU", "CRS_QU_ID", RPhyCrsQu.class);
arp.addMapping("R_PHY_RESOURCE", "PHY_RSC_ID", RPhyResource.class);
arp.addMapping("R_PHY_RSC_ATTR", "PHY_ATTR_ID", RPhyRscAttr.class);
arp.addMapping("RPT_USER_COURSE_TASK", "RPT_USER_COURSE_TASK_ID", RptCourse.class);
arp.addMapping("rpt_room", "id", RptRoom.class);
arp.addMapping("rpt_team", "rpt_team_id", RptTeam.class);
arp.addMapping("rpt_user_topic_task", "rpt_user_topic_task_id", RptTopic.class);
arp.addMapping("RPT_USER_PRACTICE_DETAIL", "RPT_USER_PRACTICE_DETAIL_ID", RptUserPracticeDetail.class);
arp.addMapping("rpt_user_topic", "rpt_user_topic_id", RptUserTopic.class);
arp.addMapping("R_RESOURCE", "R_RESOURCE_ID", RResource.class);
arp.addMapping("R_RESOURCE_RLAT", "RSC_RLAT_ID", RResourceRlat.class);
arp.addMapping("say_upvote", "upvote_id", SayUpvote.class);
arp.addMapping("school", "school_id", School.class);
arp.addMapping("section_subject", "section_subject_id", SectionSubject.class);
arp.addMapping("site_count", "site_room_count_id", SiteCount.class);
arp.addMapping("site_crouse", "site_crouse_id", SiteCrouse.class);
arp.addMapping("site_news", "site_news_id", SiteNews.class);
arp.addMapping("site_resource", "SPACE_RLAT_ID", SiteResource.class);
arp.addMapping("study_event", "study_event_id", StudyEvent.class);
arp.addMapping("STUDY_PROCESS", "STUDY_PROGRESS_ID", StudyProcess.class);
arp.addMapping("suggestion", "suggestion_id", Suggestion.class);
arp.addMapping("sys_notice", "sys_notice_id", SysNotice.class);
arp.addMapping("sys_notice_comment", "sys_notice_comment_id", SysNoticeComment.class);
arp.addMapping("sys_org", "org_id", SysOrg.class);
arp.addMapping("sys_user_officer", "user_officer_id", SysUserOfficer.class);
arp.addMapping("teach_textbook", "id", TeachBookText.class);
arp.addMapping("teach_category", "cate_id", TeachCategory.class);
arp.addMapping("TEACH_DESIGN", "TEACH_DESIGN_ID", TeachDesign.class);
arp.addMapping("TEACH_DESIGN_COMMENT", "TEACH_DESIGN_COMMENT_ID", TeachDesignComment.class);
arp.addMapping("TEACH_DESIGN_COMMENT_REPLY", "TEACH_DESIGN_COMMENT_REPLY_ID", TeachDesignCommentReply.class);
arp.addMapping("TEACH_DESIGN_FILE", "TEACH_DESIGN_FILE_ID", TeachDesignFile.class);
arp.addMapping("TEACH_DESIGN_REFLECTION", "TEACH_DESIGN_REFLECTION_ID", TeachDesignReflection.class);
arp.addMapping("teach_design_upvote", "teach_design_upvote_id", TeachDesignUpvote.class);
arp.addMapping("TEACH_DETAIL", "TEACH_DETAIL_ID", TeachDetail.class);
arp.addMapping("teach_knowledge", "id", TeachKnowledge.class);
arp.addMapping("teach_model_tree", "teach_id", TeachModelTree.class);
arp.addMapping("teach_rela_tree", "id", TeachRelaTree.class);
arp.addMapping("teach_section", "id", TeachSection.class);
arp.addMapping("TEACH_STEP", "TEACH_STEP_ID", TeachStep.class);
arp.addMapping("TEACH_STEP_FILE", "TEACH_STEP_FILE_ID", TeachStepFile.class);
arp.addMapping("teach_subject", "id", TeachSubject.class);
arp.addMapping("t_ioid_sequence", TioidSequence.class);
arp.addMapping("train_discuss", "train_discuss_id", TrainDiscuss.class);
arp.addMapping("TRAIN_PLAN", "TRAIN_PLAN_ID", TrainPlan.class);
arp.addMapping("TRAIN_PLAN_ATTR", "TRAIN_PLAN_ATTR_ID", TrainPlanAttr.class);
arp.addMapping("train_plan_inst", "train_plan_inst_id", TrainPlanInst.class);
arp.addMapping("train_plan_inst_attr", "train_plan_inst_attr_id", TrainPlanInstAttr.class);
arp.addMapping("train_topic", "train_topic_id", TrainTopic.class);
arp.addMapping("train_topic_step", "train_topic_step_id", TrainTopicStep.class);
arp.addMapping("u_fans", "u_fans_id", UFans.class);
arp.addMapping("u_friend", "u_friend_id", UFriend.class);
arp.addMapping("u_friend_apply", "friend_apply_id", UFriendApply.class);
arp.addMapping("u_login_user", "user_id", ULoginUser.class);
arp.addMapping("user_blog", "user_blog_id", UserBlog.class);
arp.addMapping("user_blog_reply", "user_blog_reply_id", UserBlogReply.class);
arp.addMapping("user_event", "user_event_id", UserEvent.class);
arp.addMapping("user_file", "user_file_id", UserFile.class);
arp.addMapping("user_folder", "user_folder_id", UserFolder.class);
arp.addMapping("user_homework", "user_homework_id", UserHomework.class);
arp.addMapping("user_homework_comment", "user_homework_comment_id", UserHomeworkComment.class);
arp.addMapping("user_level", "user_id", UserLevel.class);
arp.addMapping("USER_MSG", "MSG_ID", UserMsg.class);
arp.addMapping("user_points_his", "point_his_id", UserPointsHis.class);
arp.addMapping("user_say", "user_say_id", UserSay.class);
arp.addMapping("user_say_reply", "say_reply_id", UserSayReply.class);
arp.addMapping("user_suggest", "user_suggest_id", UserSuggest.class);
arp.addMapping("u_user_info", "user_id", UUserInfo.class);
arp.addMapping("zone", "zone_id", Zone.class);
arp.addMapping("zone_visitor", "zone_visitor_id", ZoneVisitor.class);

// (DbKit.MAIN_CONFIG_NAME, dataSourceProvider); 

// 配置数据库连接池插件
Prop p1 = PropKit.use("jdbc.properties");
DruidPlugin bdruidPlugin = new DruidPlugin(p1.get("a.jdbc.url"), p1.get("a.jdbc.user"), p1.get("a.jdbc.password"));
bdruidPlugin.addFilter(new StatFilter());
me.add(bdruidPlugin);

ActiveRecordPlugin  arp1 =  new ActiveRecordPlugin("76Data",bdruidPlugin);
arp1.setShowSql(true);
arp1.setContainerFactory(new CaseInsensitiveContainerFactory(true));   //设置大小写不敏感
arp1.addMapping("train_discuss_reply", "train_discuss_reply_id", TrainDiscussReply.class);





//加载EhCache插件
me.add(new EhCachePlugin());

//sql日志
SqlReporter.setLogger(true);

}
启动的时候报错   2016 5:52:19 下午 org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter jfinal
java.lang.NullPointerException
at com.jfinal.plugin.activerecord.Model.find(Model.java:529)
at com.jfinal.plugin.activerecord.Model.find(Model.java:546)
at com.zl.model.TeachKnowledge.loadKnowledgeCache(TeachKnowledge.java:23)
at com.zl.pub.cache.TeachRecourseCache.loadCache(TeachRecourseCache.java:22)
at com.zl.jfinal.GlobalConfig.afterJFinalStart(GlobalConfig.java:303)


提示操作model的时候  空指针 什么原因??

加载中
0
JFinal
JFinal

   arp 与 arp1 这两个对象并没有添加到 Plugins 对象中去,所以相当于没有初始化插件,需要添加如下两行:

me.add(arp);
me.add(arp1);

    此外,jfinal 2.2 可以接管所有的 arp.addMapping(...)这样的工作,不需要手动写这么多的样板代码,建议升级

返回顶部
顶部