Я запускаю matlab на своем локальном компьютере и вызываю следующую функцию из Java (работающую на веб-сервере tomcat):
function df = getFig(file)
f = openfig(file,'reuse','invisible');
set(f, 'Color', [1,1,1]);
df = webfigure(f);
close(f);
end
Это работает хорошо локально, но при работе на нашем автономном компьютере.на веб-сервере unix мы получаем эту ошибку:
{Error using set
Width and height must be > 0
Error in
renderwebfigure>@(childHnd,childPos)set(childHnd,'Position',[childPos(1)*parameters.width-clipRect(1)+extraRenderSpace,childPos(2)*parameters.height-clipRect(2)+extraRenderSpace,childPos(3)*parameters.width,childPos(4)*parameters.height])
(line 70)
Error in renderwebfigure>cropFigureAndReturnCData (line 70)
Error in renderwebfigure (line 31)
}
Mar 30, 2012 4:08:17 PM org.apache.catalina.core.ApplicationContext log
INFO: WebFigures: com.mathworks.toolbox.javabuilder.services.ServiceException: com.mathworks.toolbox.javabuilder.services.ServiceException: com.mathworks.toolbox.javabuilder.services.ServiceDispatchTargetException: com.mathworks.toolbox.javabuilder.services.ServiceException: java.lang.reflect.InvocationTargetException
at com.mathworks.toolbox.javabuilder.webfigures.WebFiguresServlet.doGet(WebFiguresServlet.java:161)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: com.mathworks.toolbox.javabuilder.services.ServiceException: com.mathworks.toolbox.javabuilder.services.ServiceDispatchTargetException: com.mathworks.toolbox.javabuilder.services.ServiceException: java.lang.reflect.InvocationTargetException
at com.mathworks.toolbox.javabuilder.webfigures.service.request.WebFigureRenderRequest.process(WebFigureRenderRequest.java:230)
at com.mathworks.toolbox.javabuilder.webfigures.service.request.WebFigureRenderRequest.process(WebFigureRenderRequest.java:38)
at com.mathworks.toolbox.javabuilder.webfigures.service.WebFigureServiceFactory$WebFigureServiceImpl.processRequest(WebFigureServiceFactory.java:61)
at com.mathworks.toolbox.javabuilder.webfigures.service.WebFigureServiceFactory$WebFigureServiceImpl.processRequest(WebFigureServiceFactory.java:42)
at com.mathworks.toolbox.javabuilder.webfigures.WebFiguresServlet$1.call(WebFiguresServlet.java:147)
at com.mathworks.toolbox.javabuilder.webfigures.WebFiguresServlet$1.call(WebFiguresServlet.java:145)
at com.mathworks.toolbox.javabuilder.webfigures.WebFiguresServlet.doGet(WebFiguresServlet.java:158)
... 17 more
Caused by: com.mathworks.toolbox.javabuilder.services.ServiceDispatchTargetException: com.mathworks.toolbox.javabuilder.services.ServiceException: java.lang.reflect.InvocationTargetException
at com.mathworks.toolbox.javabuilder.services.StatefulServicePeerCache.dispatch(StatefulServicePeerCache.java:174)
at com.mathworks.toolbox.javabuilder.webfigures.service.request.WebFigureRenderRequest.process(WebFigureRenderRequest.java:221)
... 23 more
Caused by: com.mathworks.toolbox.javabuilder.services.ServiceException: java.lang.reflect.InvocationTargetException
at com.mathworks.toolbox.javabuilder.webfigures.service.WebFigureBinder$WebFigurePeerImpl.renderImage(WebFigureBinder.java:260)
at com.mathworks.toolbox.javabuilder.webfigures.service.WebFigureBinder$WebFigurePeerImpl.renderEncoded(WebFigureBinder.java:329)
at com.mathworks.toolbox.javabuilder.webfigures.service.request.WebFigureRenderRequest$1.execute(WebFigureRenderRequest.java:223)
at com.mathworks.toolbox.javabuilder.webfigures.service.request.WebFigureRenderRequest$1.execute(WebFigureRenderRequest.java:221)
at com.mathworks.toolbox.javabuilder.services.StatefulServicePeerCache.dispatch(StatefulServicePeerCache.java:171)
... 24 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.mathworks.toolbox.javabuilder.webfigures.service.WebFigureBinder$WebFigurePeerImpl$1.call(WebFigureBinder.java:254)
at com.mathworks.toolbox.javabuilder.webfigures.service.WebFigureBinder$WebFigurePeerImpl$1.call(WebFigureBinder.java:252)
at com.mathworks.toolbox.javabuilder.webfigures.service.WebFigureBinder$WebFigurePeerImpl.whileLocked(WebFigureBinder.java:191)
at com.mathworks.toolbox.javabuilder.webfigures.service.WebFigureBinder$WebFigurePeerImpl.renderImage(WebFigureBinder.java:252)
... 28 more
Caused by: com.mathworks.toolbox.javabuilder.MWException: Error using set
Width and height must be > 0
at com.mathworks.toolbox.javabuilder.internal.MWMCR.mclFeval(Native Method)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.access$600(MWMCR.java:23)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$6.mclFeval(MWMCR.java:833)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$5.invoke(MWMCR.java:731)
at $Proxy4.mclFeval(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.invoke(MWMCR.java:406)
at com.mathworks.toolbox.javabuilder.webfigures.service.WebFigureServiceMCR.renderwebfigure(WebFigureServiceMCR.java:211)
... 36 more
Другие цифры, которые я генерирую, используя график использования (1:10);отлично работает на обеих платформах.Похоже, проблема в функции openfig.Кроме того, если я указываю путь к файлу, который не существует, я получаю ошибку «файл не найден», а ширина и высота должны быть> 0 ошибка
Однако вызов этого метода работает:
function w = getplot
f = figure('visible', 'off');
plot(1:10);
w = webfigure(f);
close(f);
end