大家好,我看了几个主题,但我找不到解决问题的方法。 我想使用GWT上传文件,因此 I followed this tutorial
当我点击按钮加载文件时,我得到了这个例外:
07:59:20,285 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/GWTExample].[uploadProgressServlet]] (http-localhost-127.0.0.1-8181-5) Exception lors de l'allocation pour la servlet uploadProgressServlet: java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source) [rt.jar:1.6.0_24]
at java.util.Properties.load0(Unknown Source) [rt.jar:1.6.0_24]
at java.util.Properties.load(Unknown Source) [rt.jar:1.6.0_24]
at com.fth.server.UploadProgressServlet.init(UploadProgressServlet.java:34) [classes:]
at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_24]
当我登录异常位置时,它会转到类UploadProgressServlet和这一行:
public void init() throws ServletException {
Properties properties = new Properties();
try {
properties.load(getServletContext().getResourceAsStream(PROPERTIES_FILE));
} catch (IOException ioe) {
throw new ServletException(ioe);
}
我把文件uploadprogress.properties
放到项目中甚至到了类路径中,但它似乎像Jboss看不到它。
我从教程中做的唯一改变是我使用了自己的vue(使用smartGWT)并将其放入按钮代码中:
uploadform.setFields(imageItem1, imageItem2,imageItem3, imageItem4, imageItem5, saveItem,commit,CancelItem);
saveItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
@Override
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
final UploadProgressServiceAsync SERVICE = GWT.create(UploadProgressService.class);
ServiceDefTarget serviceDef = (ServiceDefTarget) SERVICE;
String moduleRelativeURL = GWT.getModuleBaseURL() + "uploadprogress";
serviceDef.setServiceEntryPoint(moduleRelativeURL);
AsyncCallback<Void> asyncCallback;
SERVICE.readFiles(1, 1, new AsyncCallback<List<FileDto>>() {
@Override
public void onFailure(Throwable caught) {
SC.say(caught.getMessage());
}
@Override
public void onSuccess(List<FileDto> result) {
SC.say(result.toString());
}
});
}
});
这是uploadprogress.properties
:
upload.directory=target
请告诉我是否有什么我应该做,因为我不知道自48小时后该做什么。代码放在按钮中是否正确?