遇到最常见的问题:

JAVA web项目中的no result defined for action result input

错误
产生这个错误的原因:Action中的属性值为空的时候,Struts2的默认拦截器会报错,但是又找不到input的Result,不能够把错误返回,所以报这种错误。
1、validate方法没有通过(表单验证看看有没有重名,导致js文件加载过慢);
2、页面元素中有重命名时,但后台action类的对应的接收此同名参数的是变量而没有写成数组
3、配置文件中result 返回.jsp出现错误(多了空格、或者没有界面)
4、对应Action中没有返回值,或者返回值出错

1.MyEclipse报错:Multiple markers at this line - The type java.io.ObjectInputStream cannot be resolved.

1.出错原因
网上查了以后,说是因为JDK版本太高的问题
2.修改
window->preference->Java->Installed JREs->选择低版本的JDK->ok
ps:这里由于我只装了JDK1.8,所以选择可以MyEclipse自己的JDK(即Sun JDK 1.6.0_13)

SSH项目报错解决办法-LMLPHP

2.eclipse,myeclipse导入工程报:javax.servlet.jsp.JspException cannot be resolved to a type
3.Eclipse中报错The type javax.servlet.http.HttpServletResponse cannot be resolved
2和3解决办法:
1.在工程中添加jsp-api.jar包,tomcat的安装目录中就有
右击项目—》Build Path ----》Configure Build Path ,点击Java Build Path,选中右侧Libraries,点击Add External JARs选择tomcat安装目录下的jsp-api.jar包
2.右键项目Properties-------->Targeted Runtimes 把Tomcat勾上

4.Multiple annotations found at this line: 解决办法 Multiple annotations found at this line: - schema_reference.4: Failed to read schema document ‘http://www.springframework.org/schema/beans/ spring-beans-3.1.xsd’, because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . - cvc-elt.1: Cannot find the declaration of element ‘beans’.

如上,在使用eclipse构建基于maven的springmvc 工程时,报上面的错误

如下为spring的配置:
SSH项目报错解决办法-LMLPHP
SSH项目报错解决办法-LMLPHP

如果版本没有错的话,把约束剪切然后重新粘贴,Ctrl+S,就OK啦

5.org.springframework.dao.InvalidDataAccessApiUsageException问题解决与分析

<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- 配置事务通知属性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <!-- 定义事务传播属性 -->
    <tx:attributes>
        <!-- 增 -->
        <tx:method name="insert*" propagation="REQUIRED" />
        <tx:method name="save*" propagation="REQUIRED" />
        <tx:method name="add*" propagation="REQUIRED" />
        <tx:method name="new*" propagation="REQUIRED" />
        <tx:method name="create*" propagation="REQUIRED" />
        <!-- 删 -->
        <tx:method name="remove*" propagation="REQUIRED" />
        <tx:method name="delete*" propagation="REQUIRED" />
        <!-- 改 -->
        <tx:method name="update*" propagation="REQUIRED" />
        <tx:method name="edit*" propagation="REQUIRED" />
        <tx:method name="set*" propagation="REQUIRED" />
        <tx:method name="change*" propagation="REQUIRED" />
        <!-- 查 -->
        <tx:method name="get*" propagation="REQUIRED" read-only="true" />
        <tx:method name="find*" propagation="REQUIRED" read-only="true" />
        <tx:method name="load*" propagation="REQUIRED" read-only="true" />
        <tx:method name="*" propagation="REQUIRED" read-only="true" />
    </tx:attributes>
</tx:advice>


<!-- 配置事务切面 -->
<aop:config>
    <aop:pointcut id="serviceOperation"
        expression="execution(* cn.jkstudio.*.service.*.*.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
</aop:config>

好好看事务的配置有没有错,如果能确定没有错,一般是配置事务切面的地方对包路径写的有问题:
检查expression=“execution(* cn.jkstudio..service...(…))”
第一个 * 表示方法返回值类型可以为任意类型
第二个 * 表示cn.jkstudio包下面的任意包
第三个 * 表示service包下面的任意包
第四个 * 表示service.任意包 下面的任意一个类
第五个 * 表示service.任意包.任意类下面的任意一个方法
后面小括号里面的两个 … 表示该方法可以有0个或多个参数

6.org.apache.jasper.JasperException…(line:XX, column: XX) quote symbol expected和处理办法

quote symbol就是引号

