开发异常记录

上面的错误出现在socket通信使用bufferwriter的时候出现的,原因是因为使用bufferwriter的时候需要时用flush();清空缓冲区。下面是解决方法:

 

解决方法是在shutdown上面一行加入writer.flush();

java.lang.ClassCastException

是指类型转换出错

当前者的域小于后者的时候出现

譬如说:前者A是子类的对象,而后者B是父类的对象

若使用A = B;就会抛出java.lang.ClassCastException

 

一、

Caused by:java.lang.SecurityException: Prohibited package name: java.mypackage  

这句话的意思大概为不能以包含Java为开头的包名

 

二、

org.hibernate.exception.JDBCConnectionException: Cannot open connection

Caused by: java.sql.SQLRecoverableException: IO 错误: The Network Adapter could not establish the connection

错误原因是因为数据库服务没有开启

 

三、

Exception in thread "main" java.lang.IllegalArgumentException: Unknown entity: java.lang.Integer

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

 明显可以看出,Hibernate是通过删除对象的方式来删除的,简单的传入一个属性,就会报以上异常。

因此需要将属性set到实体对象中,然后通过在delete()方法中传入实体对象即可实现删除。

 

四、

Exception in thread "main" org.hibernate.HibernateException: save is not valid without active transaction

是因为操作的时候没有开启事务1

 

五、

Exception in thread "main" org.hibernate.TypeMismatchException: Provided id of the wrong type for class com.oracle.webservices.entity.Studententiry.

Expected: class java.lang.Long, got class java.lang.Integer

错误原因是因为需要long长整型的数字,而不是integer类型的数。

 

六、

Java.lang.StackOverflowError异常。

StackOverflowError是由于当前线程的栈满了  ,也就是函数调用层级过多导致。

 

七、

The method load(Class, Serializable) in the type Session is not applicable for the arguments (Class<

发现这应该是hibernate版本的问题,在hibernate中的操作,要看你引用的hibernate版本本身是否支持自动拆装。或者是jdk版本过低

Serializable接口是integer等基本类型包装类的父接口

 

八、

WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement

解决方法:把hibernate.hbm2ddl.auto注释掉,把其值改为create或none也可以

将hibernate.cfg.xml中的这行注释 <!--<property name="hbm2ddl.auto">create</property>-->

 

九、

No CurrentSessionContext configured!" 异常解决方案

hibernate 没有配方言

<property name="current_session_context_class">thread</property>

 

十、

Exception in thread "main" java.lang.ExceptionInInitializerError

at Test1.main(Test1.java:13)

Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :

com/hpit/web/entity/Users.hbm.xml : origin(com/hpit/web/entity/Users.hbm.xml)

原因是idea自动生成的hibernate.xml.xml文件找不到实体类映射文件:

解决方法:

Maven 项目不打包 *.hbm.xml 映射文件

  使用 Maven 部署 Java Web 项目时,Hibernate 的映射文件 *.hbm.xml 没有被打包部署到目标目录下,

第一种解决方法:在 pom.xml 文件中 <build> 节点下添加以下代码:

 <build>

 <!--

    配置文件在pojo中需要再次添加这些文件

    <resources>

      <resource>

        <directory>src/main/java</directory>

        <includes>

          <include>com/zxlc/pojo/Student.hbm.xml</include>

        </includes>

        <filtering>true</filtering>

      </resource>

      <resource>

        <directory>src/main/java</directory>

        <includes>

          <include>com/zxlc/pojo/Users.hbm.xml</include>

        </includes>

      </resource>

      <resource>

        <directory>src/main/resources</directory>

        <includes>

          <include>hibernate.cfg.xml</include>

        </includes>

      </resource>

    </resources>-->

 </build>

第二种方法: 或者:将 *.hbm.xml 映射文件放到 src/main/resources 文件夹下:

 

 

十一、

org.hibernate.PropertyValueException: not-null property references a null or transient value: com.zyl.po.Card.cardnum

提示很明显,非空的值关联了一个空值或无效的值,就是你数据库里面某个字段设置为非空了,但是传过去的是个空值,仔细检查一下

 

十二、

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException:

Cannot find class [org.apache.commons.dbcp2.BasicDataSource]

for bean with name 'dataSource' defined in class path resource [applicationContext.xml];

nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp2.BasicDataSource

Caused by: java.lang.ClassNotFoundException: org.apache.commons.dbcp2.BasicDataSource

出现这种情况主要是因为缺少相应的jar包或者maven方式的依赖,例如上面就缺少DBCP的依赖包。

 

 

十三、

 

java.lang.ExceptionInInitializerError

 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: com.chen.web.services [Xlint:invalidAbsoluteTypeName]

 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: com.chen.web.services [Xlint:invalidAbsoluteTypeName]

 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: com.chen.web.services [Xlint:invalidAbsoluteTypeName]

 

Caused by: java.lang.IllegalArgumentException: warning no match for this type name: com.chen.web.services [Xlint:invalidAbsoluteTypeName]

 

 错误原因:

 <aop:config proxy-target-class="true">

        <aop:pointcut id="serviceMethod" expression="execution(* com.chen.web.services.*.*(..))" />

        <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod" />

    </aop:config>

expression="execution(* com.chen.web.services.*.*(..))"这后面必须有连个*号,必须这样写。

 

十四、

22-Apr-2017 15:22:27.335 严重 [RMI TCP Connection(3)-127.0.0.1]

org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file

22-Apr-2017 15:22:27.337 严重 [RMI TCP Connection(3)-127.0.0.1]

org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors

  <!-- 服务器启动时,通过监听器初始化Spring的配置环境监听器,默认加载文件是:/WEB-INF/applicationContext.xml -->

    <listener>

        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

    </listener>

主要原因是因为服务器启动时,通过监听器初始化Spring的配置环境监听器,默认加载文件是:/WEB-INF/applicationContext.xml但是

web-info下有没有文件造成的。

 

 

十五、

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

 

Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

 如何有applicationContext.xml文件的话,那可能是存放改文件的目录没有标记成resources root。

 

十六、

java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Users is not mapped [from Users]

 

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Users is not mapped [from Users]

 

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Users is not mapped

错误原因是因为缺少实体类映射文件

 

 

十七、

org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread

错误原因是因为配置事务以后没有在service层的实现类上配置@Transactional注解(只要不是接口的其他类都可以)

 

 

十八、!!!!!!!!!!!!!

java.lang.NullPointerException

at com.chen.web.action.StrutsAction.first(StrutsAction.java:69)

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:498)

