Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Architecture & Framework » Spring Framework  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请教Spring错误问题
Platformer





发贴: 5
积分: 0
于 2006-05-22 09:57 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
这是我写的测试代码:
package com.towset.sshdlib.util;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.towset.sshdlib.business.IEleBookService;
import com.towset.sshdlib.business.service.EleBookImp;
import com.towset.sshdlib.business.IBookMarkService;
import com.towset.sshdlib.business.service.BookMarkImp;
import com.towset.sshdlib.business.IBorrowInfoService;
import com.towset.sshdlib.business.service.BorrowInfoImp;

import com.towset.sshdlib.model.BookConern;
import com.towset.sshdlib.model.BookMark;
import com.towset.sshdlib.model.BorrowBookInfo;
import com.towset.sshdlib.model.ElectionBook;
import com.towset.sshdlib.model.UserInfo;

public class Test {
IEleBookService service;
  EleBookImp ebi;
//  IBookMarkService ibmark;
//  BookMarkImp bmark;
//  IBorrowInfoService ibinfo;
//  BorrowInfoImp binfo;
  
  ElectionBook eb = new ElectionBook();
  BookConern bc = new BookConern();
  UserInfo ui=new UserInfo();
  BookMark bm=new BookMark();
  BorrowBookInfo bbi=new BorrowBookInfo();
  
  
  public void save(){
    ApplicationContext context =
     new ClassPathXmlApplicationContext(new String[]{"daoBean.xml","serviceBean.xml"});    
    
//    ApplicationContext context=
//      new ClassPathXmlApplicationContext("bean.xml");
    
//    ebi=(EleBookImp)context.getBean("ieleBookService");
    
    service=(IEleBookService)context.getBean("ieleBookService");
    
    
//    Session se = HibernateUtil.currentSession();
//    Transaction tx = se.beginTransaction();
    
    bc.setCname("renyou");
    bc.setCisbn("345");
    bc.setCtel("1357");
    bc.setCaddress("shanghai");
    bc.setCremark("haode");
    
   eb.setEthesis("zero");
    eb.setEresponsible("wang");
   eb.setEisbn("12423");
    eb.setEurl("d:/TowSet");
   eb.setEsort("kexue");
    eb.setEclegree(2);
    eb.setEremark("chenggong");
    eb.setBconern(bc);
    
    System.out.println("bao");
//    se.save(eb);
//    tx.commit();
//    HibernateUtil.closeSession();
      
//    ebi.createObject(eb);
    service.createObject(eb);
  }
  
  public ElectionBook getEleBookByIsbn(Long isbn){
    ApplicationContext context= new ClassPathXmlApplicationContext(new String[]{"daoBean.xml","serviceBean.xml"});
    ebi=(EleBookImp)context.getBean("eleBookService");
    return eb=ebi.findById(isbn);
  }
  
  public void deleteElebook(String isbn){
    ApplicationContext context= new ClassPathXmlApplicationContext(new String[]{"daoBean.xml","serviceBean.xml"});
    ebi=(EleBookImp)context.getBean("eleBookService");
    ebi.deleteObject(isbn);
  }
  
  public static void main(String[] args) {
    // TODO 自动生成方法存根
    Test te = new Test();
    te.save();

  }

}
----------------------------------------------提示以下错误信息------------------------------
[web] WARN [main] Configurator.configure(126) | No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/SSHdlib1/WebRoot/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
bao
Exception in thread "main" java.lang.NullPointerException
  at com.towset.sshdlib.business.service.BaseService.createObject(BaseService.java:22)
  at com.towset.sshdlib.business.service.BaseService$$FastClassByCGLIB$$f6752a3d.invoke(<generated>Wink
  at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
  at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:698)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
  at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
  at com.towset.sshdlib.business.service.EleBookImp$$EnhancerByCGLIB$$acc686d5.createObject(<generated>Wink
  at com.towset.sshdlib.util.Test.save(Test.java:72)
  at com.towset.sshdlib.util.Test.main(Test.java:90)
我找了好长时间但还是找不到,希望各位大大帮帮小弟!~




请求JAVA学习方向?????

话题树型展开
人气 标题 作者 字数 发贴时间
12544 请教Spring错误问题 Platformer 4237 2006-05-22 09:57
11620 Re:请教Spring错误问题 Davis129 100 2006-05-30 10:50

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923