当我调用我的服务类时,我有一个java.lang.NullPointerException

时间:2016-08-29 10:09:46

标签: java spring exception null

我在spring mvc上遇到m类服务的问题,当我调用m类方法它返回一个java.lang.NullPointerException

                // Partie d'importation des Data

                parseData = null;

                Hashtable<String, String> Data = new Hashtable<>();

                Data.put("idName", parseData.ParseidName(saveDirectory + fileName+".txt"));
                Data.put("country", "test");
                Data.put("date", "test");
                Data.put("mncmcc", "test");
                Data.put("pmn", "test");
                Data.put("dns", "test");
                Data.put("mails", "test");
                Data.put("phones", "test");


                //return back to home.jsp
                ModelAndView model = new ModelAndView("uploadfile");
                model.addObject("Datas", Data);
                map.addAttribute("Datas", Data);

                 fileNames.add(fileName); 

我的ParsingData服务是

public interface ParseDataService {

public String ParseidName(String filename);
public String ParseDate(File f);
public String ParseMNCMCC(File f);
public String ParseIP(File f);
public String ParseDNS(File f);
public String ParseContacts(File f);

}

实施是

@Service("ParseService")
@Transactional
public class ParseServiceImpl implements ParseService {

private static String content;
private static  File raexfile;




@Override
public
  String toTxt(String filename) throws IOException {    

    raexfile =  new File (filename);

    PDDocument document = PDDocument.load(raexfile);

    PDFTextStripper s = new PDFTextStripper();

    content = s.getText(document);

       return content;

    }




public ParseServiceImpl() {
    super();
    // TODO Auto-generated constructor stub
}


}

异常错误是java.lang.NullPointerException我不知道如何初始化我的服务类:

java.lang.NullPointerException
com.roaming.controller.irFileUploadController.crunchifySave(irFileUploadCont    roller.java:78)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62    )
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl    .java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(Invocab    leHandlerMethod.java:219)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForReque    st(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandle   rMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerA   dapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerA   dapter.handleInternal(RequestMappingHandlerAdapter.java:686)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.hand

0 个答案:

没有答案