这个是空指针异常,但是在这里是因为,整合struts2和spring没有导入struts2-spring-plugin的依赖包。

 

十九、

24-Apr-2017 19:03:09.318 警告 [RMI TCP Connection(28)-127.0.0.1]

 org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver

 [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak,

 the JDBC Driver has been forcibly unregistered.

意思是: 一个web应用程序注册的JBDC驱动程序[com.mysql.jdbc.Driver],但Web应用程序时停止时未能注销。为了防止内存泄漏,

JDBC驱动程序已被强行注册。

主要发生在Tomcat重启,是jdbc没有正确处理驱动注销。

 

 

二十、

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'org.hibernate.SessionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'org.hibernate.SessionFactory': no matching editors or conversion strategy found

at org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:74)

at org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:54)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1090)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)

... 42 more

Caused by: java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'org.hibernate.SessionFactory': no matching editors or conversion strategy found

at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:306)

at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:125)

at org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:61)

... 46 more

主要原因是因为给sessionfactory赋值的字符串类型的值。

   @Value("sessionFactory")错误错误!!!!!!!!!!!!!!!!

    private SessionFactory sessionFactory;

 

二十一、

严重: Application exception overridden by rollback exception

java.lang.IllegalStateException: Already value [org.springframework.orm.hibernate5.SessionHolder@4ce94d2f] for key [org.hibernate.internal.SessionFactoryImpl@4745e9c] bound to thread [main]

 

java.lang.IllegalStateException: No value for key [org.hibernate.internal.SessionFactoryImpl@4745e9c] bound to thread [main]

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">

配置sessionfactory和事务管理的时候hibernate的版本必须一样,不能是4和5两个版本。经过测试4也不行,必须是5.

 

二十二、

异常信息:org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException;

Spring缺少aspectjweaver.jar异常

解决方法:<!--spring AOP就是用aspectj来实现的,是依赖关系!AspectJ是动态代理的一种实现!springaop依赖-->

        <dependency>

            <groupId>org.aspectj</groupId>

            <artifactId>aspectjweaver</artifactId>

            <version>1.8.9</version>

        </dependency>

 

二十三、

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

如果控制台输出这句话是需要导入log4j-core包。

 <dependency>

 <groupId>org.apache.logging.log4j</groupId>

 <artifactId>log4j-core</artifactId>

 <version>2.7</version>

</dependency>

 

二十四、

出现should be mapped with insert="false" update="false"的解决方法

一个问题的出现,往往是由于某些原因导致的,从源头找起。这个问题主要是由于建立多对一关系映射的时候出现两个重复的定义。

比如hibernate中:

<property name="schedule_id"/>

<many-to-one name="schedule" column="schedule_id"/>

如果真的能够在数据库生成的话,那么数据库将出现两个schedule_id的错误,那肯定个是不行了

解决方式:去掉其中一个,合理的做法,去掉上面那个定义。

 

二十五、

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext.xml]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'newsComment' for bean class [com.chen.web.pojo.NewsComment] conflicts with existing, non-compatible bean definition of same name and class [com.chen.web.dao.impl.NewsCommentDao]

 

Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException:

Annotation-specified bean name 'newsComment' for bean class [com.chen.web.pojo.NewsComment] conflicts with existing,

non-compatible bean definition of same name and class [com.chen.web.dao.impl.NewsCommentDao]

这种错误是因为在实体类上加了一个@commpent注解将实体类实例化,好像不能在实体类上加注解

 

二十六、

Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 78 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 78; columnNumber: 85; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'tx:advice' 的声明。

出错原因是在applicationContext.xml中配置tx的事务文件声明错了。

http://www.springframework.org/schema/context

       http://www.springframework.org/schema/context/spring-context.xsd

   应该是:

     http://www.springframework.org/schema/tx

       http://www.springframework.org/schema/tx/spring-tx.xsd

 

二十七、2017年5月8日

   org.springframework.beans.factory.BeanDefinitionStoreException:

   Failed to read candidate component class: file [D:\untitled1\out\artifacts\web_war_exploded\WEB-INF\classes\com\kgc\ssm\qqzone\biz\HostReplyService.class];

   nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\untitled1\out\artifacts\web_war_exploded\WEB-INF\classes\com\kgc\ssm\qqzone\biz\HostReplyService.class]; nested exception is java.lang.IllegalArgumentException

   错误原因是因为jdk是1.8,而spring的版本过低造成的。。。。。。。!!!!!!!!!!1

 

eclipse错误

二十八、

出现 The processing instruction target matching "[xX][mM][lL]" is not allowed错误

 

这个错误的原因是因为xml的开始有多余的空格造成的,只要把多余的空格删除就没有问题了

 

二十九

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

三十,org.csource.common.MyException: getStoreStorage fail, errno code: 2

错误原因是因为多次启动. fastDFS.sh 导致80端口被占用。办法重启虚拟机

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值