When Tomcat is running as a service, JACOB calls Excel fails solution

Source http://wowtianwen.iteye.com/blog/1952913

 

Problem performance:

1. JACOB can call Excel normally when Tomcat is run from the command line.

2. When Tomcat is started as a Windows service, the call will be unsuccessful, which means that the program is stuck at the calling step.

3. If you look closely at the Tomcat log, you will find the following errors:

com.jacob.com.ComFailException: Invoke of: OpenSource: Microsoft Office Excel Description: Microsoft Office Excel

• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are saving has the same name as the currently open workbook.

 

If you encounter the above problems, congratulations that you have been pitted by Microsoft's junk software again.

solution:

 

1, if it is windows 2008 operating system

Please refer to these 2 articles:

http://stackoverflow.com/questions/16731037/excel-cant-read-file-written-by-java-process-when-running-as-windows-service

http://bytes.com/topic/c-sharp/answers/819740-c-service-excel-application-workbooks-open-fails-when-called-service#post3514712

If you can't open it, please flip the ^^ wall by yourself. Or read the introduction directly below:

If you are on a 64-bit operating system

Please create a new Desktop folder in the C:\Windows\SysWOW64\config\systemprofile\ directory

If it is a 32-bit operating system

Please create a new Desktop folder in the C:\Windows\System32\config\systemprofile\ directory

2. If you still can't go through the above steps, shake your hand. After I tried it, it still doesn't work. Please continue to look down.

3. Please refer to these 2 articles:

http://stackoverflow.com/questions/3658936/office-2007-is-unable-to-open-files-when-called-through-jacob-from-a-service

http://bytes.com/topic/c-sharp/answers/819740-c-service-excel-application-workbooks-open-fails-when-called-service#post3466746

If you can't open it, please flip the ^^ wall by yourself. Or read the introduction directly below:

4. First open the task manager and end the process of Excel.exe*32,

5, stop your tomcat service,

6. Run " dcomcnfg "

7. In the newly opened window, expand in turn: "Console Root Node"-->"Component Services"-->"Computer"-->"My Computer"-->"DCOM Configuration",

8. Find a node named " Microsoft Excel Application " inside

9. Right-click the node, select Properties, and switch to the Identity tab

Change to "Interactive User" and click OK to finish

 

如果在第8步里,你没有找到"Microsoft Excel Application"的节点,恭喜你,又被微软这个垃圾公司给坑了,据说是微软忘了在windows2008 64位的dcom配置里加入32位程序,诅****咒微软1000000遍。

请参考:

http://blogs.technet.com/b/the_microsoft_excel_support_team_blog/archive/2012/11/12/microsoft-excel-does-not-appear-in-dcom-configuration-snap-in.aspx

http://social.msdn.microsoft.com/Forums/office/en-US/cba17567-6371-4a66-a33a-5b36093864d2/dcom-component-services-missing-help?forum=worddev

 

不想看的直接看下面介绍:

10,关闭刚才打开的dcom配置的窗口

11,在命令行模式下,切换到

C:\WINDOWS\SysWOW64这个目录

11,输入 mmc comexp.msc /32 这个命令

12,此时会再次弹出刚才的那个dcom窗口,重复7~9的步骤

 

最后再次以服务的方式启动Tomcat,运行你的程序再行测试,应该就可以了。

至此我的是可以了。

什么?你的还是不行?哎,找个墙角,画圈圈诅*****咒微软早点破产吧

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327098942&siteId=291194637