我怎么注册不进去
public void save(UserInfo transientInstance) {
int result=0;
log.debug("saving UserInfo instance");
try {
getSession().beginTransaction().commit();
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
result=1;
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
System.out.println(result);
}<!-- 事务管理 -->
<bean id="transaction"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:advice id="advice" transaction-manager="transaction">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="find*" propagation="REQUIRED" />
<tx:method name="*" propagation="SUPPORTS" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="cut"
expression="execution(* com.crm.biz.Impl.*.*(..))" />
<aop:advisor advice-ref="advice" pointcut-ref="cut" />
</aop:config>

/** 
 * Method add
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 */
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm) form;
UserInfo userInfo=new UserInfo();
userInfo.setUserName(userForm.getUserName());
userInfo.setUserPass(userForm.getUserPass());
userBizImpl.add(userInfo);
return mapping.findForward("success"); }

解决方案 »

  1.   


    getSession().beginTransaction().commit();你这先提交再保存能注册吗?肯定不行了。
      

  2.   

    原因是L上说的。
    这种就不用这么配了吧:         <tx:method name="find*" propagation="REQUIRED" />
    <tx:method name="find*" propagation="SUPPORTS" />
      

  3.   

    try {
       getSession().beginTransaction();//开启session
       getHibernateTemplate().save(transientInstance);//保存对象
       getSession().beginTransaction().commit()//提交.
       log.debug("save successful");
       result=1;
    } catch (RuntimeException re) {
       getSession().beginTransaction().rollback();//出现异常就回滚.
       log.error("save failed", re);
       throw re;
    }
      

  4.   

                getSession().beginTransaction().commit();
                getHibernateTemplate().save(transientInstance);
    提交之后在save,没见过这种写法,呵呵
      

  5.   

    我给 你们吧错误打出来看看org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/user' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [com.biz.impl.UserBizImpl] for property 'userBizImpl'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.biz.impl.UserBizImpl] for property 'userBizImpl': no matching editors or conversion strategy found
    Caused by: 
    org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
    PropertyAccessException 1:
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [com.biz.impl.UserBizImpl] for property 'userBizImpl'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.biz.impl.UserBizImpl] for property 'userBizImpl': no matching editors or conversion strategy found
    Caused by: 
    java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.biz.impl.UserBizImpl] for property 'userBizImpl': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:815)
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    at org.springframework.web.struts.ContextLoaderPlugIn.createWebApplicationContext(ContextLoaderPlugIn.java:354)
    at org.springframework.web.struts.ContextLoaderPlugIn.initWebApplicationContext(ContextLoaderPlugIn.java:295)
    at org.springframework.web.struts.ContextLoaderPlugIn.init(ContextLoaderPlugIn.java:225)
    at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:869)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:451)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    2009-7-28 14:31:56 org.apache.catalina.core.ApplicationContext log
    严重: action: null
      

  6.   

    你看看这一句:
    Cannot convert value of type [$Proxy1] to required type [com.biz.impl.UserBizImpl] for property 'userBizImpl': no matching editors or conversion strategy found
    对象类型转换有误!
      

  7.   

    java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.biz.impl.UserBizImpl] 注入错误,比如你有个bean1 ,结果你给注入了bean2,检查一下吧
      

  8.   


    我就写了 一个action类,没其他的bean了,在没aop前都是好的
      

  9.   

    java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.biz.impl.UserBizImpl] for property 'userBizImpl': no matching editors or conversion strategy found
    com.biz.impl.UserBizImpl 配置文件中的这个类的userBizImpl属性给的值是无效的。
      

  10.   

    <aop:config proxy-target-class="true">
    <aop:pointcut id="cut"
    expression="execution(* com.hahafan.biz.impl.*.*(..))" />
    <aop:advisor advice-ref="advice" pointcut-ref="cut" />
    </aop:config>
    这样一加就好了