放大你的眼睛,看看控制台输出的行数,找到JSP页面,好好检查@@@@!!@!!!!!!!!!@@@@

7.ssh框架org.springframework.dao.InvalidDataAccessApiUsageException错误

在使用ssh框架做用户的保存的时候调用了save方法,发生上面的错误;
原因是在service中没有加入事务注解;可以再applicationContext.xml中进行对事务的配置:如下

<tx:annotation-driven transaction-manager=“transactionManager”/>
在service中加入注解:@Transactional可以在方法上加也可以在类上面加。

8.解决Spring4+Hibernate4遇到的 Write operations are not allowed in read-only mode (FlushMode.MANUAL)

https://blog.csdn.net/sozdream/article/details/39233209

一些测试方法:
Dao:
public class TestDao {

/** 保存 */
@Test
public void save() {
	ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
	IElecTextDao elecTextDao = (IElecTextDao) ac.getBean("");
	ElecText elecText = new ElecText();
	elecText.setTextName("测试Dao名称");
	elecText.setTextDate(new Date());
	elecText.setTextRemark("测试Dao备注");
	elecTextDao.save(elecText);
}

/** 更新 */
@Test
public void update() {
	ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
	IElecTextDao elecTextDao = (IElecTextDao) ac.getBean("");
	ElecText elecText = new ElecText();
	elecText.setTextID("402881e442599916014259991c450001");
	elecText.setTextName("更新名称");
	elecText.setTextDate(new Date());
	elecText.setTextRemark("更新备注");
	elecTextDao.update(elecText);
}

/** 使用主键ID查询对象 */
@Test
public void findObjectById() {
	ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
	IElecTextDao elecTextDao = (IElecTextDao) ac.getBean("");
	Serializable id = "402881e4425a729301425a734c2a0001";
	ElecText elecText = elecTextDao.findObjectByID(id);
	System.out.println(elecText.getTextName() + "    "
			+ elecText.getTextDate() + "    " + elecText.getTextRemark());
}

/** 删除(使用1个主键ID和多个主键ID的数组) */
@Test
public void deleteObjectByIDs() {
	ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
	IElecTextDao elecTextDao = (IElecTextDao) ac.getBean("");
	// Serializable [] ids =
	// {"402881e442599916014259991c450001","402881e44259d1c0014259d1c48b0001"};
	Serializable ids = "402881e44259de3a014259de40e40001";
	elecTextDao.deleteBojectByIDs(ids);
}

/** 删除(将对象封装成集合,使用集合删除集合中存放的所有对象) */
@Test
public void deleteObjectByCollection() {
	ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
	IElecTextDao elecTextDao = (IElecTextDao) ac.getBean("");
	List<ElecText> list = new ArrayList<ElecText>();
	ElecText elecText1 = new ElecText();
	elecText1.setTextID("402881e44259dfc5014259dfcaa10001");
	ElecText elecText2 = new ElecText();
	elecText2.setTextID("402881e44259e338014259e36de70001");
	list.add(elecText1);
	list.add(elecText2);
	elecTextDao.deleteObjectByCollection(list);
}

}
Service:
public class TestService {

/** 保存 */
@Test
public void save() {
	ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
	IElecTextService elecTextService = (IElecTextService) ac.getBean("");
	ElecText elecText = new ElecText();
	elecText.setTextName("测试Service名称");
	elecText.setTextDate(new Date());
	elecText.setTextRemark("测试Service备注");
	elecTextService.save(elecText);
}

}
二级缓存:
public class TestHibernateCache {

/**测试类级别的二级缓存*/
@Test
public void testClassCache(){
	Configuration configuration = new Configuration();
	//默认加载类路径下的hibernate.cfg.xml,同时加载映射文件
	configuration.configure();
	SessionFactory sf = configuration.buildSessionFactory();

	Session s = sf.openSession();
	Transaction tr = s.beginTransaction();

	ElecSystemDDL ddl1 = (ElecSystemDDL)s.get(ElecSystemDDL.class, 15);//存在

	ElecSystemDDL ddl2 = (ElecSystemDDL)s.get(ElecSystemDDL.class, 15);//没有,从Session的一级缓存中

	tr.commit();
	s.close();
	/*******************************************/
	s = sf.openSession();
	tr = s.beginTransaction();

	ElecSystemDDL ddl3 = (ElecSystemDDL)s.get(ElecSystemDDL.class, 15);//没有,从SessionFactory的二级缓存中,存放的散装数据

	tr.commit();
	s.close();

}

/**测试查询级别的二级缓存*/
@Test
public void testQueryCache(){
	Configuration configuration = new Configuration();
	//默认加载类路径下的hibernate.cfg.xml,同时加载映射文件
	configuration.configure();
	SessionFactory sf = configuration.buildSessionFactory();

	Session s = sf.openSession();
	Transaction tr = s.beginTransaction();

	Query query1 = s.createQuery("from ElecSystemDDL o where o.keyword = '性别'");
	query1.setCacheable(true);
	query1.list();//产生select语句

	tr.commit();
	s.close();
	/*******************************************/
	s = sf.openSession();
	tr = s.beginTransaction();

	Query query2 = s.createQuery("from ElecSystemDDL o where o.keyword = '性别'");
	query2.setCacheable(true);
	query2.list();//产生select语句

	tr.commit();
	s.close();

}

}

