@空杯子 你好,想跟你请教个问题:
之前您在这个问题回答过我。http://www.oschina.net/question/143986_87688
之后我就采用了jod3.0 因为我不想频繁的开启和关闭服务 我就把office开启服务放到了Spring容器开启启动和结束时关闭。管理一个openofficemanager 的bean 。
现在有个这样的问题:因为要解决上面这个连接的问题,只需要释放服务就可以了,所以我就做了转化失败重启服务的操作,之后的转化即使是正确的文件格式也是报错。
以下是错误信息:
严重: Servlet.service() for servlet [action] in context with path [/ewfs] threw exception [Request processing failed; nested exception is java.util.concurrent.RejectedExecutionException] with root cause java.util.concurrent.RejectedExecutionException at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1760) at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:78) at org.artofsolving.jodconverter.office.PooledOfficeManager.execute(PooledOfficeManager.java:71) at org.artofsolving.jodconverter.office.ProcessPoolOfficeManager.execute(ProcessPoolOfficeManager.java:78) at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:78) at org.artofsolving.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:69) at sl.ewfs.office.commons.DOC2PDFUtil.conventToPdf(DOC2PDFUtil.java:80) at sl.ewfs.office.commons.DOC2PDFUtil.TxtConventToPdf(DOC2PDFUtil.java:109) at sl.ewfs.office.action.FileInfoAction.ConventToSWF(FileInfoAction.java:591) at sl.ewfs.office.action.FileInfoAction.fileUpload(FileInfoAction.java:426) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 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:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)管理的bean 我是这样写的
public class OpenOfficeManager { private static final Logger logger = Logger .getLogger(OpenOfficeManager.class); // 连接管理类 private static final DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration(); private static OfficeManager officeManager; /** * 任务执行超时 */ private long taskTimeout; public void setTaskTimeout(long taskTimeout) { this.taskTimeout = taskTimeout; } public long getTaskTimeout() { return taskTimeout; } /** * 系统配置访问 */ private static Properties sysProperties; static { String locations[] = new String[] { "/resources.xml" }; sysProperties = ConfigUtils.readClasspathFiles(locations); } /** * 调用openoffice默认端口 */ public static int normalPort = 8100; /** * 设置端口 * * @param portNum */ public static void setPort(int portNum) { normalPort = portNum; } //TODO Spring容器初始化开启服务 public void init() { System.out.println("容器开启"); configuration.setOfficeHome(sysProperties .getProperty("openOffice.path"));// 设置OpenOffice.org安装目录 configuration.setPortNumbers(Integer.parseInt(sysProperties .getProperty("openOffice.port"))); // 设置转换端口 configuration.setTaskExecutionTimeout(taskTimeout); officeManager = configuration.buildOfficeManager(); openSoffice(); } // Spring容器销毁 关闭服务 public void destroy() { closeSoffice(); } /** * 开启服务 */ public static void openSoffice() { logger.warn("openoffice服务正在启动...."); try { officeManager.start(); logger.warn("openoffice服务已经启动"); } catch (Exception e) { logger.error("office转换服务启动失败!详细信息:" + e); } } /** * 关闭服务 */ public static void closeSoffice() { logger.info("关闭office转换服务...."); if (officeManager != null) { try { officeManager.stop(); logger.info("office转换服务已关闭"); } catch (Exception e) { logger.error("office转换服务关闭失败!详细信息:" + e); } } } /** * 得到一个转化对象 * @return */ public static OfficeDocumentConverter BuildOfficeDocumentConverter(){ return new OfficeDocumentConverter(officeManager); }bean中的配置:
<bean id="openOffice" class="sl.ewfs.office.commons.OpenOfficeManager" init-method="init" destroy-method="destroy"> <!-- 转化任务超时时间为5分钟 --> <property name="taskTimeout" value="300000" /> </bean>
我感觉代码没什么问题;
不过“听说”jod不能同时转换多个文件,你看看是不是这个原因引起的啊;
还有,个人建议将转换的方法设计成静态方法,没必要交给Spring管理;
嗯,是每次都转化一个,没有这方面的资料。这样太慢了呢,想做成并发转化,同时开几个转化的端口出来试试。嗯,我多试试。谢谢你哈。我感觉代码没什么问题;
不过“听说”jod不能同时转换多个文件,你看看是不是这个原因引起的啊;
还有,个人建议将转换的方法设计成静态方法,没必要交给Spring管理;
我感觉代码没什么问题;
不过“听说”jod不能同时转换多个文件,你看看是不是这个原因引起的啊;
还有,个人建议将转换的方法设计成静态方法,没必要交给Spring管理;
我感觉代码没什么问题;
不过“听说”jod不能同时转换多个文件,你看看是不是这个原因引起的啊;
还有,个人建议将转换的方法设计成静态方法,没必要交给Spring管理;
大哥解决了吗,能给个意见吗版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。