Java项目实际报错和解决方案(持续更新)

1.source  not  find  错误html

对于前台传入过来的参数不了解,致使不太明白。source  not   find 出现的错误,可能就是前台的数据没有传过来,致使数据出现错误。前端

好比:java

前台web

$.ajaxFileUpload({ajax

url  :'../upload/uploadPic.do',spring

type :'post',sql

traditional :true,数据库

fileElementId:'imageData', //id,这句话当时被注释掉了,致使前台的数据没法传递过来。同时,后台也没有相应的id参数,去接收相应的前台数据。apache

dataType:'text',json

data :{imageData:pic},

async :false,

success:function(data,status){

// alert(pic);

// data=parseInt($.trim(data));

// if(data==1){

// alert("图片上传成功...");

// }else{

// alert("图片上传失败...");

// }

},

后台:

public void uploadPic(@RequestParam String imageData,//这个参数没有写,致使后台没法找到前台的数据,报错的是source  not  find 

HttpServletRequest request, HttpServletResponse response){

                    FileOutputStream fos = null;

try {

//base64解析图片信息

BASE64Decoder base = new BASE64Decoder();

byte[] ImageByte = base.decodeBuffer(imageData);

//写进文件  

String home = System.getProperty("user.home");

String filePath = home + "/Desktop/testImg/" + new Date().getTime() + "" + new Random().nextInt(100000) + ".png";

File file = new File(filePath);

if(!file.exists()){

file.createNewFile();

}

fos = new FileOutputStream(file);

fos.write(ImageByte);

System.out.println(file.getAbsolutePath());

} catch (IOException e) {

e.printStackTrace();

}finally{

try {

fos.flush();

fos.close();  

} catch (IOException e) {

e.printStackTrace();

}  

fos=null;

}

2.日志文件配置

web.xml的配置

<!-- log4j日志配置 开始-->

<context-param>

    <param-name>log4jConfigLocation</param-name>

    <param-value>classpath:properties/log4j.properties</param-value>

</context-param>

<listener>

    <listener-class>

     org.springframework.web.util.Log4jConfigListener

    </listener-class>

</listener>

<!-- log4j结束 -->

3.Could not resolve type alias 'DgRoleMapper'

问题的解决:

<property name="typeAliasesPackage" value="com.xxxx.core.bean.table,com.xxxx.core.bean.faceidentifyservice"/>这里没有进行扫描

</bean>

<select id="getDgRoleist" parameterType="DgRole" resultMap="dgRole">这里填写有误

<include refid="dgRoleSelector"/>

<include refid="dgRoleWhere"/>

</select>

4.问题:

多是配置文件的问题,webServiceImpl.xml,其次是web.xml文件。web.xml没有配置servlet.

5.出错:spring.liveBeansView.mbeanDomain,这个是日志的问题,能够不用解决。

6.Could not determine bean name for instance of classclass org.apache.cxf.bus.

    没有配置在web.xml中配置cxf的servlet;或者地址错误。

7.cannot be cast to 不能被转换为

    也就是返回的类型和被定义的类型不匹配。致使不能被匹配。

8.The source attachment doesnot contain the source for the file nativemethodaccessorimpl.class.

    解决:Source Not found。 不是错误。而是你在工程里设置了调试断点,因此自动进入调试模式,而后IDE开始寻找源码。找不到源码,就会出现上

述界面。因此解决的方法就是去掉断点就好了。

9.使用ajax传递数据到后台,同时后台传递数据到前台。产生的问题:return "/query/action.do",没法返回页面。主要的缘由:ajax致使没法返回页面。

解决:后台:

    后台处理以后:

JSONObject jo = new JSONObject();

jo.put("userId", userId);//主要是把userId传递到前台

jo.put("msg", "success");

ResponseUtils.renderJson(response, jo.toString());

    前台接收数据:   

function convertCanvasToImage() {

var pic = document.getElementById("canvas").toDataURL("image/png");

pic = pic.replace(/^data:image\/(png|jpg);base64,/, "");

$.ajaxFileUpload({

url  :'../upload/uploadPic.shtml',

type :'post',

traditional :true,

fileElementId:'imageData', //id

dataType:'text',

data :{imageData:pic},

async :false,

success:function(data){ //返回数据接收后台数据

if(data){

var jsonObj = JSON.parse(data.match(/{.*?}/)&&data.match(/{.*?}/)[0]||"{}");

if(jsonObj.msg =="success"){

location.href ="registerUserinfo.jsp?userId="+jsonObj.userId;

}else if(jsonObj.msg =="faild"){

alert("注册失败!")

layer.open({

title : false,

skin: 'layui-layer-molv',

content : '注册失败,请与管理员联系'

});

}

}

},

error:function(data){

//loginFaild();

}

});

}

10.虚拟化的 Intel VT-x/EPT 要求具有 64 位客户机支持。不使用虚拟化的 Intel VT-x/EPT,是否继续?

开机的时候按F12,进入bois中的intel设置为enabled。

11.服务器拒绝了SFTP链接,但它监听FTP链接。想要用FTP协议来代替SFTP吗?最好是用加密的。

Linux没有安装ftp。须要进行安装。http://blog.csdn.net/hyholine/article/details/24579001 。


12.安装ftp的时候报错。

13.Required MultipartFile parameter 'pic' is not present 文件上传,也属于数据没有传过来的现象,由于现实的是pic为null的话。

    通常若是是在方法上,现实的字段数据为null,代表该数据没有传递过来。

问题的来源:

@RequestMapping(value="/image/uplodImg.shtml", method = RequestMethod.POST)

/**

 * 测试图片类

 * @param pic 图片

 * @param response

 */

public void uplodImg(@RequestParam("") MultipartFile pic,HttpServletResponse response){

try {

byte[] image = pic.getBytes();

String faceId = Utils.geneterUUID();

解决:

public void uplodImg(@RequestParam("file") MultipartFile pic,HttpServletResponse response){

try {

byte[] image = pic.getBytes();

String faceId = Utils.geneterUUID();

 

@SuppressWarnings("unused")

List<FaceRect> list = new ArrayList<FaceRect>();

注意:file要和页面上传文件控件中的name一致,否则会致使出错。

 

 14.Request method "Post" not supported

对于有ajax的上传的页面,出现这样的问题。

解决:先加载页面,而后写。。。

15.jsp页面中"http://java.sun.com/jsp/jstl/core"报错。

解决:没有导入jar包 ,把jstl-1.2导入。  

16.maven错误

http://www.cnblogs.com/tenghoo/p/maven_error.html 

17.错误:

“No mapping found for HTTP request with URI” 

Did not find handler method for [/backaction/backindex.do]  ~ org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:230) ~ org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping ~ 39478

2016-04-08 10:25:43,347 WARN  ~ No mapping found for HTTP request with URI [/keyCloud/backaction/backindex.do] in DispatcherServlet with name 'back'  ~ org.springframework.web.servlet.DispatcherServlet.noHandlerFound(DispatcherServlet.java:1108) ~ org.springframework.web.servlet.PageNotFound ~ 39479

2016-04-08 10:25:43,347 DEBUG ~ Successfully completed request  ~ org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) ~ org.springframework.web.servlet.DispatcherServlet ~ 39479

缘由:已经配置了注解,可是配置文件有配置一个注解,把原来的给覆盖了,没法使用。使用删除后面的注解就行。注册注解处理器
<mvc:annotation-driven />把这个删除就行。

 

18.$.post传递不过来参数,怎么回事?

http://www.oschina.net/question/2334057_237284 。首先检查页面的参数是否有问题。 

19.SrpingMVC

 No adapter for handler [public java.lang.String com.keyCloud.core.controller.back.backCenterController.backindex()]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler

解决:若是增长了拦截器,就必须配置适配器、映射器等。这个问题是没有配置适配器。两个同时存在。

 

 
  1. <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
  2. <property name="interceptors">
  3. <list>
  4. <bean class="com.keyCloud.core.web.backSpringmvcInterceptor">
  5.  
  6. </bean>
  7. </list>
  8. </property>
  9. </bean>
  10. <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
  11.  

20.It is indirectly referenced from required .class file 前面跟着类。出错

maven管理中缺乏这个包,请导入这个类的包。

21. The method replaceFirst(String, String) in the type String is not applicable for the arguments (char, String)

 

 startDate = startDate.replaceFirst(startDate.charAt(7), "月");  类型转换的问题。

22. Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing。

 因而百度谷歌了一下相关资料。原来我写的内部类是动态的,也就是开头以public class开头。而主程序是public static class main。在Java中,类中的静态方法不能直接调用动态方法。

 只有将某个内部类修饰为静态类,而后才可以在静态类中调用该类的成员变量与成员方法。因此在不作其余变更的状况下,最简单的解决办法是将public class改成public static class.

23. Injection of resource dependencies failed; nested exception is org.springfra

类注入失败。一是:没有扫描包;二是配置问题,配置的位置放错了文件。

24.java.lang.NoClassDefFoundError: org/springframework/core/DefaultParameterNameDiscoverer

spring-core核心包没有导入,或者核心包冲突。从新导入就行。

25.getwriter() has already been called for this response。

java.lang.IllegalStateException: getWriter() has already been called for this response

在执行下述代码时报错,

OutputStream out = getResponse().getOutputStream();

缘由为代码中有打开的Response.getWriter(),未关闭,因调用点较多,很差一一排查。

经过查看代码,看到response中的usingWriter=true,随即想办法将该标志位设置为false。

response.reset(); 便可,注意reset后缓存消失,设置消失。

OutputStream和Writer在一个response中不能同时得到。

26.定时器:Unable to store job because one already exists with this identification

解决方法:

You can:

  • check if the "job key" already exists, and remove the existing job before creating a new one:

    scheduler.deleteJob(job1Key);

  • or create a new job with another key (in your case, each time you execute scheduleJobs(), variable i has the same value (0)

  • or just re-use the same job (why would you create a new job if the old one is still good)

  • or use the RAM Job Store, which does not persist jobs in database (each time you will use your software, you will have an empty job store)

  •  

27.tomcat启动的时候

org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/cigar-box-frontend]]

应该是web.xml的问题:

<servlet>

<servlet-name>cigarboxFrontendMvc</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

<init-param>

<param-name>contextConfigLocation</param-name>

<param-value>classpath:spring/spring-mvc.xml</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

<multipart-config>

<max-file-size>5242880</max-file-size><!-- 5MB -->

<max-request-size>20971520</max-request-size><!-- 20MB -->

<file-size-threshold>0</file-size-threshold>

</multipart-config>

</servlet>

<!--为DispatcherServlet创建映射 -->

<servlet-mapping>

<servlet-name>cigarboxFrontendMvc</servlet-name>

<url-pattern>/</url-pattern>

</servlet-mapping>

28.文件上传的问题

transferTo 上传失败

缘由:1.jetty环境和tomcat环境下的是不同的,主要的是根目录有问题。

tomcat下面是没有问题的,而jetty不要带D:\就好了,jetty会自动添加到保存的本地目录。

29.Caused by: java.sql.SQLException: Field 'id' doesn't have a default value

解决方法:数据库的id没有设置为自动增加,或者实体类没有设置自动增加。

30.Caused by: java.net .SocketException: Broken pipe

at java.net

.SocketOutputStream.socketWrite0(Native Method) ~[na:1.7.0_79]

at java.net

.SocketOutputStream.socketWrite(SocketOutputStream.java:113) ~[na:1.7.0_79]

at java.net

.SocketOutputStream.write(SocketOutputStream.java:159) ~[na:1.7.0_79]

at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215) ~[tomcat-coyote.jar:7.0.63]

at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480) ~[tomcat-coyote.jar:7.0.63]

at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:119) ~[tomcat-coyote.jar:7.0.63]

at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:801) [tomcat-coyote.jar:7.0.63]

at org.apache.coyote.Response.action(Response.java:172) ~[tomcat-coyote.jar:7.0.63]

at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:363) ~[catalina.jar:7.0.63]

... 42 common frames omitted

解决方法:请求超时-前端显示,或者请求好久才出现数据。一是网络,二是查询数据很慢,致使的。

多是数据库的问题,若是是查询根据id,有没有设置主键id;而是数据大,查询很慢,致使超时,程序代码很简单,有没有设置索引。

31.tar -zxvf apache-storm-1.1.1.tar.gz

gzip: stdin: not in gzip format

tar: Child returned status 1

tar: Error is not recoverable: exiting now

解决方法:1.查看文件 的属性,file apache-storm-1.1.1.tar.gz

apache-storm-1.1.1.tar.gz: HTML document text。代表是heml,因此解压不了。从新下载包进去解压。

2.弃掉z参数。

相关文章
相关标签/搜索