JBPM
public class TestHibernateJbpm {

/**
 * 生成JBPM的18张表
 * <property name="hibernate.hbm2ddl.auto">update</property>
 * */
@Test
public void createJbpm(){
	ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
	SessionFactory sf = (SessionFactory) ac.getBean("sessionFactory");
	System.out.println("SessionFactory:"+sf);
}

/**测试流程引擎对象*/
@Test
public void testProcessEngine(){
	ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
	ProcessEngine processEngine = (ProcessEngine)ac.getBean("processEngine");
	System.out.println("PorcessEngine:"+processEngine);
}

}

$%7BpageContext.request.contextPath%7D

https://stackoverflow.com/questions/43302380/http-status-404-7bpagecontext-request-contextpath1237d-ckfinder-ckfinder-ht

9.Unable to create requested service [org.hibernate.engine.spi.CacheImple 在使用Hibernate4做二级缓存的测试(HashtableCacheProvider)时,会报如下异常: 1.

SSH项目报错解决办法-LMLPHP

2.在org.hibernate.cache包下面缺少很多class文件,如HashtableCacheProvider.class等,你可以将hibernate3中org.hibernate.cache下面的文件拷贝到hibernate4的核心jar包下,或者使用Hibernate3的核心jar包。

10.Exception in thread “main” java.lang.Error: Unresolved compilation problems 解决方案

找了很久,终于找到原因了,下了个commons jar包, 然后按如下步骤:在Package Explore内 对应的工程上 单击右键;弹出右键菜单上单击“Build Path->Configure Build Path”,在弹出的对话框上 单击“Libararies->add External JARS” 选择上你的jar包所在位置就可以了

11.org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Table ‘XXX’ doesn’t exist

在项目的hibernate.cfg.xml中,我配置好xml后让hibernate自动在mysql建表
update
  可是,运行的时候报错“org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Table ‘XXX’ doesn’t exist”。可见,hibernate并没有帮我们自动创建数据库表文件。于是我手动在数据库中创建表,然后在跑一次程序,果然没有问题了。
  
  原因分析:
  数据库方言配置出现问题了,我们需要配置更高版本的数据库方言,具体如下:
hibernate-5.0.7中使用的方言

<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

Hibernate-5.2.10 使用的方言需要升级
  解决办法:
  在hibernate.cfg.xml中配置 SQL dialect方言。支持mysql高版本的建表。将

<!--<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>-->
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>

这样,hibernate就可以自动来创建数据库表了。

12.omcat在 myeclipse中第一次启动时报错:Address already in use: JVM_Bind:80804

问题:刚安装的tomcat在 myeclipse中第一次启动时报错:Address already in use: JVM_Bind:8080
原因:tomcat已经在使用,后来发现已经在控制面板=》管理工具=》服务中启动了tomcat的服务,关闭后就可以启动成功启动tomcat了。

13.org.activiti.engine.ActivitiException: Couldn’t deserialize object in variable ‘application’

1、遇到工作流的问题第一个想到的,我觉得就是在添加流程变量的的时候,你的实体类有没有实现序列化接口
2、然后,再看其他的问题
3.今天遇到了这个问题,其他的都实现了序列化接口,以为不是这个问题,由于我的项目中,有一个taskView类(申请和task类的实体类),这个我是没有实现序列化的,原本以为是不用实现的,但是后来通过debug调试后发现问题就是出现在这里。
4.实现序列化接口后,问题就解决了。

解决办法:注意类与类之间的关系,之间的强转,接口的泛型是否有写正确。

10-06 12:29