• 发现的问题


    在做项目的时候出现了这个异常:ognl.NoSuchPropertyException

    java.lang.IllegalAccessException: Class ognl.OgnlRuntime can not access a member of

    引起这种原因就是属性名称的不规范!!比如 "nTitle"、“pID”这样的属性名生成set和get方法是不规范的!

    虽然代码没错,但是就会出现这个异常;

    关于ssh中的问题:当我们在po层有集合属性时,我们应该显示的初始化集合属性,否则程序运行时会抛出空指针异常,

    这个异常与hibernate无关,当程序对该集合属性添加属性时,如果没有初始化就会引发空指针异常。

    org.hibernate.MappingException: Could not determine type for.......

    hibernate集成在spring文件中,
    在属性及get方法上都可以注解,结果hibernate默认只读属性上的注解,忽略 get方法上的注解,

    所以特别是在一对多,一对一关系,多对多关系映射时,虽然在get方法上做了配置,但hibernate没有读取该注解,

    才报 Could not determine type XXXx的错误;到底怎么在get方法上配置才有效,自己百度去吧。

    org.hibernate.MappingException: Unknown entity: java.lang.Integer

    今天发现自己写的hibernate中出现这个异常;其实是session.delete()中的参数是个对象;

    而我传的是个ID int型的;


    八月 22, 2014 8:30:09 下午 org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userAction' defined in file [D:.metadata.pluginsorg.eclipse.wst.server.core mp0wtpwebappsszwprojWEB-INFclassescomactionUserAction.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.action.UserAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1007)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
        at org.apache.catalina.core.StandardService.start(StandardService.java:525)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.action.UserAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1000)
        ... 28 more
    Caused by: java.lang.NullPointerException
        at org.apache.struts2.ServletActionContext.getRequest(ServletActionContext.java:112)
        at com.action.UserAction.<init>(UserAction.java:33)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
        ... 30 more

    一直出这个错误是因为UserAction中有private HttpSession session = ServletActionContext.getRequest().getSession();

  • 相关阅读:
    Eclipse SVN忽略某些文件或文件夹方法
    在ORACLE中给已有数据的表增加、修改、删除一个字段(或一个列)或者多个字段(或多个列)的问题
    Java中IO流,输入输出流概述与总结
    Java面向对象之继承
    jquery-each()
    window.showModalDialog以及window.open用法简介
    struts1、ajax、jquery、json简单实例
    软件人才管理
    疑难杂症定位记录
    linux中断子系统
  • 原文地址:https://www.cnblogs.com/yzdqxing/p/3913241.html
Copyright © 2020-2023  润新知