SWT widgets
Hello all,
first of all: i am a newbie in this great world...so be kind ;)
i am using the eclipse ide (don't hit me please) and i am using a SWT Text instance in my "application" .
Is there a way to restrict the characters in the Text to be only numbers ?
I need a text field in which the user can only type numbers
thanks for your help
Hello all,
first of all: i am a newbie in this great world...so
be kind ;)
i am using the eclipse ide (don't hit me please) andLOL!
i am using a SWT Text instance in my "application" .
Is there a way to restrict the characters in the Text
to be only numbers ?
I need a text field in which the user can only type
numbers
thanks for your helpbear in mind that I have little SWT experience but I think you want to create a verify listener and add it to your text thing with addVerifyListener.
this appears to be the SWT equiv of the Swing InputVerifier which i have used and would do what you want. Anyway a guess, an educated one but still a guess so don't hit me if i am wrong.
Similar Messages
-
Add a AWT component to a SWT widget
Hello,
is it possible to add a AWT component to a SWT widget?
I have a Java3D canvas witch exetends from java.awt.component and i want to display it in my application witch uses SWT, but i can't find a way :-(
Can you help me?
StevIf it only takes other SWT components, then no. If it takes any AWT Component, then yes. But I can't find the API docs to look it up. So if you are using it, presumably you have the API docs and should thus look there for the answer... or try it, as it would've taken less time waiting for this ignorant answer.
-
Org.eclipse.swt.SWTException: Widget is disposed
Hello ,
I am using SWT for creating UI , I am written following code for creating pop up window
Button ok = componentsRenderer.createButtonWidget(versionTreeComponentsShell, SWT.PUSH,
PropertyClass.getPropertyLabel(QTLConstants.OK_BUTTON));
Button cancel = componentsRenderer.createButtonWidget(versionTreeComponentsShell, SWT.PUSH,
PropertyClass.getPropertyLabel(QTLConstants.CANCEL_BUTTON));
ok.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
StringBuffer sbDefaultVersionSplitter = new StringBuffer();
String defaultVersionSplitterSelected = "";
if(versionSplitterCheckBoxList.size() > 0){
String[] defaultVersionSplitters = PropertyClass.getPropertyLabel(QTLConstants.VERSIONING_ASSISTENT_PAGE_SPLLITER).split(QTLConstants.MULTIPLE_EXTENSIONS_SPLITER);
for(Button cbButton : versionSplitterCheckBoxList){
if(cbButton.getSelection() && !cbButton.getText().equalsIgnoreCase(defaultVersionSplitters[3])){
// check is added for version number string equal to "<fileName><number>" i.e splitter is not present
if(!cbButton.getText().equalsIgnoreCase(defaultVersionSplitters[2])){
String tempVersionStringWithSplitter = cbButton.getText().substring(cbButton.getText().indexOf("_")+1,cbButton.getText().length());
String selectedSplitter = tempVersionStringWithSplitter.substring(0,tempVersionStringWithSplitter.indexOf("<"));
sbDefaultVersionSplitter.append(selectedSplitter);
sbDefaultVersionSplitter.append("|");
}//end of for loop
if(customVersionSplitterText.isEnabled() && customVersionSplitterText.getCharCount() > 0){
sbDefaultVersionSplitter.append(customVersionSplitterText.getText());
defaultVersionSplitterSelected = sbDefaultVersionSplitter.toString();
} else if(sbDefaultVersionSplitter.length() > 0 && (!customVersionSplitterText.isEnabled() || customVersionSplitterText.getCharCount() == 0)){
defaultVersionSplitterSelected = sbDefaultVersionSplitter.toString().substring(0, sbDefaultVersionSplitter.length()-2);
}//end of if loop
dataBean.setVersionSplitterSelected(defaultVersionSplitterSelected);
versionTreeComponentsShell.close();
cancel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
versionTreeComponentsShell.setVisible(false);
when i am clicking multiple time on "OK" button i am getting following error
org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(SWT.java:4361)
at org.eclipse.swt.SWT.error(SWT.java:4276)
at org.eclipse.swt.SWT.error(SWT.java:4247)
at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340)
at org.eclipse.swt.widgets.Button.getSelection(Button.java:721)
at com.impact.qtl12.imports.UI.CSVWizard.FileInputPage$10.widgetSelected(FileInputPage.java:784)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at com.impact.qtl12.imports.UI.CSVFile.QTL$4.widgetSelected(QTL.java:427)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
at com.impact.qtl12.imports.UI.CSVFile.QTL.createShell(QTL.java:767)
at com.impact.qtl12.imports.UI.CSVFile.QTL.launch(QTL.java:826)
at com.impact.qtl12.imports.UI.CSVFile.QTL.main(QTL.java:847)
whats solution for this ?
RegardsYou can try asking third party API questions here, but you'll likely be waiting a long time. You are better off looking for a forum that is specifically for your third party technology; in this case I would look around on the Eclipse website since its their tech.
-
JVM crash for RCP/SWT application under windows
Hi,
We are running an RCP application under windows which uses SWT components .Intermittently the JVM carshes.I doubt SWT is the prime suspect or JVM???We are unable to identify the exact sequence in which the crash occurs.I'm attaching some hs_err_pdi* log files for the abnormal crash.
Any insight appreciated.
rgds,
tess
Core dump 1:
# An unexpected error has been detected by HotSpot Virtual Machine:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d6d6f09, pid=528, tid=2988
# Java VM: Java HotSpot(TM) Client VM (1.5.0_02-b09 mixed mode)
# Problematic frame:
# V [jvm.dll+0x96f09]
--------------- T H R E A D ---------------
Current thread (0x00368338): JavaThread "main" [_thread_in_vm, id=2988]
siginfo: ExceptionCode=0xc0000005, reading address 0x65636194
Registers:
EAX=0x65636170, EBX=0x00a47c80, ECX=0x0006eeb4, EDX=0x00a82480
ESP=0x0006eea8, EBP=0x0006eec0, ESI=0x076271e8, EDI=0x0000021e
EIP=0x6d6d6f09, EFLAGS=0x00010216
Top of Stack: (sp=0x0006eea8)
0x0006eea8: 076271e8 0000021e 076271e8 0006f000
0x0006eeb8: 076271e8 00a47c80 0006f000 6d7091d8
0x0006eec8: 076271e8 6d6f779a 003687ac 07608b68
0x0006eed8: 00368338 6d766380 00000002 0006f108
0x0006eee8: 00a82d81 0006f12c 00368338 00000002
0x0006eef8: 00368338 003687c4 06c21f40 0000000a
0x0006ef08: 00000000 0000000a 00368740 00367ef8
0x0006ef18: 00367f00 003682ec 003687dc 003687bc
Instructions: (pc=0x6d6d6f09)
0x6d6d6ef9: ec 83 ec 0c 56 8b 75 08 57 56 8b 46 08 8d 4d f4
0x6d6d6f09: 0f b7 40 24 89 45 fc 8b 46 0c 8b 78 14 e8 ae 92
Stack: [0x00030000,0x00070000), sp=0x0006eea8, free space=251k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x96f09]
V [jvm.dll+0xc91d8]
V [jvm.dll+0x7c921]
j com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(IZ)Z+127
j com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipSpaces()Z+246
j com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Z)Z+87
j com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Z)Z+24
j com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Z)Z+118
j com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Lcom/sun/org/apache/xerces/internal/xni/parser/XMLInputSource;)V+29
j com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Lcom/sun/org/apache/xerces/internal/xni/parser/XMLInputSource;)V+9
j com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Lorg/xml/sax/InputSource;)V+43
j com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Lorg/xml/sax/InputSource;)Lorg/w3c/dom/Document;+61
j org.eclipse.jface.dialogs.DialogSettings.load(Ljava/io/Reader;)V+18
j org.eclipse.jface.dialogs.DialogSettings.load(Ljava/lang/String;)V+29
j org.eclipse.ui.plugin.AbstractUIPlugin.loadDialogSettings()V+57
j org.eclipse.ui.plugin.AbstractUIPlugin.getDialogSettings()Lorg/eclipse/jface/dialogs/IDialogSettings;+8
j org.eclipse.ui.internal.registry.PerspectiveRegistry.load()V+11
j org.eclipse.ui.internal.WorkbenchPlugin.getPerspectiveRegistry()Lorg/eclipse/ui/IPerspectiveRegistry;+22
j org.eclipse.ui.internal.Workbench.getPerspectiveRegistry()Lorg/eclipse/ui/IPerspectiveRegistry;+3
j org.eclipse.ui.internal.Workbench.doOpenFirstTimeWindow()V+2
j org.eclipse.ui.internal.Workbench.openFirstTimeWindow()V+17
j org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow()V+7
j org.eclipse.ui.application.WorkbenchAdvisor.openWindows()Z+45
j org.eclipse.ui.internal.Workbench.init(Lorg/eclipse/swt/widgets/Display;)Z+671
j org.eclipse.ui.internal.Workbench.runUI()I+39
j org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+11
j org.eclipse.ui.PlatformUI.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+2
j com.stabilix.hc.Application.run(Ljava/lang/Object;)Ljava/lang/Object;+237
j org.eclipse.core.internal.runtime.PlatformActivator$1.run(Ljava/lang/Object;)Ljava/lang/Object;+257
j org.eclipse.core.runtime.adaptor.EclipseStarter.run(Ljava/lang/Object;)Ljava/lang/Object;+170
j org.eclipse.core.runtime.adaptor.EclipseStarter.run([Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object;+57
v ~StubRoutines::call_stub
V [jvm.dll+0x818e8]
V [jvm.dll+0xd4989]
V [jvm.dll+0x817b9]
V [jvm.dll+0xe4c04]
V [jvm.dll+0x9f94f]
C [java.dll+0x6c08]
j sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+87
j sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+111
j org.eclipse.core.launcher.Main.invokeFramework([Ljava/lang/String;[Ljava/net/URL;)V+181
j org.eclipse.core.launcher.Main.basicRun([Ljava/lang/String;)V+107
j org.eclipse.core.launcher.Main.run([Ljava/lang/String;)I+4
j org.eclipse.core.launcher.Main.main([Ljava/lang/String;)V+10
v ~StubRoutines::call_stub
V [jvm.dll+0x818e8]
V [jvm.dll+0xd4989]
V [jvm.dll+0x817b9]
V [jvm.dll+0x88747]
C [javaw.exe+0x14c0]
C [javaw.exe+0x313d]
C [kernel32.dll+0x16d4f]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(IZ)Z+127
j com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipSpaces()Z+246
j com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Z)Z+87
j com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Z)Z+24
j com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Z)Z+118
j com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Lcom/sun/org/apache/xerces/internal/xni/parser/XMLInputSource;)V+29
j com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Lcom/sun/org/apache/xerces/internal/xni/parser/XMLInputSource;)V+9
j com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Lorg/xml/sax/InputSource;)V+43
j com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Lorg/xml/sax/InputSource;)Lorg/w3c/dom/Document;+61
j org.eclipse.jface.dialogs.DialogSettings.load(Ljava/io/Reader;)V+18
j org.eclipse.jface.dialogs.DialogSettings.load(Ljava/lang/String;)V+29
j org.eclipse.ui.plugin.AbstractUIPlugin.loadDialogSettings()V+57
j org.eclipse.ui.plugin.AbstractUIPlugin.getDialogSettings()Lorg/eclipse/jface/dialogs/IDialogSettings;+8
j org.eclipse.ui.internal.registry.PerspectiveRegistry.load()V+11
j org.eclipse.ui.internal.WorkbenchPlugin.getPerspectiveRegistry()Lorg/eclipse/ui/IPerspectiveRegistry;+22
j org.eclipse.ui.internal.Workbench.getPerspectiveRegistry()Lorg/eclipse/ui/IPerspectiveRegistry;+3
j org.eclipse.ui.internal.Workbench.doOpenFirstTimeWindow()V+2
j org.eclipse.ui.internal.Workbench.openFirstTimeWindow()V+17
j org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow()V+7
j org.eclipse.ui.application.WorkbenchAdvisor.openWindows()Z+45
j org.eclipse.ui.internal.Workbench.init(Lorg/eclipse/swt/widgets/Display;)Z+671
j org.eclipse.ui.internal.Workbench.runUI()I+39
j org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+11
j org.eclipse.ui.PlatformUI.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+2
j com.stabilix.hc.Application.run(Ljava/lang/Object;)Ljava/lang/Object;+237
j org.eclipse.core.internal.runtime.PlatformActivator$1.run(Ljava/lang/Object;)Ljava/lang/Object;+257
j org.eclipse.core.runtime.adaptor.EclipseStarter.run(Ljava/lang/Object;)Ljava/lang/Object;+170
j org.eclipse.core.runtime.adaptor.EclipseStarter.run([Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object;+57
v ~StubRoutines::call_stub
j sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0
j sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+87
j sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+111
j org.eclipse.core.launcher.Main.invokeFramework([Ljava/lang/String;[Ljava/net/URL;)V+181
j org.eclipse.core.launcher.Main.basicRun([Ljava/lang/String;)V+107
j org.eclipse.core.launcher.Main.run([Ljava/lang/String;)I+4
j org.eclipse.core.launcher.Main.main([Ljava/lang/String;)V+10
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x0b16ad20 JavaThread "Thread-1" daemon [_thread_blocked, id=2932]
0x0af3f128 JavaThread "Start Level Event Dispatcher" daemon [_thread_blocked, id=1568]
0x0affb840 JavaThread "Framework Event Dispatcher" daemon [_thread_blocked, id=3368]
0x0ad535f0 JavaThread "State Data Manager" daemon [_thread_blocked, id=4088]
0x00a4de70 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3972]
0x00a4c408 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2056]
0x00a4b0d0 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=988]
0x00a495e8 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=2076]
0x00a48740 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=4012]
0x00a42698 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_blocked, id=2960]
0x00a38e98 JavaThread "Finalizer" daemon [_thread_blocked, id=2808]
0x00a37a08 JavaThread "Reference Handler" daemon [_thread_blocked, id=1212]
=>0x00368338 JavaThread "main" [_thread_in_vm, id=2988]
Other Threads:
0x00a338c0 VMThread [id=2156]
0x00a4f0b8 WatcherThread [id=4048]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 576K, used 0K [0x02a80000, 0x02b20000, 0x02f60000)
eden space 512K, 0% used [0x02a80000, 0x02a80000, 0x02b00000)
from space 64K, 0% used [0x02b10000, 0x02b10000, 0x02b20000)
to space 64K, 0% used [0x02b00000, 0x02b00000, 0x02b10000)
tenured generation total 4928K, used 2954K [0x02f60000, 0x03430000, 0x06a80000)
the space 4928K, 59% used [0x02f60000, 0x03242a58, 0x03242c00, 0x03430000)
compacting perm gen total 12288K, used 12078K [0x06a80000, 0x07680000, 0x0aa80000)
the space 12288K, 98% used [0x06a80000, 0x0764ba68, 0x0764bc00, 0x07680000)
No shared spaces configured.
Dynamic libraries:
0x00400000 - 0x0040c000 C:\Program Files\Java\jre1.5.0_02\bin\javaw.exe
0x7c900000 - 0x7c9b0000 C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f4000 C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e6b000 C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000 C:\WINDOWS\system32\RPCRT4.dll
0x77d40000 - 0x77dd0000 C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f57000 C:\WINDOWS\system32\GDI32.dll
0x77c10000 - 0x77c68000 C:\WINDOWS\system32\MSVCRT.dll
0x6d640000 - 0x6d7c5000 C:\Program Files\Java\jre1.5.0_02\bin\client\jvm.dll
0x76b40000 - 0x76b6d000 C:\WINDOWS\system32\WINMM.dll
0x6d280000 - 0x6d288000 C:\Program Files\Java\jre1.5.0_02\bin\hpi.dll
0x76bf0000 - 0x76bfb000 C:\WINDOWS\system32\PSAPI.DLL
0x6d380000 - 0x6d3b5000 C:\Program Files\Java\jre1.5.0_02\bin\jdwp.dll
0x6d610000 - 0x6d61c000 C:\Program Files\Java\jre1.5.0_02\bin\verify.dll
0x6d300000 - 0x6d31d000 C:\Program Files\Java\jre1.5.0_02\bin\java.dll
0x6d630000 - 0x6d63f000 C:\Program Files\Java\jre1.5.0_02\bin\zip.dll
0x6d220000 - 0x6d227000 C:\Program Files\Java\jre1.5.0_02\bin\dt_socket.dll
0x71ab0000 - 0x71ac7000 C:\WINDOWS\system32\WS2_32.dll
0x71aa0000 - 0x71aa8000 C:\WINDOWS\system32\WS2HELP.dll
0x71a50000 - 0x71a8f000 C:\WINDOWS\System32\mswsock.dll
0x76f20000 - 0x76f47000 C:\WINDOWS\system32\DNSAPI.dll
0x76fb0000 - 0x76fb8000 C:\WINDOWS\System32\winrnr.dll
0x76f60000 - 0x76f8c000 C:\WINDOWS\system32\WLDAP32.dll
0x76fc0000 - 0x76fc6000 C:\WINDOWS\system32\rasadhlp.dll
0x662b0000 - 0x66308000 C:\WINDOWS\system32\hnetcfg.dll
0x71a90000 - 0x71a98000 C:\WINDOWS\System32\wshtcpip.dll
0x6d4c0000 - 0x6d4d3000 C:\Program Files\Java\jre1.5.0_02\bin\net.dll
0x6d4e0000 - 0x6d4e9000 C:\Program Files\Java\jre1.5.0_02\bin\nio.dll
0x10000000 - 0x10050000 C:\Eclipse-Latest\eclipse\workspace\.metadata\.plugins\org.eclipse.pde.core\hc.product\org.eclipse.osgi\bundles\66\1\.cp\swt-win32-3201.dll
0x774e0000 - 0x7761d000 C:\WINDOWS\system32\ole32.dll
0x773d0000 - 0x774d2000 C:\WINDOWS\WinSxS\X86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\COMCTL32.dll
0x77f60000 - 0x77fd6000 C:\WINDOWS\system32\SHLWAPI.dll
0x763b0000 - 0x763f9000 C:\WINDOWS\system32\comdlg32.dll
0x7c9c0000 - 0x7d1d5000 C:\WINDOWS\system32\SHELL32.dll
0x77120000 - 0x771ac000 C:\WINDOWS\system32\OLEAUT32.dll
0x76390000 - 0x763ad000 C:\WINDOWS\system32\IMM32.dll
0x74d90000 - 0x74dfb000 C:\WINDOWS\system32\USP10.dll
VM Arguments:
jvm_args: -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,suspend=y,address=localhost:3797
java_command: org.eclipse.core.launcher.Main -launcher c:\Eclipse-Latest\eclipse\eclipse -name Eclipse -showsplash 600 -product com.stabilix.hc.hc -data C:\Eclipse-Latest\eclipse\runtime-hc.product -configuration file:C:/Eclipse-Latest/eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/hc.product/ -dev file:C:/Eclipse-Latest/eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/hc.product/dev.properties -pdelaunch -os win32 -ws win32 -arch x86
Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.5.0_02
CLASSPATH=.;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cisuz.jar;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cu.jar;C:\PROGRA~1\IBM\SQLLIB\bin;C:\PROGRA~1\IBM\SQLLIB\tools\db2XTrigger.jar;C:\PROGRA~1\IBM\SQLLIB\java\common.jar;C:\DBXML\dbxml-2.0.9\dbxml\bin\release\dbxml.jar;C:\DBXML\dbxml-2.0.9\dbxml\bin\release\dbxml.jar;C:\DBXML\dbxml-2.0.9\dbxml\bin\release\dbxml.jar;.;C:\Program Files\Java\jdk1.5.0_02;C:\workspace\test;C:\Program Files\Java\jdk1.5.0_02\bin;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\jar\dbxml.jar;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\jar\db.jar;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\jar\dbxmlexamples.jar;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\jar\dbexamples.jar;C:\jbpm\jbpm-starters-kit-with-eclipse-3.0\jbpm-designer\eclipse\workspace\simple\map;C:\jbpm\jbpm-starters-kit-with-eclipse-3.0\jbpm-designer\eclipse;
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\NetManage\Windows;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;C:\jdk1.3.1_02\include;C:\DBXML\dbxml-2.0.9\dbxml\bin\release;C:\jdk1.3.1_02\bin;C:\Program Files\ZeusSCC-CVS;C:\Program Files\Java\jdk1.5.0_02\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\bin;C:\jbpm\jbpm-starters-kit-with-eclipse-3.0\jbpm-designer\eclipse;C:\MSSQL7\BINN;C:\Eclipse-Latest\eclipse\configuration\org.eclipse.osgi\bundles\64\1\.cp;C:\PROGRA~1\IBM\CLIENT~1;C:\PROGRA~1\IBM\CLIENT~1\Shared;C:\PROGRA~1\IBM\CLIENT~1\Emulator;C:\Eclipse-Latest\birt-runtime-1_0_1\bin
USERNAME=metty
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 7, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows XP Build 2600 Service Pack 2
CPU:total 1 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht
Memory: 4k page, physical 522228k(84240k free), swap 2028336k(1554380k free)
vm_info: Java HotSpot(TM) Client VM (1.5.0_02-b09) for windows-x86, built on Mar 4 2005 01:53:53 by "java_re" with MS VC++ 6.0
Core dump:2
# An unexpected error has been detected by HotSpot Virtual Machine:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0537f870, pid=3376, tid=2188
# Java VM: Java HotSpot(TM) Client VM (1.5.0_02-b09 mixed mode, sharing)
# Problematic frame:
# C 0x0537f870
--------------- T H R E A D ---------------
Current thread (0x00357dc8): JavaThread "main" [_thread_in_native, id=2188]
siginfo: ExceptionCode=0xc0000005, reading address 0x0537f870
Registers:
EAX=0x7ffdf000, EBX=0x00000000, ECX=0x00000000, EDX=0x00000002
ESP=0x0006f1ec, EBP=0x0006f214, ESI=0x0537f870, EDI=0x0006f250
EIP=0x0537f870, EFLAGS=0x00010202
Top of Stack: (sp=0x0006f1ec)
0x0006f1ec: 77d48734 0014074a 0000001c 00000000
0x0006f1fc: 00000508 0537f870 dcbaabcd 00000000
0x0006f20c: 0006f250 0537f870 0006f27c 77d48816
0x0006f21c: 0537f870 0014074a 0000001c 00000000
0x0006f22c: 00000508 00000000 0014074a 00000102
0x0006f23c: 00000014 00000001 00000000 00000000
0x0006f24c: 00000010 00000000 00000001 00000000
0x0006f25c: 00000000 00000000 0006f230 0006ee10
Instructions: (pc=0x0537f870)
0x0537f860:
[error occurred during error reporting, step 100, id 0xc0000005]
Stack: [0x00030000,0x00070000), sp=0x0006f1ec, free space=252k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x0537f870
C [USER32.dll+0x8816]
C [USER32.dll+0xb4c0]
C [USER32.dll+0xb50c]
C [ntdll.dll+0xeae3]
C [USER32.dll+0x9402]
C [swt-win32-3201.dll+0x8179]
J org.eclipse.swt.internal.win32.OS.PeekMessageW(Lorg/eclipse/swt/internal/win32/MSG;IIII)Z
J org.eclipse.swt.widgets.Display.readAndDispatch()Z
J org.eclipse.ui.internal.Workbench.runEventLoop(Lorg/eclipse/jface/window/Window$IExceptionHandler;Lorg/eclipse/swt/widgets/Display;)V
v ~OSRAdapter
j org.eclipse.ui.internal.Workbench.runUI()I+108
j org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+11
j org.eclipse.ui.PlatformUI.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+2
j com.stabilix.hc.Application.run(Ljava/lang/Object;)Ljava/lang/Object;+167
j org.eclipse.core.internal.runtime.PlatformActivator$1.run(Ljava/lang/Object;)Ljava/lang/Object;+257
j org.eclipse.core.runtime.adaptor.EclipseStarter.run(Ljava/lang/Object;)Ljava/lang/Object;+170
j org.eclipse.core.runtime.adaptor.EclipseStarter.run([Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object;+57
v ~StubRoutines::call_stub
V [jvm.dll+0x818e8]
V [jvm.dll+0xd4989]
V [jvm.dll+0x817b9]
V [jvm.dll+0xe4c04]
V [jvm.dll+0x9f94f]
C [java.dll+0x6c08]
j sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+87
j sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+111
j org.eclipse.core.launcher.Main.invokeFramework([Ljava/lang/String;[Ljava/net/URL;)V+181
j org.eclipse.core.launcher.Main.basicRun([Ljava/lang/String;)V+107
j org.eclipse.core.launcher.Main.run([Ljava/lang/String;)I+4
j org.eclipse.core.launcher.Main.main([Ljava/lang/String;)V+10
v ~StubRoutines::call_stub
V [jvm.dll+0x818e8]
V [jvm.dll+0xd4989]
V [jvm.dll+0x817b9]
V [jvm.dll+0x88747]
C [javaw.exe+0x14c0]
C [javaw.exe+0x313d]
C [kernel32.dll+0x16d4f]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J org.eclipse.swt.internal.win32.OS.PeekMessageW(Lorg/eclipse/swt/internal/win32/MSG;IIII)Z
J org.eclipse.swt.widgets.Display.readAndDispatch()Z
J org.eclipse.ui.internal.Workbench.runEventLoop(Lorg/eclipse/jface/window/Window$IExceptionHandler;Lorg/eclipse/swt/widgets/Display;)V
v ~OSRAdapter
j org.eclipse.ui.internal.Workbench.runUI()I+108
j org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+11
j org.eclipse.ui.PlatformUI.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+2
j com.stabilix.hc.Application.run(Ljava/lang/Object;)Ljava/lang/Object;+167
j org.eclipse.core.internal.runtime.PlatformActivator$1.run(Ljava/lang/Object;)Ljava/lang/Object;+257
j org.eclipse.core.runtime.adaptor.EclipseStarter.run(Ljava/lang/Object;)Ljava/lang/Object;+170
j org.eclipse.core.runtime.adaptor.EclipseStarter.run([Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object;+57
v ~StubRoutines::call_stub
j sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0
j sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+87
j sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+111
j org.eclipse.core.launcher.Main.invokeFramework([Ljava/lang/String;[Ljava/net/URL;)V+181
j org.eclipse.core.launcher.Main.basicRun([Ljava/lang/String;)V+107
j org.eclipse.core.launcher.Main.run([Ljava/lang/String;)I+4
j org.eclipse.core.launcher.Main.main([Ljava/lang/String;)V+10
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x03076980 JavaThread "Worker-0" [_thread_blocked, id=884]
0x00a6cdc0 JavaThread "Start Level Event Dispatcher" daemon [_thread_blocked, id=2340]
0x00a68920 JavaThread "Framework Event Dispatcher" daemon [_thread_blocked, id=2936]
0x00a612b0 JavaThread "State Data Manager" daemon [_thread_blocked, id=484]
0x00a0e2f8 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3280]
0x00a0ced0 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3264]
0x00a0c1c0 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=844]
0x00a094a0 JavaThread "Finalizer" daemon [_thread_blocked, id=3680]
0x00a07ff0 JavaThread "Reference Handler" daemon [_thread_blocked, id=2316]
=>0x00357dc8 JavaThread "main" [_thread_in_native, id=2188]
Other Threads:
0x00a07008 VMThread [id=2964]
0x00a0f508 WatcherThread [id=552]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 704K, used 454K [0x22a70000, 0x22b30000, 0x22f50000)
eden space 640K, 68% used [0x22a70000, 0x22ade4e8, 0x22b10000)
from space 64K, 20% used [0x22b20000, 0x22b23540, 0x22b30000)
to space 64K, 0% used [0x22b10000, 0x22b10000, 0x22b20000)
tenured generation total 8776K, used 5412K [0x22f50000, 0x237e2000, 0x26a70000)
the space 8776K, 61% used [0x22f50000, 0x23499290, 0x23499400, 0x237e2000)
compacting perm gen total 20480K, used 20413K [0x26a70000, 0x27e70000, 0x2aa70000)
the space 20480K, 99% used [0x26a70000, 0x27e5f6c8, 0x27e5f800, 0x27e70000)
ro space 8192K, 62% used [0x2aa70000, 0x2af78018, 0x2af78200, 0x2b270000)
rw space 12288K, 46% used [0x2b270000, 0x2b7fc620, 0x2b7fc800, 0x2be70000)
Dynamic libraries:
0x00400000 - 0x0040c000 C:\Program Files\Java\jre1.5.0_02\bin\javaw.exe
0x7c900000 - 0x7c9b0000 C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f4000 C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e6b000 C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000 C:\WINDOWS\system32\RPCRT4.dll
0x77d40000 - 0x77dd0000 C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f57000 C:\WINDOWS\system32\GDI32.dll
0x77c10000 - 0x77c68000 C:\WINDOWS\system32\MSVCRT.dll
0x6d640000 - 0x6d7c5000 C:\Program Files\Java\jre1.5.0_02\bin\client\jvm.dll
0x76b40000 - 0x76b6d000 C:\WINDOWS\system32\WINMM.dll
0x6d280000 - 0x6d288000 C:\Program Files\Java\jre1.5.0_02\bin\hpi.dll
0x76bf0000 - 0x76bfb000 C:\WINDOWS\system32\PSAPI.DLL
0x6d610000 - 0x6d61c000 C:\Program Files\Java\jre1.5.0_02\bin\verify.dll
0x6d300000 - 0x6d31d000 C:\Program Files\Java\jre1.5.0_02\bin\java.dll
0x6d630000 - 0x6d63f000 C:\Program Files\Java\jre1.5.0_02\bin\zip.dll
0x6d4c0000 - 0x6d4d3000 C:\Program Files\Java\jre1.5.0_02\bin\net.dll
0x71ab0000 - 0x71ac7000 C:\WINDOWS\system32\WS2_32.dll
0x71aa0000 - 0x71aa8000 C:\WINDOWS\system32\WS2HELP.dll
0x6d4e0000 - 0x6d4e9000 C:\Program Files\Java\jre1.5.0_02\bin\nio.dll
0x10000000 - 0x10050000 C:\Eclipse-Latest\eclipse\workspace\.metadata\.plugins\org.eclipse.pde.core\Eclipse Application\org.eclipse.osgi\bundles\8\1\.cp\swt-win32-3201.dll
0x774e0000 - 0x7761d000 C:\WINDOWS\system32\ole32.dll
0x5d090000 - 0x5d127000 C:\WINDOWS\system32\COMCTL32.dll
0x763b0000 - 0x763f9000 C:\WINDOWS\system32\comdlg32.dll
0x77f60000 - 0x77fd6000 C:\WINDOWS\system32\SHLWAPI.dll
0x7c9c0000 - 0x7d1d5000 C:\WINDOWS\system32\SHELL32.dll
0x77120000 - 0x771ac000 C:\WINDOWS\system32\OLEAUT32.dll
0x76390000 - 0x763ad000 C:\WINDOWS\system32\IMM32.dll
0x74d90000 - 0x74dfb000 C:\WINDOWS\system32\USP10.dll
0x773d0000 - 0x774d2000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
0x71a50000 - 0x71a8f000 C:\WINDOWS\System32\mswsock.dll
0x76f20000 - 0x76f47000 C:\WINDOWS\system32\DNSAPI.dll
0x76fb0000 - 0x76fb8000 C:\WINDOWS\System32\winrnr.dll
0x76f60000 - 0x76f8c000 C:\WINDOWS\system32\WLDAP32.dll
0x76fc0000 - 0x76fc6000 C:\WINDOWS\system32\rasadhlp.dll
0x74c80000 - 0x74cac000 C:\WINDOWS\system32\oleacc.dll
0x76080000 - 0x760e5000 C:\WINDOWS\system32\MSVCP60.dll
0x20000000 - 0x202c5000 C:\WINDOWS\system32\xpsp2res.dll
0x76fd0000 - 0x7704f000 C:\WINDOWS\system32\CLBCATQ.DLL
0x77050000 - 0x77115000 C:\WINDOWS\system32\COMRes.dll
0x77c00000 - 0x77c08000 C:\WINDOWS\system32\VERSION.dll
0x75cf0000 - 0x75d81000 C:\WINDOWS\System32\mlang.dll
0x76380000 - 0x76385000 C:\WINDOWS\system32\msimg32.dll
0x77760000 - 0x778ce000 C:\WINDOWS\System32\shdocvw.dll
0x77a80000 - 0x77b14000 C:\WINDOWS\system32\CRYPT32.dll
0x77b20000 - 0x77b32000 C:\WINDOWS\system32\MSASN1.dll
0x754d0000 - 0x75550000 C:\WINDOWS\system32\CRYPTUI.dll
0x76c30000 - 0x76c5e000 C:\WINDOWS\system32\WINTRUST.dll
0x76c90000 - 0x76cb8000 C:\WINDOWS\system32\IMAGEHLP.dll
0x5b860000 - 0x5b8b4000 C:\WINDOWS\system32\NETAPI32.dll
0x771b0000 - 0x77256000 C:\WINDOWS\system32\WININET.dll
0x77fe0000 - 0x77ff1000 C:\WINDOWS\system32\Secur32.dll
0x77260000 - 0x772ff000 C:\WINDOWS\system32\urlmon.dll
0x77b40000 - 0x77b62000 C:\WINDOWS\system32\appHelp.dll
0x75e90000 - 0x75f40000 C:\WINDOWS\system32\SXS.DLL
0x6d000000 - 0x6d166000 C:\Program Files\Java\jre1.5.0_02\bin\awt.dll
0x73000000 - 0x73026000 C:\WINDOWS\system32\WINSPOOL.DRV
0x77920000 - 0x77a13000 C:\WINDOWS\system32\SETUPAPI.dll
0x03a60000 - 0x03ae8000 C:\WINDOWS\System32\shdoclc.dll
0x72b20000 - 0x72b38000 C:\WINDOWS\system32\plugin.ocx
0x769c0000 - 0x76a73000 C:\WINDOWS\system32\USERENV.dll
0x72d20000 - 0x72d29000 C:\WINDOWS\system32\wdmaud.drv
0x72d10000 - 0x72d18000 C:\WINDOWS\system32\msacm32.drv
0x77be0000 - 0x77bf5000 C:\WINDOWS\system32\MSACM32.dll
0x77bd0000 - 0x77bd7000 C:\WINDOWS\system32\midimap.dll
VM Arguments:
java_command: org.eclipse.core.launcher.Main -launcher c:\Eclipse-Latest\eclipse\eclipse -name Eclipse -showsplash 600 -product com.stabilix.hc.hc -data C:\Eclipse-Latest\eclipse\runtime-EclipseApplication -configuration file:C:/Eclipse-Latest/eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/ -dev file:C:/Eclipse-Latest/eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties -pdelaunch -os win32 -ws win32 -arch x86
Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.5.0_02
CLASSPATH=.;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cisuz.jar;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cu.jar;C:\PROGRA~1\IBM\SQLLIB\bin;C:\PROGRA~1\IBM\SQLLIB\tools\db2XTrigger.jar;C:\PROGRA~1\IBM\SQLLIB\java\common.jar;C:\DBXML\dbxml-2.0.9\dbxml\bin\release\dbxml.jar;C:\DBXML\dbxml-2.0.9\dbxml\bin\release\dbxml.jar;C:\DBXML\dbxml-2.0.9\dbxml\bin\release\dbxml.jar;.;C:\Program Files\Java\jdk1.5.0_02;C:\workspace\test;C:\Program Files\Java\jdk1.5.0_02\bin;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\jar\dbxml.jar;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\jar\db.jar;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\jar\dbxmlexamples.jar;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\jar\dbexamples.jar;C:\jbpm\jbpm-starters-kit-with-eclipse-3.0\jbpm-designer\eclipse\workspace\simple\map;C:\jbpm\jbpm-starters-kit-with-eclipse-3.0\jbpm-designer\eclipse;
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\NetManage\Windows;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;C:\jdk1.3.1_02\include;C:\DBXML\dbxml-2.0.9\dbxml\bin\release;C:\jdk1.3.1_02\bin;C:\Program Files\ZeusSCC-CVS;C:\Program Files\Java\jdk1.5.0_02\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Sleepycat Software\Berkeley DB XML 2.1.8\bin;C:\jbpm\jbpm-starters-kit-with-eclipse-3.0\jbpm-designer\eclipse;C:\MSSQL7\BINN;C:\Eclipse-Latest\eclipse\configuration\org.eclipse.osgi\bundles\64\1\.cp;C:\PROGRA~1\IBM\CLIENT~1;C:\PROGRA~1\IBM\CLIENT~1\Shared;C:\PROGRA~1\IBM\CLIENT~1\Emulator;C:\Eclipse-Latest\birt-runtime-1_0_1\bin
USERNAME=metty
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 7, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows XP Build 2600 Service Pack 2
CPU:total 1 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht
Memory: 4k page, physical 522228k(79952k free), swap 2028336k(1491168k frFirst, I would try and get the latest JDK 1.5.0_06 or 1.5.0_u7.. Next I would look
at the swt version you have..We've seen issues like this before.. Simple update of swt and the problem went away. Worth a try. Good luck -
Hi
All
I'm runing this Java class by a jsp to Search and Replace and saveAs a word document, when run the fisrt time it works OK, but if I run again I got this error:
What is happing there?
Following the Error and Source Java.
Thanks
11:59:49,234 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:3563)
at org.eclipse.swt.SWT.error(SWT.java:3481)
at org.eclipse.swt.SWT.error(SWT.java:3452)
at org.eclipse.swt.widgets.Widget.error(Widget.java:432)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:274)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:265)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:218)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:156)
at br.com.tryblob.view.WordSearchReplace.<init>(WordSearchReplace.java:36)
at org.apache.jsp.replacedoc_jsp._jspService(replacedoc_jsp.java:48)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
12:00:56,843 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:3563)
at org.eclipse.swt.SWT.error(SWT.java:3481)
at org.eclipse.swt.SWT.error(SWT.java:3452)
at org.eclipse.swt.widgets.Widget.error(Widget.java:432)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:274)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:265)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:218)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:156)
at br.com.tryblob.view.WordSearchReplace.<init>(WordSearchReplace.java:36)
at org.apache.jsp.replacedoc_jsp._jspService(replacedoc_jsp.java:48)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
==================JAVA CLASS=====================
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.internal.ole.win32.TYPEATTR;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.OleFunctionDescription;
import org.eclipse.swt.ole.win32.OlePropertyDescription;
import org.eclipse.swt.ole.win32.OleParameterDescription;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.ole.win32.Variant;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
public class WordSearchReplace {
private static final String PROG_ID = "Word.Application";
private static final int WD_REPLACE_ALL = 2;
private static final int WD_FIND_CONTINUE = 1;
private Shell shell = null;
private OleFrame frame = null;
private OleClientSite wordSite = null;
private OleAutomation wordAutomation = null;
private OleAutomation activeDocumentAutomation = null;
private boolean cleaned = false;
* Create a new instance of the WordSearchReplace class.
public WordSearchReplace() {
this.shell = new Shell();
this.frame = new OleFrame(this.shell, SWT.NONE);
this.wordSite = new OleClientSite(this.frame, SWT.NONE, WordSearchReplace.PROG_ID);
this.wordAutomation = new OleAutomation(this.wordSite);
* Open an MS Word file. This is a file whose name ends with the extension
* .doc or .doc and which conforms to the correct format.
* Note; if it is possible to open the named file, an attempt is made
* to cache an OleAutomation object referencing that file which will be
* referred to in future as the active document. Most other methods
* need to capture references to further OleAutomation(s) that have the
* active document as their root.
* @param fileName An instance of the String class that encapsulates the
* path to and name of the file that is to be opened.
* Note; the full path name must be supplied as Word
* will be opening the file and no assumptions can
* safely be made concerning the applications 'home'
* folder.
* @throws NullPointerException if a null value is passed to the fileName
* parameter.
* @throws FileNotFoundException if it is not possible to locate the
* file.
* @throws IllegalArgumentException if the name of the file does not end
* with either the .dot or .doc extensions.
* @throws SWTException if a problem occurs whilst invoking any of the OLE
* methods.
public void openFile(String fileName) throws SWTException,
NullPointerException,
FileNotFoundException,
IllegalArgumentException {
OleAutomation documentsAutomation = null;
int[] id = null;
Variant[] arguments = null;
Variant invokeResult = null;
try {
// Check the the file name is not null
if(fileName == null) {
throw new NullPointerException("Null value passed to " +
"fileName parameters of the openFile() method.");
// Check the the file names ends with '.dot' or '.doc'.
// Remember to include templates and docuemnts
if(!(fileName.endsWith(".doc")) && !(fileName.endsWith(".dot"))) {
throw new IllegalArgumentException(
"The filename must end with the extensions \'.doc\' or \'.dot\'");
// Check that the file exists
File fileToPrint = new File(fileName);
if(!(fileToPrint.exists())) {
throw new FileNotFoundException("The file " +
fileName +
"cannot be found.");
// From the application, get an automation for the Documents property
documentsAutomation = this.getChildAutomation(this.wordAutomation,
"Documents");
// Get the ID of the Open method
id = documentsAutomation.getIDsOfNames(new String[]{"Open"});
if(id == null) {
throw new SWTException("It was not possible to recover an " +
"identifer for the Open method in WordSearchReplace.openFile().");
// Build an array of parameters - holds just the file name
arguments = new Variant[1];
arguments[0] = new Variant(fileName);
// Invoke the Open method on the Documents property
invokeResult = documentsAutomation.invoke(id[0], arguments);
// If the call to invoke the open method failed, throw an SWTException
// to terminate processing.
if(invokeResult == null) {
throw new SWTException("An error occurred whilst invoking the " +
"Open method for the following file: " +
fileName +
" in WordSearchReplace.openFile().");
// If it was possible to open the document successfully, grab an
// automation object referencing the active document here.
else {
this.activeDocumentAutomation = this.getChildAutomation(
this.wordAutomation, "ActiveDocument");
finally {
// If the automation was instantiated then dispose of it to
// release resources. This OleAutomation was only required
// to open the file and can safely be released here.
if(documentsAutomation != null) {
documentsAutomation.dispose();
* Save the currently open file - the active document.
* @throws SWTException if a problem occurs whilst invoking any of the OLE
* methods.
public void save() throws SWTException {
int[] id = null;
Variant invokeResult = null;
// From the automation for the ActiveDocument object, get an id for
// the Save method
id = this.activeDocumentAutomation.getIDsOfNames(new String[]{"Save"});
// If it was not possible to recover the id of the Save
// method, throw an exception to notify the user and terminate
// processing.
if(id == null) {
throw new SWTException("Unable to obtain an automation for " +
"the Save method in WordSearchReplace.save().");
// Invoke the Save method and catch the value returned
invokeResult = this.activeDocumentAutomation.invoke(id[0]);
// If a null value was returned then the invocation of the
// Save method failed. Throw an exception to notify the
// user and terminate processing.
if(invokeResult == null) {
throw new SWTException("A problem occurred invoking the " +
"Save method in WordSearchReplace.save().");
* Save the active document using the name provided.
* @param fileName Am instance of the String class encapsulating the name
* for the file. Again, the path to and name of the file should
* be supplied.
* @throws NullPointerException if a null value is passed to the fileName
* parameter.
* @throws IllegalArgumentException if either an empty String is passed
* to the fileName parameter or if the files name does not end
* with one of the two permissible extensions - .dot and .doc
public void saveAs(String fileName) throws SWTException,
NullPointerException,
IllegalArgumentException {
int[] id = null;
Variant[] arguments = null;
Variant invokeResult = null;
// If the fileName parameter is passed a null
// value, throw an exception.
if(fileName == null) {
throw new NullPointerException("A null value was passed to " +
"the fileName parameter of WordSearchReplace.saveAs().");
// If the fileName parameter has been passed an empty String
// then again throw an exception.
if(fileName.length() == 0) {
throw new NullPointerException("An empty string was passed " +
"to the fileName parameter of WordSearchReplace.saveAs().");
// Finally, make sure the file name ends in either
// .doc or .dot.
if((!fileName.endsWith(".dot")) && (!fileName.endsWith(".doc"))) {
throw new IllegalArgumentException("An illegal file name was " +
"passed to the fileName parameter of " +
"WordSearchReplace.saveAs(). The file name must " +
"end in \'.dot\' or \'.doc\'.");
// From the automation for the ActiveDocument object, get an id for
// the SaveAs method
id = this.activeDocumentAutomation.getIDsOfNames(new String[]{"SaveAs"});
// If it was not possible to recover the id of the SaveAs
// method, throw an exception to notify the user and terminate
// processing.
if(id == null) {
throw new SWTException("Unable to obtain an automation for " +
"the SaveAs method in WordSearchReplace.saveAs().");
// Build the array of arguments that will be passed to the invoke
// method when the SaveAs method is invoked. In this case, this
// array will contain a single member - a String object encapsulating
// the path to and name of the output file.
arguments = new Variant[1];
arguments[0] = new Variant(fileName);
// Invoke the SaveAs method and catch the value returned
invokeResult = this.activeDocumentAutomation.invoke(id[0], arguments);
// If a null value was returned then the invocation of the
// PrintOut method failed. Throw an exception to notify the
// user and terminate processing.
if(invokeResult == null) {
throw new SWTException("A problem occurred invoking the " +
"SaveAs method in WordSearchReplace.saveAs().");
* Mimics Words 'replace' functionality by searching the active
* document for evey string of characters that matches the value passed to
* the searchTerm parameter and replacing them with the string of
* characters passed to the replacementTerm method.
* It is possible to code a VBA macro within Word that will perfrom a serach
* and replace. That code would look like the following;
* <pre>
* Selection.Find.ClearFormatting
* Selection.Find.Replacement.ClearFormatting
* With Selection.Find
* .Text = "serach"
* .Replacement.Text = "search"
* .Forward = True
* .Wrap = wdFindContinue
* .Format = False
* .MatchCase = False
* .MatchWholeWord = False
* .MatchWildcards = False
* .MatchSoundsLike = False
* .MatchAllWordForms = False
* End With
* Selection.Find.Execute Replace:=wdReplaceAll
* <pre>
* and this method will 'automate' it.
* @param searchTerm An instance of the String class that will encapsulate
* the series of characters that should be replaced.
* @param replacementTerm An instance of the String class that will
* encapsulate the series of characters that should replace the
* searchTerm.
* @throws NullPointerException if a null value is passed to either the
* searchTerm or replacementTerm methods.
* @throws SWTException if a problem occurs when invoking any of the
* OLE methods.
public void replace(String searchTerm,
String replacementTerm) throws SWTException,
NullPointerException {
OleAutomation selectionFindAutomation = null;
OleAutomation childAutomation = null;
Variant[] arguments = null;
Variant invokeResult = null;
int[] id = null;
int[] namedArguments = null;
boolean success = true;
// Validate the searchTerm parameter and throw exception if
// null value passed.
if(searchTerm == null) {
throw new NullPointerException("Null value passed to " +
"searchTerm parameter of the replace() method.");
// Validate the replacementTerm parameter and throw exception if
// null value passed.
if(replacementTerm == null) {
throw new NullPointerException("Null value passed to " +
"replacementTerm parameter of the replace() method.");
// Most of the VBA instructions used to perform the search and
// replace functionality and child automations of Selection.Find,
// therefore, it is wise to cache that automation first.
// From the application, get an automation for the Selection property
childAutomation = this.getChildAutomation(this.wordAutomation,
"Selection");
selectionFindAutomation = this.getChildAutomation(childAutomation,
"Find");
// Next, using the cached automation, invoke the 'ClearFormatting'
// method, validate the returned value and invoke the method.
// Selection.Find.ClearFormatting
id = selectionFindAutomation.getIDsOfNames(new String[]{"ClearFormatting"});
if(id == null) {
throw new SWTException("It is not possible to recover an identifier " +
"for the ClearFormatting method in WordSearchReplace.replace() " +
"when clearing the formatting for the search string.");
invokeResult = selectionFindAutomation.invoke(id[0]);
if(invokeResult == null) {
throw new SWTException("A problem occurred invoking the " +
"ClearFormatting method in WordSearchReplace.repace() " +
"when clearing formatting for the search string.");
// Now, perform the same function but for the replacement string.
// Selection.Find.Replacement.ClearFormatting
childAutomation = this.getChildAutomation(selectionFindAutomation,
"Replacement");
id = childAutomation.getIDsOfNames(new String[]{"ClearFormatting"});
if(id == null) {
throw new SWTException("It is not possible to recover an identifier " +
"for the ClearFormatting method in WordSearchReplace.replace() " +
"when clearing the formatting for the replacement string.");
invokeResult = childAutomation.invoke(id[0]);
if(invokeResult == null) {
throw new SWTException("A problem occurred invoking the " +
"ClearFormatting method in WordSearchReplace.repace() " +
"when clearing formatting for the replacement string.");
// Firstly, set the search text.
// .Text = "search term"
arguments = new Variant[1];
arguments[0] = new Variant(searchTerm);
success = this.setPropertyValue(selectionFindAutomation, "Text", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Text " +
"property for the search string in WordSearchReplace.replace().");
// Next, the replacement text
// .Replacement.Text = "replacement term"
childAutomation = this.getChildAutomation(selectionFindAutomation,
"Replacement");
arguments[0] = new Variant(replacementTerm);
success = this.setPropertyValue(childAutomation, "Text", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Text property" +
" for the replacement string in WordSearchReplace.replace().");
// Set the direction of the search - forward in this case.
// .Forward = True
arguments[0] = new Variant(true);
success = this.setPropertyValue(selectionFindAutomation, "Forward", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Forward " +
"property in WordSearchReplace.replace().");
// Tell the search to wrap. Note the literal wdFindContinue relates to
// a constant that is defined within Word. I have provided a static
// final to replace it called WD_FIND_CONTINUE
// .Wrap = wdFindContinue
arguments[0] = new Variant(WordSearchReplace.WD_FIND_CONTINUE);
success = this.setPropertyValue(selectionFindAutomation, "Wrap", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Wrap " +
"property in WordSearchReplace.replace().");
// Set the Format property to False.
// .Format = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "Format", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Format " +
"property in WordSearchReplace.replace().");
// Set the MatchCase property to false.
// .MatchCase = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchCase", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the MatchCase " +
"property in WordSearchReplace.replace().");
// Set the MatchWholeWord property to false.
// .MatchWholeWord = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchWholeWord", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the " +
"MatchWholeWord property in WordSearchReplace.replace().");
// Set the MatchWildCards property to false.
// .MatchWildcards = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchWildCards", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the " +
"MatchWildCards property in WordSearchReplace.replace().");
// Set the MatchSoundsLike property to false.
// .MatchSoundsLike = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchSoundsLike", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the " +
"MatchSoundsLike property in WordSearchReplace.replace().");
// Set the MatchAllWordForms property to false.
// .MatchAllWordForms = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchAllWordForms", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the " +
"MatchAllWordForms property in WordSearchReplace.replace().");
// Invoke the Execute command passing the correct value to the Replace
// parameter. Again, wdReplaceAll is a constant that I have provided
// a ststic final for called WD_REPLACE_ALL
// Selection.Find.Execute Replace:=wdReplaceAll
id = selectionFindAutomation.getIDsOfNames(new String[]{"Execute", "Replace"});
if(id == null) {
throw new SWTException("It was not possible to recover an identifier " +
"for the Execute method in WordSearchReplace.replace().");
arguments = new Variant[1];
arguments[0] = new Variant(WordSearchReplace.WD_REPLACE_ALL);
namedArguments = new int[1];
namedArguments[0] = id[1];
// There was some indication that the invokeNoReply method should
// be used when making this call but no, invoke SEEMS to work well
//selectionFindAutomation.invokeNoReply(id[0], arguments, namedArguments);
invokeResult = selectionFindAutomation.invoke(id[0], arguments, namedArguments);
if(invokeResult == null) {
throw new SWTException("A problem occurred trying to invoke the " +
"Execute method in WordSearchReplace.replace().");
* Close the active document.
* @throws SWTException if a problem is encountered invoking any of the
* OLE methods.
public void closeFile() throws SWTException {
int[] id = null;
Variant[] arguments = null;
Variant invokeResult = null;
try {
// From the OleAutomation referencing the active document, recover
// the id of the Close method.
id = this.activeDocumentAutomation.getIDsOfNames(new String[]{"Close"});
// If it was not possible to recover the id of the Close
// method then throw an exception to notify the user and
// terminate processing.
if(id == null) {
throw new SWTException("It was not possible to recover an " +
"identifier for the Close method in " +
"WordSearchReplace.closeFile().");
// Invoke the Close method on the ActiveDocument automation
invokeResult = this.activeDocumentAutomation.invoke(id[0]);
// If the invocation of the Close method failed, throw an
// exception to notify the user and terminate processing.
if(invokeResult == null) {
throw new SWTException(
"An error occurred invoking the Close method in " +
"WordSearchReplace.closeFile().");
finally {
if(this.activeDocumentAutomation != null) {
this.activeDocumentAutomation.dispose();
* Release resources.
public void dispose() throws SWTException {
try {
// Set the cleaned flag to true. This prevents the method from
// running again if it is called from the finalize() method
this.cleaned = true;
// From the word automation, recover the id of the Quit method
int[] id = this.wordAutomation.getIDsOfNames(new String[]{"Quit"});
// If the id of the Quit method cannot be recovered
// throw an exception - not much good really though.
if(id == null) {
throw new SWTException("Unable to obtain an id for the Quit " +
"property in WordSearchReplace.dispose().");
// Invoke Quit
Variant result = this.wordAutomation.invoke(id[0]);
// If an error occurs during the invocation, throw an exception.
// Again though that exception is of limited value.
if(result == null) {
throw new SWTException("A problem occurred trying to invoke the " +
"Quit method in WordSearchReplace.dispose().");
finally {
// Finally, dispose of the word application automation.
this.wordAutomation.dispose();
* The finalize() method has been over-ridden to ensure that resources
* are correctly released if a WordSearchReplace object is created but
* not disposed of properly before it becomes eligible for garbage
* collection. The cleaned flag is used as acheck to ensure that the
* dispose() method cannot be called more than once.
public void finalize() throws Throwable {
if(!this.cleaned) {
this.dispose();
* Creates and returns a 'child' OleAutomation object. The object model
* employed by Word, Excel and the like, arrange objects, methods and
* properties hierarchically. To invoke a method, it is often necessary
* to iterate through this hierarchy from parent to child and this method
* supports that process.
* @param automation An OleAutomation object that references the parent
* automation.
* @param childName An instance of the String class that encapsulates the
* name of the child automation.
* @throws SWTException if a problem is encountered invoking one or
* other of the OLE methods.
private OleAutomation getChildAutomation(OleAutomation automation,
String childName) throws SWTException {
// Try to recove the unique identifier for the child automation
int[] id = automation.getIDsOfNames(new String[]{childName});
// If the identifier cannot be found then throw an exception to
// terminate processing.
if (id == null) {
throw new SWTException(
"A problem occurred trying to obtain and id for: " +
childName +
"in the getCWhen you call it the first time, it new Shell() constructs a new Display for you (the default).
The second time, it gets the default display, but you are in a different Thread now. Since you have to create your widgets in the UI thread, it gives you that error.
To run code in the UI thread, Display provides two methods:
display.syncexec(..)and
display.asyncexec(...)see
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/swt_threading.htm
for more details. -
SWT Error occured in OSB project
When I import OSB project in workshop and tried to see params in stage "service callout" a get "SWT Error occured" [img src=http://f3.s.qip.ru/56TNXCPS.jpg] and can't see params. If to create in workshop new service callout - everything is ok.
Any idea?
Edited by: 936743 on 25.05.2012 6:19Record about this error in log file
!SESSION 2012-05-25 17:15:24.272 -----------------------------------------------
eclipse.buildId=M20080221-1800
java.version=1.6.0_05
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=ru_RU
Command-line arguments: -os win32 -ws win32 -arch x86
!ENTRY com.bea.workshop.product 1 1 2012-05-25 17:15:40.709
!MESSAGE Using product plugin (com.bea.workshop.product) for feedback reports
!ENTRY org.eclipse.ui 4 0 2012-05-25 17:17:15.123
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:3589)
at org.eclipse.swt.SWT.error(SWT.java:3481)
at org.eclipse.swt.SWT.error(SWT.java:3452)
at org.eclipse.swt.widgets.Widget.error(Widget.java:432)
at org.eclipse.swt.widgets.Control.createHandle(Control.java:602)
at org.eclipse.swt.widgets.Composite.createHandle(Composite.java:235)
at org.eclipse.swt.widgets.Decorations.createHandle(Decorations.java:413)
at org.eclipse.swt.widgets.Shell.createHandle(Shell.java:522)
at org.eclipse.swt.widgets.Control.createWidget(Control.java:618)
at org.eclipse.swt.widgets.Scrollable.createWidget(Scrollable.java:131)
at org.eclipse.swt.widgets.Decorations.createWidget(Decorations.java:421)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:286)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:265)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:218)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:156)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.getTextDimension(TabbedPropertyList.java:709)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.getTabHeight(TabbedPropertyList.java:826)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.computeTabsThatFitInComposite(TabbedPropertyList.java:535)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.computeTopAndBottomTab(TabbedPropertyList.java:863)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.access$25(TabbedPropertyList.java:862)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList$10.controlResized(TabbedPropertyList.java:504)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:221)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:943)
at org.eclipse.swt.widgets.Control.WM_SIZE(Control.java:4302)
at org.eclipse.swt.widgets.Scrollable.WM_SIZE(Scrollable.java:333)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1360)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3743)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2260)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3760)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1235)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2521)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2503)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2499)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2568)
at org.eclipse.swt.layout.FormLayout.layout(FormLayout.java:356)
at org.eclipse.swt.layout.FormLayout.layout(FormLayout.java:284)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1025)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1371)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3743)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2260)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3760)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4374)
at org.eclipse.swt.internal.win32.OS.EndDeferWindowPos(Native Method)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:729)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:695)
at org.eclipse.swt.widgets.Composite.setResizeChildren(Composite.java:901)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1026)
at org.eclipse.swt.widgets.Composite.layout(Composite.java:551)
at org.eclipse.swt.widgets.Composite.layout(Composite.java:509)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.layoutTabs(TabbedPropertyList.java:980)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.computeTopAndBottomTab(TabbedPropertyList.java:897)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.access$25(TabbedPropertyList.java:862)
at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList$10.controlResized(TabbedPropertyList.java:504)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:221)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:943)
at org.eclipse.swt.widgets.Control.WM_SIZE(Control.java:4302)
at org.eclipse.swt.widgets.Scrollable.WM_SIZE(Scrollable.java:333)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1360)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3743)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2260)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3760)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1235)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2521)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2503)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2499)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2568)
at org.eclipse.swt.layout.FormLayout.layout(FormLayout.java:356)
at org.eclipse.swt.layout.FormLayout.layout(FormLayout.java:284)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1025)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1371)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3743)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2260)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3760)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4374)
at org.eclipse.swt.internal.win32.OS.EndDeferWindowPos(Native Method)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:729)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:695)
at org.eclipse.swt.widgets.Composite.setResizeChildren(Composite.java:901)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1375)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3743)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2260)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3760)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1235)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2521)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2503)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2499)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2568)
at org.eclipse.swt.layout.FormLayout.layout(FormLayout.java:356)
at org.eclipse.swt.layout.FormLayout.layout(FormLayout.java:284)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1025)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1371)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3743)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2260)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3760)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.EndDeferWindowPos(Native Method)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:729)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:695)
at org.eclipse.swt.widgets.Composite.setResizeChildren(Composite.java:901)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1375)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3743)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2260)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3760)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1235)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2521)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2503)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2499)
at org.eclipse.swt.layout.FillLayout.layout(FillLayout.java:198)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1025)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1371)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3743)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2260)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3760)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1235)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2521)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2503)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2499)
at org.eclipse.swt.layout.FillLayout.layout(FillLayout.java:198)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1025)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1371)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3743)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2260)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3760)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4374)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1235)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2521)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2503)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2499)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:2568)
at org.eclipse.ui.internal.LayoutPart.setBounds(LayoutPart.java:300)
at org.eclipse.ui.internal.presentations.PresentablePart.setBounds(PresentablePart.java:169)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.layoutContent(PresentablePartFolder.java:129)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.layout(PresentablePartFolder.java:410)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.setBounds(PresentablePartFolder.java:258)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.setBounds(TabbedStackPresentation.java:218)
at org.eclipse.ui.internal.PartStack.setBounds(PartStack.java:1198)
at org.eclipse.ui.internal.LayoutTree.doSetBounds(LayoutTree.java:547)
at org.eclipse.ui.internal.LayoutTree.setBounds(LayoutTree.java:538)
at org.eclipse.ui.internal.LayoutTreeNode.doSetBounds(LayoutTreeNode.java:535)
at org.eclipse.ui.internal.LayoutTree.setBounds(LayoutTree.java:538)
at org.eclipse.ui.internal.LayoutPartSash.widgetSelected(LayoutPartSash.java:276)
at org.eclipse.ui.internal.LayoutPartSash.access$1(LayoutPartSash.java:259)
at org.eclipse.ui.internal.LayoutPartSash$1.widgetSelected(LayoutPartSash.java:62)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
at org.eclipse.swt.widgets.Sash.WM_MOUSEMOVE(Sash.java:380)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3716)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4361)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2265)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3296)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.eclipse_main(Main.java:1148)
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 com.m7.installer.util.NitroxMain$1.run(NitroxMain.java:33)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) -
Org.eclipse.swt.SWTException: Invalid thread access - Action struts
Hi
I�m runing this WordSearchReplace java class that I got here in this forum, and I�m runing it doing search and replace in Ms word document if I run just one time it works ok, but if I run twice i got that erro, I�m runing that java class in my Action on struts.
I don�t know what is occur.
Can you help me?
Thanks
Following the example of call, mistakes and java class.
//======RUNING THE WordSearchReplace JAVA CLASS=========
WordSearchReplace wordSR = null;
try {
String[] v_text = {"#V46#","#V42#"};
String[] v_replace = {"Texto1","Texto2"};
wordSR = new WordSearchReplace();
wordSR.openFile(v_path+v_file_name);
for ( int i=0; i<v_text.length; i++ )
wordSR.replace( v_text, v_replace[i] );
wordSR.save();
wordSR.closeFile();
catch(Exception e) {
System.out.println("Caught: ERRO ao Executar WordSearchReplace " + e.getClass().getName());
System.out.println(e.getMessage());
e.printStackTrace(System.out);
finally {
if(wordSR != null) {
try {
wordSR.dispose();
catch(Exception innerE) {
System.out.println("Caught: " + innerE.getClass().getName());
System.out.println(innerE.getMessage());
innerE.printStackTrace(System.out);
//========ERRO ===========================
17:24:49,093 INFO [STDOUT] Invalid thread access
17:24:49,093 INFO [STDOUT] org.eclipse.swt.SWTException: Invalid thread access
17:24:49,093 INFO [STDOUT] at org.eclipse.swt.SWT.error(SWT.java:3563)
17:24:49,093 INFO [STDOUT] at org.eclipse.swt.SWT.error(SWT.java:3481)
17:24:49,093 INFO [STDOUT] at org.eclipse.swt.SWT.error(SWT.java:3452)
17:24:49,093 INFO [STDOUT] at org.eclipse.swt.widgets.Widget.error(Widget.java:432)
17:24:49,093 INFO [STDOUT] at org.eclipse.swt.widgets.Shell.<init>(Shell.java:274)
17:24:49,093 INFO [STDOUT] at org.eclipse.swt.widgets.Shell.<init>(Shell.java:265)
17:24:49,093 INFO [STDOUT] at org.eclipse.swt.widgets.Shell.<init>(Shell.java:218)
17:24:49,093 INFO [STDOUT] at org.eclipse.swt.widgets.Shell.<init>(Shell.java:156)
17:24:49,093 INFO [STDOUT] at br.com.tryblob.view.WordSearchReplace.<init>(WordSearchReplace.java:38)
17:24:49,093 INFO [STDOUT] at br.com.tryblob.view.WordAction.execute(WordAction.java:70)
17:24:49,093 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
17:24:49,093 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
17:24:49,093 INFO [STDOUT] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
17:24:49,093 INFO [STDOUT] at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
17:24:49,093 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
//====== WordSearchReplace JAVA CLASS=========
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.internal.ole.win32.TYPEATTR;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.OleFunctionDescription;
import org.eclipse.swt.ole.win32.OlePropertyDescription;
import org.eclipse.swt.ole.win32.OleParameterDescription;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.ole.win32.Variant;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
public class WordSearchReplace {
private static final String PROG_ID = "Word.Application";
private static final int WD_REPLACE_ALL = 2;
private static final int WD_FIND_CONTINUE = 1;
private Shell shell = null;
private OleFrame frame = null;
private OleClientSite wordSite = null;
private OleAutomation wordAutomation = null;
private OleAutomation activeDocumentAutomation = null;
private boolean cleaned = false;
* Create a new instance of the WordSearchReplace class.
public WordSearchReplace() {
this.shell = new Shell();
this.frame = new OleFrame(this.shell, SWT.NONE);
this.wordSite = new OleClientSite(this.frame, SWT.NONE, WordSearchReplace.PROG_ID);
this.wordAutomation = new OleAutomation(this.wordSite);
* Open an MS Word file. This is a file whose name ends with the extension
* .doc or .doc and which conforms to the correct format.
* Note; if it is possible to open the named file, an attempt is made
* to cache an OleAutomation object referencing that file which will be
* referred to in future as the active document. Most other methods
* need to capture references to further OleAutomation(s) that have the
* active document as their root.
* @param fileName An instance of the String class that encapsulates the
* path to and name of the file that is to be opened.
* Note; the full path name must be supplied as Word
* will be opening the file and no assumptions can
* safely be made concerning the applications 'home'
* folder.
* @throws NullPointerException if a null value is passed to the fileName
* parameter.
* @throws FileNotFoundException if it is not possible to locate the
* file.
* @throws IllegalArgumentException if the name of the file does not end
* with either the .dot or .doc extensions.
* @throws SWTException if a problem occurs whilst invoking any of the OLE
* methods.
public void openFile(String fileName) throws SWTException,
NullPointerException,
FileNotFoundException,
IllegalArgumentException {
OleAutomation documentsAutomation = null;
int[] id = null;
Variant[] arguments = null;
Variant invokeResult = null;
try {
// Check the the file name is not null
if(fileName == null) {
throw new NullPointerException("Null value passed to " +
"fileName parameters of the openFile() method.");
// Check the the file names ends with '.dot' or '.doc'.
// Remember to include templates and docuemnts
if(!(fileName.endsWith(".doc")) && !(fileName.endsWith(".dot"))) {
throw new IllegalArgumentException(
"The filename must end with the extensions \'.doc\' or \'.dot\'");
// Check that the file exists
File fileToPrint = new File(fileName);
if(!(fileToPrint.exists())) {
throw new FileNotFoundException("The file " +
fileName +
"cannot be found.");
// From the application, get an automation for the Documents property
documentsAutomation = this.getChildAutomation(this.wordAutomation,
"Documents");
// Get the ID of the Open method
id = documentsAutomation.getIDsOfNames(new String[]{"Open"});
if(id == null) {
throw new SWTException("It was not possible to recover an " +
"identifer for the Open method in WordSearchReplace.openFile().");
// Build an array of parameters - holds just the file name
arguments = new Variant[1];
arguments[0] = new Variant(fileName);
// Invoke the Open method on the Documents property
invokeResult = documentsAutomation.invoke(id[0], arguments);
// If the call to invoke the open method failed, throw an SWTException
// to terminate processing.
if(invokeResult == null) {
throw new SWTException("An error occurred whilst invoking the " +
"Open method for the following file: " +
fileName +
" in WordSearchReplace.openFile().");
// If it was possible to open the document successfully, grab an
// automation object referencing the active document here.
else {
this.activeDocumentAutomation = this.getChildAutomation(
this.wordAutomation, "ActiveDocument");
finally {
// If the automation was instantiated then dispose of it to
// release resources. This OleAutomation was only required
// to open the file and can safely be released here.
if(documentsAutomation != null) {
documentsAutomation.dispose();
* Save the currently open file - the active document.
* @throws SWTException if a problem occurs whilst invoking any of the OLE
* methods.
public void save() throws SWTException {
int[] id = null;
Variant invokeResult = null;
// From the automation for the ActiveDocument object, get an id for
// the Save method
id = this.activeDocumentAutomation.getIDsOfNames(new String[]{"Save"});
// If it was not possible to recover the id of the Save
// method, throw an exception to notify the user and terminate
// processing.
if(id == null) {
throw new SWTException("Unable to obtain an automation for " +
"the Save method in WordSearchReplace.save().");
// Invoke the Save method and catch the value returned
invokeResult = this.activeDocumentAutomation.invoke(id[0]);
// If a null value was returned then the invocation of the
// Save method failed. Throw an exception to notify the
// user and terminate processing.
if(invokeResult == null) {
throw new SWTException("A problem occurred invoking the " +
"Save method in WordSearchReplace.save().");
* Save the active document using the name provided.
* @param fileName Am instance of the String class encapsulating the name
* for the file. Again, the path to and name of the file should
* be supplied.
* @throws NullPointerException if a null value is passed to the fileName
* parameter.
* @throws IllegalArgumentException if either an empty String is passed
* to the fileName parameter or if the files name does not end
* with one of the two permissible extensions - .dot and .doc
public void saveAs(String fileName) throws SWTException,
NullPointerException,
IllegalArgumentException {
int[] id = null;
Variant[] arguments = null;
Variant invokeResult = null;
// If the fileName parameter is passed a null
// value, throw an exception.
if(fileName == null) {
throw new NullPointerException("A null value was passed to " +
"the fileName parameter of WordSearchReplace.saveAs().");
// If the fileName parameter has been passed an empty String
// then again throw an exception.
if(fileName.length() == 0) {
throw new NullPointerException("An empty string was passed " +
"to the fileName parameter of WordSearchReplace.saveAs().");
// Finally, make sure the file name ends in either
// .doc or .dot.
if((!fileName.endsWith(".dot")) && (!fileName.endsWith(".doc"))) {
throw new IllegalArgumentException("An illegal file name was " +
"passed to the fileName parameter of " +
"WordSearchReplace.saveAs(). The file name must " +
"end in \'.dot\' or \'.doc\'.");
// From the automation for the ActiveDocument object, get an id for
// the SaveAs method
id = this.activeDocumentAutomation.getIDsOfNames(new String[]{"SaveAs"});
// If it was not possible to recover the id of the SaveAs
// method, throw an exception to notify the user and terminate
// processing.
if(id == null) {
throw new SWTException("Unable to obtain an automation for " +
"the SaveAs method in WordSearchReplace.saveAs().");
// Build the array of arguments that will be passed to the invoke
// method when the SaveAs method is invoked. In this case, this
// array will contain a single member - a String object encapsulating
// the path to and name of the output file.
arguments = new Variant[1];
arguments[0] = new Variant(fileName);
// Invoke the SaveAs method and catch the value returned
invokeResult = this.activeDocumentAutomation.invoke(id[0], arguments);
// If a null value was returned then the invocation of the
// PrintOut method failed. Throw an exception to notify the
// user and terminate processing.
if(invokeResult == null) {
throw new SWTException("A problem occurred invoking the " +
"SaveAs method in WordSearchReplace.saveAs().");
* Mimics Words 'replace' functionality by searching the active
* document for evey string of characters that matches the value passed to
* the searchTerm parameter and replacing them with the string of
* characters passed to the replacementTerm method.
* It is possible to code a VBA macro within Word that will perfrom a serach
* and replace. That code would look like the following;
* <pre>
* Selection.Find.ClearFormatting
* Selection.Find.Replacement.ClearFormatting
* With Selection.Find
* .Text = "serach"
* .Replacement.Text = "search"
* .Forward = True
* .Wrap = wdFindContinue
* .Format = False
* .MatchCase = False
* .MatchWholeWord = False
* .MatchWildcards = False
* .MatchSoundsLike = False
* .MatchAllWordForms = False
* End With
* Selection.Find.Execute Replace:=wdReplaceAll
* <pre>
* and this method will 'automate' it.
* @param searchTerm An instance of the String class that will encapsulate
* the series of characters that should be replaced.
* @param replacementTerm An instance of the String class that will
* encapsulate the series of characters that should replace the
* searchTerm.
* @throws NullPointerException if a null value is passed to either the
* searchTerm or replacementTerm methods.
* @throws SWTException if a problem occurs when invoking any of the
* OLE methods.
public void replace(String searchTerm,
String replacementTerm) throws SWTException,
NullPointerException {
OleAutomation selectionFindAutomation = null;
OleAutomation childAutomation = null;
Variant[] arguments = null;
Variant invokeResult = null;
int[] id = null;
int[] namedArguments = null;
boolean success = true;
// Validate the searchTerm parameter and throw exception if
// null value passed.
if(searchTerm == null) {
throw new NullPointerException("Null value passed to " +
"searchTerm parameter of the replace() method.");
// Validate the replacementTerm parameter and throw exception if
// null value passed.
if(replacementTerm == null) {
throw new NullPointerException("Null value passed to " +
"replacementTerm parameter of the replace() method.");
// Most of the VBA instructions used to perform the search and
// replace functionality and child automations of Selection.Find,
// therefore, it is wise to cache that automation first.
// From the application, get an automation for the Selection property
childAutomation = this.getChildAutomation(this.wordAutomation,
"Selection");
selectionFindAutomation = this.getChildAutomation(childAutomation,
"Find");
// Next, using the cached automation, invoke the 'ClearFormatting'
// method, validate the returned value and invoke the method.
// Selection.Find.ClearFormatting
id = selectionFindAutomation.getIDsOfNames(new String[]{"ClearFormatting"});
if(id == null) {
throw new SWTException("It is not possible to recover an identifier " +
"for the ClearFormatting method in WordSearchReplace.replace() " +
"when clearing the formatting for the search string.");
invokeResult = selectionFindAutomation.invoke(id[0]);
if(invokeResult == null) {
throw new SWTException("A problem occurred invoking the " +
"ClearFormatting method in WordSearchReplace.repace() " +
"when clearing formatting for the search string.");
// Now, perform the same function but for the replacement string.
// Selection.Find.Replacement.ClearFormatting
childAutomation = this.getChildAutomation(selectionFindAutomation,
"Replacement");
id = childAutomation.getIDsOfNames(new String[]{"ClearFormatting"});
if(id == null) {
throw new SWTException("It is not possible to recover an identifier " +
"for the ClearFormatting method in WordSearchReplace.replace() " +
"when clearing the formatting for the replacement string.");
invokeResult = childAutomation.invoke(id[0]);
if(invokeResult == null) {
throw new SWTException("A problem occurred invoking the " +
"ClearFormatting method in WordSearchReplace.repace() " +
"when clearing formatting for the replacement string.");
// Firstly, set the search text.
// .Text = "search term"
arguments = new Variant[1];
arguments[0] = new Variant(searchTerm);
success = this.setPropertyValue(selectionFindAutomation, "Text", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Text " +
"property for the search string in WordSearchReplace.replace().");
// Next, the replacement text
// .Replacement.Text = "replacement term"
childAutomation = this.getChildAutomation(selectionFindAutomation,
"Replacement");
arguments[0] = new Variant(replacementTerm);
success = this.setPropertyValue(childAutomation, "Text", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Text property" +
" for the replacement string in WordSearchReplace.replace().");
// Set the direction of the search - forward in this case.
// .Forward = True
arguments[0] = new Variant(true);
success = this.setPropertyValue(selectionFindAutomation, "Forward", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Forward " +
"property in WordSearchReplace.replace().");
// Tell the search to wrap. Note the literal wdFindContinue relates to
// a constant that is defined within Word. I have provided a static
// final to replace it called WD_FIND_CONTINUE
// .Wrap = wdFindContinue
arguments[0] = new Variant(WordSearchReplace.WD_FIND_CONTINUE);
// System.out.println("jose vieira WD_FIND_CONTINUE:" + arguments[0]);
success = this.setPropertyValue(selectionFindAutomation, "Wrap", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Wrap " +
"property in WordSearchReplace.replace().");
// Set the Format property to False.
// .Format = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "Format", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the Format " +
"property in WordSearchReplace.replace().");
// Set the MatchCase property to false.
// .MatchCase = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchCase", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the MatchCase " +
"property in WordSearchReplace.replace().");
// Set the MatchWholeWord property to false.
// .MatchWholeWord = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchWholeWord", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the " +
"MatchWholeWord property in WordSearchReplace.replace().");
// Set the MatchWildCards property to false.
// .MatchWildcards = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchWildCards", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the " +
"MatchWildCards property in WordSearchReplace.replace().");
// Set the MatchSoundsLike property to false.
// .MatchSoundsLike = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchSoundsLike", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the " +
"MatchSoundsLike property in WordSearchReplace.replace().");
// Set the MatchAllWordForms property to false.
// .MatchAllWordForms = False
arguments[0] = new Variant(false);
success = this.setPropertyValue(selectionFindAutomation, "MatchAllWordForms", arguments);
if(!success) {
throw new SWTException("A problem occurred setting the " +
"MatchAllWordForms property in WordSearchReplace.replace().");
// Invoke the Execute command passing the correct value to the Replace
// parameter. Again, wdReplaceAll is a constant that I have provided
// a ststic final for called WD_REPLACE_ALL
// Selection.Find.Execute Replace:=wdReplaceAll
id = selectionFindAutomation.getIDsOfNames(new String[]{"Execute", "Replace"});
if(id == null) {
throw new SWTException("It was not possible to recover an identifier " +
"for the Execute method in WordSearchReplace.replace().");
arguments = new Variant[1];
arguments[0] = new Variant(WordSearchReplace.WD_REPLACE_ALL);
namedArguments = new int[1];
namedArguments[0] = id[1];
// There was some indication that the invokeNoReply method should
// be used when making this call but no, invoke SEEMS to work well
//selectionFindAutomation.invokeNoReply(id[0], arguments, namedArguments);
invokeResult = selectionFindAutomation.invoke(id[0], arguments, namedArguments);
if(invokeResult == null) {
throw new SWTException("A problem occurred trying to invoke the " +
"Execute method in WordSearchReplace.replace().");
* Close the active document.
* @throws SWTException if a problem is encountered invoking any of the
* OLE methods.
public void closeFile() throws SWTException {
int[] id = null;
Variant[] arguments = null;
Variant invokeResult = null;
try {
// From the OleAutomation referencing the active document, recover
// the id of the Close method.
id = this.activeDocumentAutomation.getIDsOfNames(new String[]{"Close"});
// If it was not possible to recover the id of the Close
// method then throw an exception to notify the user and
// terminate processing.
if(id == null) {
throw new SWTException("It was not possible to recover an " +
"identifier for the Close method in " +
"WordSearchReplace.closeFile().");
// Invoke the Close method on the ActiveDocument automation
invokeResult = this.activeDocumentAutomation.invoke(id[0]);
// If the invocation of the Close method failed, throw an
// exception to notify the user and terminate processing.
if(invokeResult == null) {
throw new SWTException(
"An error occurred invoking the Close method in " +
"WordSearchReplace.closeFile().");
finally {
if(this.activeDocumentAutomation != null) {
this.activeDocumentAutomation.dispose();
* Release resources.
public void dispose() throws SWTException {
try {
// Set the cleaned flag to true. This prevents the method from
// running again if it is called from the finalize() method
this.cleaned = true;
// From the word automation, recover the id of the Quit method
int[] id = this.wordAutomation.getIDsOfNames(new String[]{"Quit"});
// If the id of the Quit method cannot be recovered
// throw an exception - not much good really though.
if(id == null) {
throw new SWTException("Unable to obtain an id for the Quit " +
"property in WordSearchReplace.dispose().");
// Invoke Quit
Variant result = this.wordAutomation.invoke(id[0]);
// If an error occurs during the invocation, throw an exception.
// Again though that exception is of limited value.
if(result == null) {
throw new SWTException("A problem occurred trying to invoke the " +
"Quit method in WordSearchReplace.dispose().");
finally {
// Finally, dispose of the word application automation.
this.wordAutomation.dispose();
* The finalize() method has been over-ridden to ensure that resources
* are correctly released if a WordSearchReplace object is created but
* not disposed of properly before it becomes eligible for garbage
* collection. The cleaned flag is used as acheck to ensure that the
* dispose() method cannot be called more than once.
public void finalize() throws Throwable {
if(!this.cleaned) {
this.dispose();
* Creates and returns a 'child' OleAutomation object. The object model
* employed by Word, Excel and the like, arrange objects, methods and
* properties hierarchically. To invoke a method, it is often necessary
* to iterate through this hierarchy from parent to child and this method
* supports that process.
* @param automation An OleAutomation object that references the parent
* automation.
* @param childName An instance of the String class that encapsulates the
* name of the child automation.
* @throws SWTException if a problem is encountered invoking one or
* other of the OLE methods.
private OleAutomation getChildAutomation(OleAutomation automation,
String childName) throws SWTException {
// Try to recove the unique identifier for the child automation
int[] id = automation.getIDsOfNames(new String[]{childName});
// If the identifier cannot be found then throw an exception to
// terminate processing.
if (id == null) {
throw new SWTException(
"A problem occurred trying to obtain and id for: " +
childName +
"in the getChildAutomation() method.");
// SWT's implementation of OLE referes to all of Words objects, methods
// and properties using the single term 'property'. The next stage
// therefore is to recover a refence to the 'property' that relates
// to the child automation.
Variant pVarResult = automation.getProperty(id[0]);
// If it is not possible to recover a 'property' for the child
// automation, then throw an SWTException.
if (pVarResult == null) {
throw new SWTException(
"A problem occurred trying to obtain an automation for property: " +
id[0] +
" in the getChildAutomation() method.");
// As we are after a child automation in this instance, call the
// getAutomation() method on the 'property'.
return(pVarResult.getAutomation());
* Sets the value of a property.
* @param automation An instance of the OleAutomation class that will
* hold a reference to the properties parent automation object
* @param propertyName An instance of the String class that encapsulates the
* name of the property whose value is to be set.
* @param arguments An array of type Variant whose elements contain the
* values that will be set for the named property.
* @return A primitive boolean value that indicates whether or not the
* properties value was successfully set.
* @throws NullPointerException will be thrown if a null value is passed to
* any of the methods three arguments.
* @throws IllegalArgumentException will be thrown if an empty String
* is passed to the propertyName parameter or if an empty array
* is passed to the arguments parameter. Note, no check is made
* on the vallues of the elements in the arguments array.
* @throws SWTException will be thrown if a problem is encountered
* imvoking any of the OLE methods.
private boolean setPropertyValue(OleAutomation automation,
String propertyName,
Variant[] arguments) throws SWTException,
NullPointerException,
IllegalArgumentException {
// Validate the various parameters
if(automation == null) {
throw new NullPointerException(
"A null value was pasAlright, I'll try to keep it as simple as possible. If that's not going to work out, we can always complicate it later :)
I suppose you had a look at the link and I assume you know about threads.
We can easily fix this issue if you are instantiating, calling and disposing the object within one thread, e.g. you use it only in one method like
public mySwtExecutionMethod(String fileName){
WordSearchReplace replace = new WordSearchReplace();
// do your replacing here
replace.dispose();
// no reference to replace is left so it won't escape this thread
}Now the fix for your class becomes simple. As you remember from the link, you have to call all methods from within the UI thread. We will now create a Display every time upon instantiation of WordSearchReplace, so the current thread becomes the UI thread.
I had a look at the constructor, and the overhead doesn't seem that bad, provided this is not a dedicated search&replace server.
private final Display display;
public WordSearchReplace()
display = new Display(); // create display
this.shell = new Shell(display); // initialize shell with new display so this thread becomes the UI thread
this.frame = new OleFrame(this.shell, SWT.NONE);
this.wordSite = new OleClientSite(this.frame, SWT.NONE, WordSearchReplace.PROG_ID);
this.wordAutomation = new OleAutomation(this.wordSite);
}Since we always create a new Display, we should also dispose it. There is already a dispose() method, so we just have to add to it
display.dispose();That's it!
If you hold on longer to your reference and this isn't working for you, you'd have to do a lot more synchronizing and that the UI thread still exist as long as the reference.
Wish you good luck -
TreeViewer with JFace and SWT ...help!
Hi Guys;
My question is for those familiar with the eclipse platform developement..
I'm trying to implement a File Explorer under The Eclipse platform using the jface and SWT tools...
when i Run the code below it gives me a run time exception:
NoClassDefFound exception...
it seems that the problem resides at the line:
tv.setInput(new File("C:\\"));
if i remove the argument to File "C:\\" i get a blank view with no files..
here is the Code:
Any helpfull ideas would be very welcomed indeed...
import org.eclipse.jface.window.*;
import org.eclipse.swt.widgets.*;
import java.io.*;
import java.util.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.window.*;
import org.eclipse.swt.*;
class FileTreeContentProvider implements ITreeContentProvider
public Object[] getChildren(Object element)
Object[] kids = ((File) element).listFiles();
return kids == null ? new Object[0] : kids;
public Object[] getElements(Object element)
return getChildren(element);
public boolean hasChildren(Object element)
return getChildren(element).length > 0;
public Object getParent(Object element)
return ((File)element).getParent();
public void dispose()
public void inputChanged(Viewer viewer, Object old_input, Object new_input)
class FileTreeLabelProvider extends LabelProvider
public String getText(Object element)
return ((File) element).getName();
public class Standalone extends ApplicationWindow
public Standalone()
super(null);
protected Control createContents(Composite parent)
TreeViewer tv = new TreeViewer(parent);
tv.setContentProvider(new FileTreeContentProvider());
tv.setLabelProvider(new FileTreeLabelProvider());
tv.setInput(new File(" C:\\ "));
return tv.getTree();
public static void main(String[] args)
Standalone w = new Standalone();
w.setBlockOnOpen(true);
w.open();
Display.getCurrent().dispose();This is an old post... but in case anyone wants to know... This tutorial is located at http://www-106.ibm.com/developerworks/opensource/library/os-ecgui1/ and I HIGHLY recommend it for people using Eclipse and wanting to learn how to create a File Explorer with JFace/SWT.
Most likely the error that othmanSilent was getting was the following:
java.lang.NoClassDefFoundError:
org/eclipse/core/internal/boot/DelegatingURLClassLoader
It was pointed out in the eclipse.swt newsgroups quite a few times. The author of the article forgot to also mention that you need to include the following jar file in your Java Build Path: eclipse.core.boot_<eclipse-version>/boot.jar -
Can't display an image with SWT using J9
Hello,
I'm programming a user interface using SWT and J9 as JVM under Window Mobile 5.0
Everything seems to work more or less fine with SWT widgets, but I can't display any Image.
I've tried the following codes :
Image image = new Image(display,getClass().getResourceAsStream("image.bmp"));when placing image.bmp in the same jar that my main class, or in the same folder when not using a jar file.
and
Image image = new Image(display,"\\image.bmp");(when placing image.bmp in the root folder)
I've tried with a gif file, it doesn't work neither.
Both codes work fine in my normal computer (replacing "//image.bmp" by "C://image.bmp" for instance)
Any help would be highly appreciated ;-)
Message was edited by:
cOsiHere is a basic example to display image and make it flicker. Use it and try to improve to get the exact frame rate you want.
Remember this is not the actual solution, its just to give you an idea.
The best solution is the one you find it by yourself
Attachments:
Flicker.vi 8 KB -
I have found information regarding how to embed Swings in SWT.
But i have to embed Swt browser in swings
Please see the links for examples:
http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Bringupabrowser.htm
http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/EmbedSwingandAWTinSWT.htm
I have to show two browsers in same window which i have partially done by embeding swings in swt. but need the otherway.
Here is that code:
import java.awt.Color;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.LocationEvent;
import org.eclipse.swt.browser.LocationListener;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.browser.StatusTextEvent;
import org.eclipse.swt.browser.StatusTextListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
public class BringUpBrowser {
public static void main(String[] args) {
BringUpBrowser browser= new BringUpBrowser();
browser.showBrowser();
public void showBrowser(){
Display display = new Display();
final Shell shell = new Shell(display);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
shell.setLayout(gridLayout);
shell.setMaximized(true);
final Browser browser1 = new Browser(shell, SWT.NONE);
GridData data1 = new GridData();
data1.horizontalAlignment = GridData.FILL;
data1.verticalAlignment = GridData.FILL;
data1.horizontalSpan = 3;
data1.grabExcessHorizontalSpace = true;
data1.grabExcessVerticalSpace = true;
browser1.setLayoutData(data1);
browser1.setUrl("www.indussoftware.com");
ToolBar toolbar = new ToolBar(shell, SWT.NONE);
ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
itemBack.setText("Back");
ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
itemForward.setText("Forward");
ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
itemStop.setText("Stop");
ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
itemRefresh.setText("Refresh");
ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
itemGo.setText("Go");
GridData data = new GridData();
data.horizontalSpan = 3;
toolbar.setLayoutData(data);
Label labelAddress = new Label(shell, SWT.NONE);
labelAddress.setText("Address");
final Text location = new Text(shell, SWT.BORDER);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.horizontalSpan = 2;
data.grabExcessHorizontalSpace = true;
location.setLayoutData(data);
final Browser browser = new Browser(shell, SWT.NONE);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.FILL;
data.horizontalSpan = 3;
data.grabExcessHorizontalSpace = true;
data.grabExcessVerticalSpace = true;
browser.setLayoutData(data);
final Label status = new Label(shell, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
status.setLayoutData(data);
final ProgressBar progressBar = new ProgressBar(shell, SWT.NONE);
data = new GridData();
data.horizontalAlignment = GridData.END;
progressBar.setLayoutData(data);
Composite composite = new Composite(shell, SWT.EMBEDDED);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.CENTER;
data.horizontalSpan = 3;
composite.setLayoutData(data);
Frame frame = SWT_AWT.new_Frame(composite);
JPanel panel = new JPanel();
panel.setLayout(new FormLayout("0:grow(0.4),0:grow(0.2),0:grow(0.4)","5dlu,5dlu,16dlu"));
frame.add(panel);
CellConstraints cc = new CellConstraints();
JButton button = new JButton("Close");
panel.add(new JSeparator(),cc.xyw(1, 1, 3));
panel.add(button,cc.xy(2, 3));
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
//this = null;
//end of chakri
/* event handling */
Listener listener = new Listener() {
public void handleEvent(Event event) {
ToolItem item = (ToolItem) event.widget;
String string = item.getText();
if (string.equals("Back"))
browser.back();
else if (string.equals("Forward"))
browser.forward();
else if (string.equals("Stop"))
browser.stop();
else if (string.equals("Refresh"))
browser.refresh();
else if (string.equals("Go"))
browser.setUrl(location.getText());
browser.addProgressListener(new ProgressListener() {
public void changed(ProgressEvent event) {
if (event.total == 0)
return;
int ratio = event.current * 100 / event.total;
progressBar.setSelection(ratio);
public void completed(ProgressEvent event) {
progressBar.setSelection(0);
browser.addStatusTextListener(new StatusTextListener() {
public void changed(StatusTextEvent event) {
status.setText(event.text);
browser.addLocationListener(new LocationListener() {
public void changed(LocationEvent event) {
if (event.top)
location.setText(event.location);
public void changing(LocationEvent event) {
itemBack.addListener(SWT.Selection, listener);
itemForward.addListener(SWT.Selection, listener);
itemStop.addListener(SWT.Selection, listener);
itemRefresh.addListener(SWT.Selection, listener);
itemGo.addListener(SWT.Selection, listener);
location.addListener(SWT.DefaultSelection, new Listener() {
public void handleEvent(Event e) {
browser.setUrl(location.getText());
shell.open();
browser.setUrl("http://google.co.in");
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
display.dispose();
Here Iam facing problems while adding Listeners.
Can u help me in this?GANGINENI wrote:
hi i developed a program for timer in applet, i want to include it in to jFrame, can some one help me,i am developing program in netbeansYes.
1) ....
h1. Edit:
in light of camickr's note, I am deleting my post. The original poster is now on my DNH list and will remain there until his behavior changes.
Edited by: Encephalopathic on Oct 31, 2008 2:20 PM -
SWT Help?.....
Hi folks,
I am trying to print out using SWT. The application that I have created all shows correctly in Print Preview, but when I press 'Print' I am receiving the following exception:
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:2691)
at org.eclipse.swt.SWT.error(SWT.java(Inlined Compiled Code))
at org.eclipse.swt.SWT.error(SWT.java(Inlined Compiled Code))
at org.eclipse.swt.widgets.Display.error(Display.java(Inlined Compiled Code))
at org.eclipse.swt.widgets.Display.checkDevice(Display.java(Compiled Code))
at org.eclipse.swt.widgets.Display.getSystemColor(Display.java:1530)When I click on the exception, it goes to this line in my code:
g.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));Can anyone please point me in the correct direction as to where I am going wrong?
CheersThanks anyone for looking but I no longer need any help as I have sorted it out,
Cheers. -
SWT:::INVALID THREAD ACCESS
When im tryin to call a method from sum other class .
It throws
org.eclipse.swt.SWTException: Invalid thread access
i know this has to do with ui threadsand we have to wrap the display by SyncEXec......
but im not able to do it,,,
can ne1 help??org.eclipse.swt.widgets.Display.asyncExec(new Runnable() {
public void run() {
// do your stuff here
});if only they'd document these things, eh. it's not like it's all there in the help menu, either..... -
I started up FB 4 today and got this error in my log:
Any ideas good friends?
!SESSION 2009-10-28 12:33:26.601 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_16
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86 -clean -data H:\My Documents\Flash Builder 4 -clean
!ENTRY org.eclipse.update.configurator 4 0 2009-10-28 12:33:30.367
!MESSAGE Unable to find feature.xml in directory: C:\Program Files\Adobe\Adobe Flash Builder Beta 2\features\com.adobe.ide.coldfusion.feature_1.0.0.253229-8LAqPgroE9KlmfZZdDcADiNC
!ENTRY org.eclipse.ui 4 0 2009-10-28 12:34:13.745
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
at org.eclipse.swt.SWT.error(SWT.java:3777)
at org.eclipse.swt.SWT.error(SWT.java:3695)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3800)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3425)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.adobe.flexbuilder.standalone.FlexBuilderApplication.start(FlexBuilderApplication.java :99)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLau ncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.jav a:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
Caused by: java.lang.NullPointerException
at org.eclipse.eclipsemonkey.actions.RecreateMonkeyMenuAction.createTheMenu(RecreateMonkeyMe nuAction.java:118)
at org.eclipse.eclipsemonkey.actions.RecreateMonkeyMenuAction.run(RecreateMonkeyMenuAction.j ava:71)
at org.eclipse.eclipsemonkey.UpdateMonkeyActionsResourceChangeListener$2.run(UpdateMonkeyAct ionsResourceChangeListener.java:256)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133)
... 22 more
!SESSION 2009-10-29 09:05:49.373 -----------------------------------------------
eclipse.buildId=unknownI went and deleted my metadata folder it FB4 stared ok _
-
Hi Muse testers,
This is my first attempt at a mucow widget ... I wanted to provide it in case it was something you might find useful.
I'm sure Adobe will be creating a table widget soon, but I have created this as a way to make an editable table powered by a spreadsheet
The following page provides instructions and a link at end to the beta for people to try out. It's for a three-column table. Feel free to test it out ...
http://ph-tablehopper.businesscatalyst.com/index.html
ThanksOriginally posted by: david_whiteman.oti.com
"Konstantin Scheglov" <[email protected]> wrote in message
news:al1d3t$jag$[email protected]..
> May by you will find something usefull on:
> http://sourceforge.net/projects/eclipsecolorer/
> There are two components for big tables:
> 1. org.eclipse.swt.widgets.TableVirtual for using Windows virtual ListView
> feature. I am not sure about 10 million rows, but it can display fast ten
> thousands rows. (this is what I tested).
I'm surprised you put your TableVirtual class in the org.eclipse.swt.widgets
package. Isn't it considered bad form to add classes to a package that is
owned by others like this? It seems that it would imply TableVirtual was
part of the open source SWT widgets in the eclipse.org repository.
David -
SWT Runs in Eclipse - Not after export (NOT executable JAR)
I have been working on my first SWT application. It will run when using the Eclipse run command. However, when I export the project to a JAR file I can't get the module to run. I am NOT trying to run this as an executable JAR. I will eventually get to that, but for the moment I just want to be able to execute the module via the standard Java command.
When I try to run the module via:
java com.myproj.visual.SearchDisplay I get the following result:
NoClassDefFoundError: org/eclipse/swt/widgets/LayoutI have tried every variation of running this that I can find. I have the swt.jar as well as the jar containing my project files in the class path. I have extracted the DLL files from swt.jar and put them in the directory from which I am executing the module, i.e. I change directory to there before executing the Java command. I tried including the following in the Java command:
-Djava.library.path=c:\projects\java\myproj\swt-win32-3139.dllI have also tried including the classpath at the Java command:
-classpath .;c:\projects\java\myproj\swt.jar;c:\projects\java\myproj\mmstat.jarSo far nothing has helped. I get the same error regardless what I do. Yet this runs fine inside Eclipse.
In my Eclipse environment I do have swt.jar imported. And have org.eclipse.swt in my Require Projects tab on the Build Path. I also have swt.jar and Standard Widget Toolkit identified in the Libraries tab of the Build Path. And on the Order and Export tab I have tried including all three (Standard Widget Toolkit, swt.jar and org.eclipse.swt) and then each one separately and then in combinations.
It is obvious that I am not exporting correctly or I don't have the correct configuration at runtime. But I can not figure this out. I have been reading forums for days now. They mostly are concerned with excecutable JARs which is not yet my problem. I first need to get this working before worrying about packaging an executable.
Can someone please help suggest some solutions for me?
It would be GREATLY appreciated.
Glenn Puckett
Lexington, KYMaking a jar file from SWT project, in Eclipse:
1. Create one manifest file in project with following contents:
Manifest-Version: 1.0
Class-path: swt.jar
Main-class: package.MainClass
2. Export jar file with this manifest file
a) Right-click on project
b) Selection Export
c) Select Java and Jar file
d) Select the project, classpath and file project
e) In jar file textbox enter the name for jar file and select options: "Exports generated class files and resources" and "Compress the content of the jar file"
f) Press Next button
g) Press Next button
h) Select "Use existing manifest from workspace" and select the manifest file which you has created
i) Press Finish button
3. Put togheter the jar file and swt.jar
4. Run jar file
Maybe you are looking for
-
Can I have a different iCloud ID than my iTunes Store ID?
I have an apple id that I use for the iTunes store and share with my kids. I set up iCloud on my iPhone and it used that id. I would like a seperate apple id that I couled use for iClould so I can keep my contacts, reminders, calendars, etc. seperate
-
Recovery Disks won't install to new HD
Hello, all, My laptop froze up last week and wouldn't boot to the OS. Laptop is an HP Pavillion g6-1b60us, running Windows 7. I've tried a number of things, including a new hard drive, the recovery partition, recovery CDs, standard OS install discs,
-
Multiclip Edits Problematic with EDL's (Edit Decision Lists)
Gentlemen, I exported a sample EDL for my on line bay from a multiclip edit from three angles (P2 Card Files) I created and they are seeing the list as one Reel Name instead of the three reel names if I cut it traditionally. I understand a multiclip
-
Cannot connect to Analysis server
Gooday , I am trying to log in to our analysis server using my windows authentications,for some reason i am not able to and i get this error "Cannot Connect to "ServerName\Instance" "The Execute element at line 6, column 60 (namespace urn:schemas-mic
-
./setup_install_server failing with ZFS
I recently upgraded my jumpstart server to 10/08 with ZFS boot. My installation media is located under /export/install/media, where /export/install is a ZFS file system (zpool1/install). I'm trying to add Solaris 9 installation media, but setup_insta