Collecting Exceptions from Threads in ThreadPoolExecutor
Hi,
I have a scenario where I am using a thread pool executor to submit threads. and then, I am waiting at the end for all threads to finish using below code.
threadPoolExecutor.shutdown();
try {
while (!threadPoolExecutor.awaitTermination(1000L, TimeUnit.MILLISECONDS)) {
// awaiting termination of all the threads here.
What I required is, I want to catch the exceptions that are been thrown by one of the threads in ThreadPoolExecutor in my method where I am submitting threads and want to do some processing based on those exceptions.
Is it possible to catch those exceptions that are been thrown by the threads in ThreadPoolExecutor? If so, can some one please let me know how to do that?
Thanks
Pallavi
Here is sample code:
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class sample2 {
ThreadPoolExecutor threadPoolExecutor = null;
public sample2()
super();
threadPoolExecutor = new ThreadPoolExecutor(5,10,5,TimeUnit.MINUTES, new ArrayBlockingQueue(10));
public static void main(String[] args) throws IOException
sample2 s = new sample2();
s.checkThreadPoolExecutor();
System.out.println("I am done with calling all threads- waiting for threads to finish");
s.threadPoolExecutor.shutdown();
try {
while (!s.threadPoolExecutor.awaitTermination(1000L, TimeUnit.MILLISECONDS)) {
// awaiting termination of all the threads here.
catch(Exception e)
System.out.println("Exception while waiting fot threads to finish");
s.threadPoolExecutor.shutdown();
System.out.println("Bye bye");
public class TestThread implements Callable<Integer>
int i =0;
String sample = null;
public TestThread(int i)
this.i = i;
@Override
public Integer call() {
System.out.println("I am thread-"+i + "and sleeping for 1 min");
try
Thread.sleep(1000*5);
catch(InterruptedException ie)
System.out.println("some one woke me up");
try{
String test = sample.substring(0,1);
catch(Exception e)
throw new RuntimeException(e);
return i;
private void checkThreadPoolExecutor()
for(int i = 0; i <10;i++)
testMethod(i);
System.out.println("I am done with i:" + i + " in checkThreadPoolExec");
private void testMethod(int i)
TestThread thread = new TestThread(i);
Future<Integer> future = threadPoolExecutor.submit(thread);
Edited by: Pallavi.Palleti on Feb 17, 2009 7:41 PM
Hi,
some hints for future postings:
- use code-tags when submitting code (tags are available at icon bar at the top of your message editor); this will make your code easier to read given you preserved proper indentation when copying it to your posting
- class names should start with an upper case letter (e.g. "public class Sample2" instead of "public class sample")
- you do not submit "Threads" to an executor, you either submit Runnables or Callables; Threads are pooled inside the executor to execute the Runnables/Callables you submit
As for your question: where exactly do you want to handle the exception? Within your Runnable or when checking the result of the Future? For the second case, Future.get() should throw an ExecutionException if the underlying Runnable/Callable threw an exception.
In general, there is the concept of an UncaughtExceptionHandler that will take care of any execptions that occur and have not been handled by the corresponding implementation.
Bye.
Similar Messages
-
Throw exceptions from threads?
Is it possible to throw exceptions from threads since I can't add the throws statement to the run method I don't know how I could do it...
Any help greatly appriciated!
CyaIs it possible to throw exceptions from threads since
I can't add the throws statement to the run method I
don't know how I could do it...
Any help greatly appriciated!
CyaYou can't throw checked exceptions, because obviously the code responsible for invoking the run() method wouldn't know what to do with it, and you wouldn't be the one to catch them. You can however throw unchecked exceptions (such as those based on RuntimeException). -
How can I pass an exception from one thread to another thread
If I create a new class, that will extends the class Thread, the methode run() can not be use with the statement Throws Exeption .
The question now: Is there any possibility to pass an exception from one thread to another thread?
Thx.It really depends on what you want to do with your exception. Is there some sort of global handler that will process the exceptions in some meaningful way? Unless you have that, there's not much point in throwing an exception in a thread, unless you simply want the stack trace generated.
Presuming that you have a global handler that can catch exceptions, nest your Exception subclass inside a RuntimeException:
public class NestedRuntimeException extends RuntimeException
private final m_nestedException;
public NestedRuntimeException(final Exception originalException)
super("An exception occurred with message: " + originalException.getMessage());
m_nestedException;
public Exception getNestedException()
return m_nestedException;
}Your global handler can catch the NestedRuntimeException or be supplied it to process by the thread group. -
Can i catch an exception from another thread?
hi,guys,i have some code like this:
public static void main(String[] args) {
TimeoutThread time = new TimeoutThread(100,new TimeOutException("超时"));
try{
t.start();
}catch(Exception e){
System.out.println("eeeeeeeeeee");
TimeoutThread will throws an exception when it runs ,but now i can't get "eeeeeeeeeee" from my console when i runs the main bolck code.
i asked this question in concurrent forums,somebody told me that i can't.so ,i think if i can do this from aspect of jvm.
thank you for your help
Edited by: Darryl Burke -- Double post of how to catching exceptions from another thread lockinguser5449747 wrote:
so ,i think if i can do this from aspect of jvm. What does that mean? You think you'll get a different answer in a different forum?
You can't catch exceptions from another thread. It's that easy. You could somehow ensure that exceptions from that other thread are always caught and somehow passed to your thread, but that would be a different thing (you would still be catching the exception on the thread it is originating from, as is the only way).
For example you can use setUncaughtExceptionHandler() on your thread to provide an object that handles an uncaught exceptions (and you could pass that uncaught exception to your other thread in some way). -
Is it possible to throw an exception from run method of a thread?
Is it possible to throw an exception from "run method of a thread"(implemented as runnable implementation)?
Is it advisable to do so?Is it possible to throw an exception from "run method
of a thread"(implemented as runnable
implementation)?Yes, an unchecked one. Runtime exceptions.
Is it advisable to do so?If you mess up it happens automatically. But basically: no. -
RICS0001:Internal Error,unable to process the collected data from the device.
Hi all,
I've got the following error in Inventory Collection: 'RICS0001:Internal Error,unable to process the collected data from the device.'
System is CW LMS 2.6
If I search the web I get the following Cisco document:
http://www.cisco.com/en/US/products/sw/cscowork/ps2073/prod_troubleshooting_guide09186a008036dff2.html
'...in the log directory look for IC_Server.log.'
IC_Server.log:
[ Di Nov 16 15:54:27 CET 2010 ],INFO ,[Thread-25],com.cisco.nm.rmeng.inventory.ics.core.ICSCore,173,Got Async Request, User Name :admin
[ Di Nov 16 15:54:27 CET 2010 ],INFO ,[Thread-25],com.cisco.nm.rmeng.inventory.ics.core.ICSCore,179,Request ID is : 1289919235488
[ Di Nov 16 15:54:27 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.inventory.ics.core.CollectionController,309,Started processing device ID: 3341
[ Di Nov 16 15:54:27 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.util.logger.RMELogger,724,com.cisco.nm.rmeng.util.db.DatabaseConnectionPool,getConnection,59,Inside ICSDatabaseConnection, MAX_COUNT =20
[ Di Nov 16 15:54:28 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.inventory.ics.core.CollectionController,387,Started processing device Name: 9.152.255.101
[ Di Nov 16 15:54:28 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.util.logger.XDILogger,77,com.cisco.nm.xms.xdi.pkgs.SharedInventoryCatIOS.ContainmentAGI_ENTITY_Mib_Non_Modular,g$eval,103,com.cisco.nm.xms.xdi.pkgs.SharedInventoryRouter:ContainmentAGI_ENTITY_Mib_Non_Modular:g$eval:populating ContainmentAG attributes, begins...
[ Di Nov 16 15:54:28 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.util.logger.XDILogger,77,com.cisco.nm.xms.xdi.pkgs.SharedInventoryCatIOS.ContainmentAGI_ENTITY_Mib_Non_Modular,populatingTheChassis,110,com.cisco.nm.xms.xdi.pkgs.SharedInventoryRouter:ContainmentAGI_ENTITY_Mib_Non_Modular:populatingTheChassis:ContainmentAG attributes,collection from the device begins...
[ Di Nov 16 15:54:29 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.util.logger.XDILogger,77,com.cisco.nm.xms.xdi.pkgs.SharedInventoryCatIOS.ContainmentAGI_ENTITY_Mib_Non_Modular,populatingTheChassis,147,com.cisco.nm.xms.xdi.pkgs.SharedInventoryRouter:ContainmentAGI_ENTITY_Mib_Non_Modular:populatingTheChassis:ContainmentAG attributes,collection from the device successful...
[ Di Nov 16 15:54:29 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.util.logger.XDILogger,77,com.cisco.nm.xms.xdi.pkgs.SharedInventoryCatIOS.ContainmentAGI_ENTITY_Mib_Non_Modular,populatingTheChassis,149,com.cisco.nm.xms.xdi.pkgs.SharedInventoryRouter:ContainmentAGI_ENTITY_Mib_Non_Modular:populatingTheChassis:ContainmentAG attributes,population begins...
[ Di Nov 16 15:54:29 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.util.logger.XDILogger,77,com.cisco.nm.xms.xdi.pkgs.SharedInventoryCatIOS.ContainmentAGI_ENTITY_Mib_Non_Modular,populatingTheChassis,216,com.cisco.nm.xms.xdi.pkgs.SharedInventoryRouter:ContainmentAGI_ENTITY_Mib_Non_Modular:populatingTheChassis:Before method getSlotsConfiguredStatistics
[ Di Nov 16 15:54:29 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.util.logger.XDILogger,77,com.cisco.nm.xms.xdi.pkgs.SharedInventoryCatIOS.ContainmentAGI_ENTITY_Mib_Non_Modular,populatingTheChassis,225,com.cisco.nm.xms.xdi.pkgs.SharedInventoryRouter:ContainmentAGI_ENTITY_Mib_Non_Modular:populatingTheChassis:After method getSlotsConfiguredStatistics
[ Di Nov 16 15:54:29 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.util.logger.XDILogger,77,com.cisco.nm.xms.xdi.pkgs.SharedInventoryCatIOS.ContainmentAGI_ENTITY_Mib_Non_Modular,populatingTheChassis,245,com.cisco.nm.xms.xdi.pkgs.SharedInventoryRouter:ContainmentAGI_ENTITY_Mib_Non_Modular:populatingTheChassis:ContainmentAG attributes,population completed...
[ Di Nov 16 15:54:29 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.util.logger.XDILogger,77,com.cisco.nm.xms.xdi.pkgs.SharedInventoryCatIOS.ContainmentAGI_ENTITY_Mib_Non_Modular,g$eval,105,com.cisco.nm.xms.xdi.pkgs.SharedInventoryRouter:ContainmentAGI_ENTITY_Mib_Non_Modular:g$eval:populating ContainmentAG attributes, ends...
[ Di Nov 16 15:54:43 CET 2010 ],INFO ,[Thread-14],com.cisco.nm.rmeng.inventory.ics.core.CollectionController,477,DP time is 15 seconds for 9.152.255.101
[ Di Nov 16 15:54:44 CET 2010 ],ERROR,[Thread-14],com.cisco.nm.rmeng.util.logger.RMELogger,770,com.cisco.nm.rmeng.inventory.ics.invchange.AddInvChange,effect,33,Unexpected error :com.sybase.jdbc2.jdbc.SybSQLException: ASA Fehler -193: Primärschlüssel für Tabelle 'PhysicalElement' ist nicht eindeutig
at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2834)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2156)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:220)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:203)
at com.sybase.jdbc2.jdbc.SybStatement.executeLoop(SybStatement.java:1766)
at com.sybase.jdbc2.jdbc.SybStatement.execute(SybStatement.java:1758)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.execute(SybPreparedStatement.java:619)
at com.cisco.nm.rmeng.inventory.ics.dbrep.DBRecord.insert(DBRecord.java:50)
at com.cisco.nm.rmeng.inventory.ics.util.ICSDatabaseConnection.insert(ICSDatabaseConnection.java:91)
at com.cisco.nm.rmeng.inventory.ics.invchange.AddInvChange.effect(AddInvChange.java:29)
at com.cisco.nm.rmeng.inventory.ics.server.InvDataProcessor.processInvData(InvDataProcessor.java:394)
at com.cisco.nm.rmeng.inventory.ics.core.CollectionController.run(CollectionController.java:849)
at java.lang.Thread.run(Thread.java:534)
[ Di Nov 16 15:54:44 CET 2010 ],ERROR,[Thread-14],com.cisco.nm.rmeng.inventory.ics.server.InvDataProcessor,448,ASA Fehler -193: Primärschlüssel für Tabelle 'PhysicalElement' ist nicht eindeutig
com.sybase.jdbc2.jdbc.SybSQLException: ASA Fehler -193: Primärschlüssel für Tabelle 'PhysicalElement' ist nicht eindeutig
at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2834)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2156)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:220)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:203)
at com.sybase.jdbc2.jdbc.SybStatement.executeLoop(SybStatement.java:1766)
at com.sybase.jdbc2.jdbc.SybStatement.execute(SybStatement.java:1758)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.execute(SybPreparedStatement.java:619)
at com.cisco.nm.rmeng.inventory.ics.dbrep.DBRecord.insert(DBRecord.java:50)
at com.cisco.nm.rmeng.inventory.ics.util.ICSDatabaseConnection.insert(ICSDatabaseConnection.java:91)
at com.cisco.nm.rmeng.inventory.ics.invchange.AddInvChange.effect(AddInvChange.java:29)
at com.cisco.nm.rmeng.inventory.ics.server.InvDataProcessor.processInvData(InvDataProcessor.java:394)
at com.cisco.nm.rmeng.inventory.ics.core.CollectionController.run(CollectionController.java:849)
at java.lang.Thread.run(Thread.java:534)
[ Di Nov 16 15:54:44 CET 2010 ],ERROR,[Thread-14],com.cisco.nm.rmeng.inventory.ics.core.CollectionController,861, Exception occured in process method while processing: 9.152.255.101 ASA Fehler -193: Primärschlüssel für Tabelle 'PhysicalElement' ist nicht eindeutig
ICSException :: ASA Fehler -193: Primärschlüssel für Tabelle 'PhysicalElement' ist nicht eindeutig
at com.cisco.nm.rmeng.inventory.ics.server.InvDataProcessor.processInvData(InvDataProcessor.java:463)
at com.cisco.nm.rmeng.inventory.ics.core.CollectionController.run(CollectionController.java:849)
at java.lang.Thread.run(Thread.java:534)
I don't know where the German error message comes from. The whole system is English. Translation is: "ASA error -192: primary key for table 'PhysicalElement' isn't distinct'
Thanks for your help!
AlexWell known issue in LMS 2.6. Most likely you are hitting CSCsm97530. As a temporary solution you could remove and re-add problematic device from CS. To get a permanent fix you need a patch (provided by TAC).
-
Exception in thread "AWT-EventQueue-0
I am receiving the [Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException] from my code.
a button press triggers this exception, the thing is, the press of the button executes some xqueries and does not have any potential null variables. the variables used on the xquery are taken from a combox and are not null.
the error message iam getting is
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at wizard.Wizard1.jButton2ActionPerformed(Wizard1.java:2915)
at wizard.Wizard1.access$3400(Wizard1.java:54)
at wizard.Wizard1$35.actionPerformed(Wizard1.java:2663)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
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)my code on the button is
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try {
String minorfunctionality;
String majorfunctionality;
String roomstyle;
String floortype;
String driver = "org.exist.xmldb.DatabaseImpl";
Class cl = Class.forName(driver);
Database database = (Database) cl.newInstance();
DatabaseManager.registerDatabase(database);
Collection col = DatabaseManager.getCollection("xmldb:exist://localhost:8080/exist/xmlrpc/db/XMLroom","admin","");
XPathQueryService service = (XPathQueryService) col.getService("XPathQueryService", "1.0");
service.setProperty("indent", "yes");
XMLResource document = (XMLResource)col.createResource("Example 1", "XMLResource");
String path2= "C:\\Configuration\\XML_29_4_09.xml";
File f2 = new File(path2);
if(!f2.canRead()) {
System.out.println("cannot read file " + path2 );
return;
document.setContent(f2);
System.out.print("storing document " + document.getId() + "...");
col.storeResource(document);
majorfunctionality = jComboBox1.getSelectedItem().toString();
minorfunctionality = jComboBox2.getSelectedItem().toString();
floortype = jComboBox15.getSelectedItem().toString();
roomstyle = jComboBox3.getSelectedItem().toString();
ResourceSet result = service.query(" update replace doc('XML_29_4_09.xml')//functionality/MajorFunctionality with <MajorFunctionality>" + majorfunctionality + "</MajorFunctionality>");
ResourceSet result2 = service.query(" update replace doc('XML_29_4_09.xml')//functionality/MinorFunctionality with <MinorFunctionality>" + minorfunctionality + "</MinorFunctionality>");
ResourceSet result3 = service.query(" update replace doc('XML_29_4_09.xml')//room/style with <style>" + roomstyle + "</style>");
ResourceSet result4 = service.query(" update replace doc('XML_29_4_09.xml')//floor/material/texture with <texture>" + floortype + "</texture>");
ResourceIterator i = result.getIterator();
while (i.hasMoreResources()) {
Resource r = i.nextResource();
System.out.println((String) r.getContent());
} catch (XMLDBException ex) {
Logger.getLogger(Wizard1.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(Wizard1.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Wizard1.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Wizard1.class.getName()).log(Level.SEVERE, null, ex);
}any ideas why im getting this? thank you in advance.ok , in line 2915
XPathQueryService service = (XPathQueryService) col.getService("XPathQueryService", "1.0");this declaration is standard when writing an xquery.
and col has been declared before this line
Collection col = DatabaseManager.getCollection("xmldb:exist://localhost:8080/exist/xmlrpc/db/XMLroom","admin",""); -
Hello,
From time to time I am getting unhandled exceptions from ESP (5.1 v4 using .NET interface). This is happening only for the high rates of updates (300 records/s). ESP is dying internally, I am not even able to catch exception.
That is the exception from .NET Runtime:
Application: AvidPublisher.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException Stack: at .SYBASE.Esp.SDK.EspPublisher.publish(SYBASE.Esp.SDK.EspPublisher*, SYBASE.Esp.SDK.EspPublishable*, SYBASE.Esp.SDK.EspError*) at SYBASE.Esp.SDK.NetEspPublisher.publish(SYBASE.Esp.SDK.NetEspMessageWriter, SYBASE.Esp.SDK.NetEspError) at FXDerivatives.Common.StreamingPlatform.EspHelper.Publish(System.String, System.Object[][], Int32) at FXDerivatives.Common.StreamingPlatform.EspHelper.PublishToStream(System.String, System.Collections.Generic.IEnumerable`1, Int32, PublishMode) at FXDerivatives.Common.Aleri.AleriLogWriter.PublishToAleri(System.String, System.String, System.String, FXDerivatives.Common.Aleri.AleriLogLevel, System.String, System.String, System.Collections.Generic.Dictionary`2) at FXDerivatives.Common.Aleri.AleriLogWriter.Write(FXDerivatives.Common.Aleri.AleriLogLevel, System.String, System.String, System.Collections.Generic.Dictionary`2) at FXDerivatives.Common.Aleri.AleriLogWriter.Write(FXDerivatives.Common.Aleri.AleriLogLevel, System.String, System.String, FXDerivatives.Common.MarketData.CurrencyPair, System.String) at AvidPublisher.Publishers.Publisher.LogToAleri(FXDerivatives.Common.Aleri.AleriLogLevel, System.String, System.String, System.String, System.String) at AvidPublisher.Publishers.Publisher.PublishAll(System.String, System.String, System.Collections.Generic.Dictionary`2) at AvidPublisher.Publishers.Publisher+<>c__DisplayClass2.b__0(System.Object, System.Collections.Generic.Dictionary`2) at FXDerivatives.Common.Utility.Bundler`2+DistributeEventHandler[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Invoke(System.Object, System.Collections.Generic.Dictionary`2) at FXDerivatives.Common.Utility.Bundler`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].DistributeEvents(System.Object, System.Timers.ElapsedEventArgs) at System.Timers.Timer.MyTimerCallback(System.Object) at System.Threading.TimerQueueTimer.CallCallbackInContext(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.TimerQueueTimer.CallCallback() at System.Threading.TimerQueueTimer.Fire() at System.Threading.TimerQueue.FireNextTimers() at System.Threading.TimerQueue.AppDomainTimerCallback()
That is the Applciation error:
Faulting application name: AvidPublisher.exe, version: 0.0.0.0, time stamp: 0x54083da6 Faulting module name: MSVCR100.dll, version: 10.0.40219.1, time stamp: 0x4d5f0c22 Exception code: 0xc0000005 Fault offset: 0x00010a5d Faulting process id: 0xd78 Faulting application start time: 0x01cfc82a6a680ae9 Faulting application path: D:\FXDeriv\Apps\AvidPublisher\AvidPublisher.exe Faulting module path: C:\Windows\system32\MSVCR100.dll Report Id: 48d4d149-341f-11e4-ae8a-0050569a4c0f
Can you please advise? Are you experiencing similar problems?Pardon, if I wasn't clear. there are many types of applications that are actually failing, so there is no specific scenario. I have around 20 separate applications which are listening for changes and 1 aplication which copy all data from Aleri to ESP. This app never fails, as it is basically publishing around 15 different datatables sequentially. But those 20 separate applications are failing randomly when trying to consume data, and then save data back to ESP if required. there is 1 more place when application is failing, when different threads are subscribing to stream, and ESP crashes when we call: _subscriber.connect(espError);
-
Exception in thread "main" java.rmi.NotBoundException: commandService
Hello,
I want to deploy two SNs on one machine, and I chose different port(5030,5031), when I run "runadmin", the exceptions happened.
[sunyao@datanode1:~/oracle_nosql/tools]$ jps -m
25392 Jps -m
25145 kvstore-1.2.123.jar start -root KVROOT_2
23099 kvstore-1.2.123.jar start -root KVROOT
23265 ManagedService -root KVROOT/mystore/sn2 -store mystore -class RepNode -service rg1-rn2
25220 ManagedService -root KVROOT_2/mystore2/sn1 -store mystore2 -class Admin -service admin1
[sunyao@datanode1:~/oracle_nosql/tools]$ java -jar kv-1.2.123/lib/kvstore-1.2.123.jar ping -port 5030 -host datanode1
SNA at hostname: datanode1 registry port: 5030 has no available Admins or RNs registered.
[sunyao@datanode1:~/oracle_nosql/tools]$ java -jar kv-1.2.123/lib/kvstore-1.2.123.jar runadmin -port 5030 -host datanode1
Exception in thread "main" java.rmi.NotBoundException: commandService
at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:106)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at oracle.kv.impl.util.registry.RegistryUtils.getAdmin(RegistryUtils.java:197)
at oracle.kv.impl.admin.client.KVAdmin.connect(KVAdmin.java:883)
at oracle.kv.impl.admin.client.KVAdmin.main(KVAdmin.java:2131)
at oracle.kv.impl.util.KVStoreMain$6.run(KVStoreMain.java:188)
at oracle.kv.impl.util.KVStoreMain.main(KVStoreMain.java:319)hi ,
I have started two admin service in one group:
but one admin service can't access from 5001, and the log is below:
[sunyao@datanode1:~/oracle_nosql/tools/KVROOT/mystore/log]$ cat admin2_0.log
02-09-12 17:48:46:696 CST INFO [admin2] Starting service process: admin2, Java command line arguments: [-XX:+DisableExplicitGC, -Xms96M, -Xmx96M]
02-09-12 17:48:46:720 CST INFO [admin2] Starting AdminService
02-09-12 17:48:46:881 CST INFO [admin2] Initializing Admin for store: mystore
02-09-12 17:48:46:883 CST INFO [admin2] Created new admin environment dir: KVROOT/mystore/sn2/admin2/env
02-09-12 17:48:46:884 CST INFO [admin2] JVM Runtime maxMemory (bytes): 96468992
02-09-12 17:48:46:889 CST INFO [admin2] Non-default JE properties for environment: {je.rep.vlsn.logCacheSize=128, je.rep.envUnknownStateTimeout=10 s, je.tree.maxDelta=10, je.log.faultReadSize=4096, je.rep.vlsn.distance=1000000, je.env.runEvictor=true, je.cleaner.minUtilization=40, je.rep.replicaAckTimeout=5 s, je.cleaner.threads=2, je.evictor.lruOnly=false, je.rep.replayMaxOpenDbHandles=100, je.log.writeQueueSize=2097152, je.evictor.criticalPercentage=105, je.log.iteratorReadSize=1048576, je.log.numBuffers=16, je.nodeMaxEntries=128, je.evictor.nodesPerScan=200, je.rep.preHeartbeatTimeoutMs=5000000000, je.checkpointer.bytesInterval=200000000, je.cleaner.lazyMigration=false, je.txn.durability=write_no_sync,write_no_sync,simple_majority, je.cleaner.readSize=1048576, je.rep.txnRollbackLimit=10, je.log.fileCacheSize=2000, je.log.fileMax=1073741824}
02-09-12 17:48:48:390 CST INFO [admin2] State change event: Thu Feb 09 17:48:47 CST 2012, State: REPLICA, Master: 1
02-09-12 17:48:48:852 CST INFO [admin2] Shutting down monitor collector
02-09-12 17:48:48:853 CST INFO [admin2] Replicated environment handle established. Cache size: 57881395, State: REPLICA
02-09-12 17:48:48:854 CST INFO [admin2] Starting Command service on rmi://datanode1:5000/commandService
02-09-12 17:48:48:950 CST INFO [admin2] Starting Web service on port 5001
02-09-12 17:48:49:183 CST INFO [admin2] jetty-7.4.0.v20110414
02-09-12 17:48:49:350 CST INFO [admin2] Extract jar:file:/home/sunyao/oracle_nosql/tools/kv-1.2.123/lib/kvstore-1.2.123.jar!/war/KVAdminUI/ to /tmp/jetty-0.0.0.0-5001-KVAdminUI-_-any-/webapp
02-09-12 17:48:50:65 CST INFO [admin2] NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
02-09-12 17:48:50:120 CST INFO [admin2] started o.e.j.w.WebAppContext{,file:/tmp/jetty-0.0.0.0-5001-KVAdminUI-_-any-/webapp/},jar:file:/home/sunyao/oracle_nosql/tools/kv-1.2.123/lib/kvstore-1.2.123.jar!/war/KVAdminUI
02-09-12 17:48:50:201 CST INFO [admin2] Started [email protected]:5001 STARTING
02-09-12 17:48:50:203 CST INFO [admin2] Started AdminService
02-09-12 17:49:04:408 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 17:49:24:427 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 17:49:28:432 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 17:52:16:974 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 17:52:29:844 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 17:54:03:343 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 18:00:48:854 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 18:02:10:25 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 18:02:55:400 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 18:02:59:708 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 18:03:02:127 CST INFO [admin2] Redirect to master at http://namenode:5001
02-09-12 18:03:05:644 CST INFO [admin2] Redirect to master at http://namenode:5001
namenode is the hostname of 192.168.7.200, and I can access the admin service from http://192.168.7.200:5001
and the topology is
Pinging components of store mystore based upon topology sequence #612
mystore comprises 300 partitions and 3 Storage Nodes
Storage Node [sn1] on namenode:5000 Datacenter: Boston [dc1] Status: RUNNING Ver: 11gR2.1.2.123
Rep Node [rg1-rn1] Status: RUNNING,REPLICA at sequence number: 625 haPort: 5011
Storage Node [sn2] on datanode1:5000 Datacenter: Boston [dc1] Status: RUNNING Ver: 11gR2.1.2.123
Rep Node [rg1-rn2] Status: RUNNING,REPLICA at sequence number: 625 haPort: 5010
Storage Node [sn3] on datanode2:5000 Datacenter: Boston [dc1] Status: RUNNING Ver: 11gR2.1.2.123
Rep Node [rg1-rn3] Status: RUNNING,MASTER at sequence number: 625 haPort: 5010
Edited by: 912068 on 2012-2-9 上午2:06
and when I shutdown namenode SN and admin service , and access 185:5001, the exceptions are belowed:
Error
Dismiss
The Admin instance is unable to service this request, as it is not the master Admin instance. Furthermore, its state is such that it does not know the master Admin's forwarding address.
Edited by: 912068 on 2012-2-9 上午2:24 -
Collect data from User workflow error updating list item
Hi, can someone please help me with WSS 3 workflows?!
I'll keep it simple - I have a workflow step "Collect data from user" that will fail with Unknown Error when attempting to update list item (this is after the user has clicked Complete Task). The workflow does not continue past this step and I have
to terminate the workflow.
What is odd, is that if I do another Collect data from User in the same step but following the 1st collect, both will work!! How can this be?? This proves the 1st collect is OK so why won't it run without another Collect data after it?! Doesn't make sense to
me.
I was just trying the second Collect to troubleshoot the issue. I've tried other actions there but having another Collect does seem to be the action that kicks things into life. Is there a clue here?
Any clues would be much appreciated as I'm not able to turn much up when I Google.
ThanksWell, surprise, surprise, this has come back (thought it might!). The trace logs show it's a task locked error but I can't see how. Can anyone please provide me with some clues??
03/14/2014 12:30:25.11 w3wp.exe (0x7698) 0x5EA4 Windows SharePoint
Services Web Controls 88wy Medium SPDataSourceView.ExecuteSelect()
- selectArguments: IsEmpty=True, MaximumRows=0, RetrieveTotalRowCount=False, SortExpression=, StartRowIndex=0, TotalRowCount=-1
03/14/2014 12:30:28.39 w3wp.exe (0x7698) 0x6C4C Windows SharePoint Services
Web Controls 88wy Medium SPDataSourceView.ExecuteSelect() - selectArguments:
IsEmpty=True, MaximumRows=0, RetrieveTotalRowCount=False, SortExpression=, StartRowIndex=0, TotalRowCount=-1
03/14/2014 12:30:28.47 w3wp.exe (0x7698) 0x6C4C Windows SharePoint Services
Web Controls 88wy Medium SPDataSourceView.ExecuteSelect() - selectArguments:
IsEmpty=True, MaximumRows=0, RetrieveTotalRowCount=False, SortExpression=, StartRowIndex=0, TotalRowCount=-1
03/14/2014 12:30:29.86 w3wp.exe (0x7698) 0x7A94 Windows SharePoint Services
Workflow Infrastructure 72er Medium Microsoft.SharePoint.SPException: This task is currently locked by a running workflow and cannot
be edited. at Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(Guid newGuidOnAdd, SPWeb web, Boolean bMigration, Boolean& bAdd, Boolean& bPublish, Object& objAttachmentNames, Object& objAttachmentContents, Int32&
parentFolderId) at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean
suppressAfterEvents) at Microsoft.SharePoint.SPListItem.Update() at Microsoft.SharePoint.Workflow.SPWinOEWSSService.CommitUpdateListItem(Transaction txn, Object[] transData)
03/14/2014 12:30:29.86 w3wp.exe (0x7698) 0x7A94 Windows SharePoint Services
Workflow Infrastructure 72fe High Error in commiting pending workflow batch items: Microsoft.SharePoint.SPException: This
task is currently locked by a running workflow and cannot be edited. at Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(Guid newGuidOnAdd, SPWeb web, Boolean bMigration, Boolean& bAdd, Boolean& bPublish, Object& objAttachmentNames,
Object& objAttachmentContents, Int32& parentFolderId) at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion,
Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents) at Microsoft.SharePoint.SPListItem.Update() at Microsoft.SharePoint.Workflow.SPWinOEWSSService.CommitUpdateListItem(Transaction txn, Object[]
transData) at Micro...
03/14/2014 12:30:29.86* w3wp.exe (0x7698) 0x7A94 Windows SharePoint Services
Workflow Infrastructure 72fe High ...soft.SharePoint.Workflow.SPPendingWork.PerformWorkNow(Transaction txn)
at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.Commit(Transaction transaction, ICollection items)
03/14/2014 12:30:30.05 w3wp.exe (0x7698) 0x7A94 Windows SharePoint Services
Workflow Infrastructure 88xr Unexpected WinWF Internal Error, terminating workflow Id# 2dc6002d-9f9d-474f-84cf-329025347ec5
03/14/2014 12:30:30.05 w3wp.exe (0x7698) 0x7A94 Windows SharePoint Services
Workflow Infrastructure 98d4 Unexpected System.Workflow.Runtime.Hosting.PersistenceException: This task is currently locked by a running workflow
and cannot be edited. ---> Microsoft.SharePoint.SPException: This task is currently locked by a running workflow and cannot be edited. at Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(Guid newGuidOnAdd, SPWeb web, Boolean
bMigration, Boolean& bAdd, Boolean& bPublish, Object& objAttachmentNames, Object& objAttachmentContents, Int32& parentFolderId) at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion,
Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents) at Microsoft.SharePoint.SPListItem.Update() at Microsoft.SharePoint.Workflow.SPWi...
03/14/2014 12:30:30.05* w3wp.exe (0x7698) 0x7A94 Windows SharePoint Services
Workflow Infrastructure 98d4 Unexpected ...nOEWSSService.CommitUpdateListItem(Transaction txn, Object[] transData) at
Microsoft.SharePoint.Workflow.SPPendingWork.PerformWorkNow(Transaction txn) at Microsoft.SharePoint.Workflow.SPPendingWorkBatch.Commit(Transaction transaction, ICollection items) at System.Workflow.Runtime.WorkBatch.PendingWorkCollection.Commit(Transaction
transaction) at System.Workflow.Runtime.WorkBatch.Commit(Transaction transaction) at System.Workflow.Runtime.Hosting.WorkflowCommitWorkBatchService.CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback)
at System.Workflow.Runtime.Hosting.DefaultWorkflowCommitWorkBatchService.CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) at System.Workflow.Runtime.WorkflowExecutor.CommitTransaction(Activity activityContext)
03/14/2014 12:30:30.05* w3wp.exe (0x7698) 0x7A94 Windows SharePoint Services
Workflow Infrastructure 98d4 Unexpected ... at System.Workflow.Runtime.WorkflowExecutor.Persist(Activity dynamicActivity, Boolean
unlock, Boolean needsCompensation) --- End of inner exception stack trace --- at System.Workflow.Runtime.WorkflowExecutor.Persist(Activity dynamicActivity, Boolean unlock, Boolean needsCompensation)
at System.Workflow.Runtime.WorkflowExecutor.System.Workflow.ComponentModel.IWorkflowCoreRuntime.PersistInstanceState(Activity activity) at System.Workflow.ComponentModel.Activity.MarkClosed() at System.Workflow.ComponentModel.Activity.ReleaseLockOnStatusChange(IActivityEventListener`1
eventListener) at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.SafeReleaseLockOnStatusChange(ActivityExecutionContext context) at System.Workflow.ComponentModel.FaultAndCancella...
03/14/2014 12:30:30.05* w3wp.exe (0x7698) 0x7A94 Windows SharePoint Services
Workflow Infrastructure 98d4 Unexpected ...tionHandlingFilter.OnEvent(Object sender, ActivityExecutionStatusChangedEventArgs e)
at System.Workflow.ComponentModel.ActivityExecutorDelegateInfo`1.ActivityExecutorDelegateOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime) at System.Workflow.Runtime.Scheduler.Run()
03/14/2014 12:30:30.38 w3wp.exe (0x7698) 0x6C9C Windows SharePoint Services
General 0 Unexpected ERROR: request not found
in the TrackedRequests. We might be creating and closing webs on different threads. ThreadId = 59, Free call stack = at Microsoft.SharePoint.SPRequestManager.Release(SPRequest request) at Microsoft.SharePoint.SPWeb.Invalidate()
at Microsoft.SharePoint.SPWeb.Close() at Microsoft.SharePoint.SPSite.Close() at Microsoft.SharePoint.SPSite.Dispose() at Microsoft.SharePoint.Workflow.SPWorkflowManager.RunWorkflow(SPWorkflow
workflow, Collection`1 events, SPRunWorkflowOptions runOptions) at Microsoft.SharePoint.Workflow.SPWorkflowManager.RunWorkflow(SPWorkflow workflow, Collection`1 events) at Microsoft.SharePoint.Workflow.SPWinOEItemEventReceiver.RouteWorkflowEvent(SPItemEventProperties
properties, SPWeb web, SPListItem item, Boolean fNeedTas...
03/14/2014 12:30:30.38* w3wp.exe (0x7698) 0x6C9C Windows SharePoint Services
General 0 Unexpected ...kReset)
at Microsoft.SharePoint.Workflow.SPWinOEItemEventReceiver.ItemUpdated(SPItemEventProperties properties) at Microsoft.SharePoint.SPEventManager.RunItemEventReceiver(SPItemEventReceiver receiver, SPItemEventProperties properties, SPEventContext
context, String receiverData) at Microsoft.SharePoint.SPEventManager.RunItemEventReceiverHelper(Object receiver, Object properties, SPEventContext context, String receiverData) at Microsoft.SharePoint.SPEventManager.<>c__DisplayClass8`1.<InvokeEventReceivers>b__0()
at Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state) at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param) at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken
03/14/2014 12:30:30.38* w3wp.exe (0x7698) 0x6C9C Windows SharePoint Services
General 0 Unexpected ...userToken, CodeToRunElevated
code) at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](SPUserToken userToken, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel) at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](Byte[]
userTokenBytes, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel) at Microsoft.SharePoint.SPEventManager.HandleEventCallback[ReceiverType,PropertiesType](Object callbackData)
at Microsoft.SharePoint.Utilities.SPThreadPool.WaitCallbackWrapper(Object state) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCo...
03/14/2014 12:30:30.38* w3wp.exe (0x7698) 0x6C9C Windows SharePoint Services
General 0 Unexpected ...de backoutCode, Object
userData) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback
tpWaitCallBack) at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state) , Allocation call stack (if present) null -
Hello,
The problem is inside the method "chamaConversor".
" conversor.pdfToText(arquivoPdf,arquivoTxt);" make a file.txt from one file.pdf. After that it don?t return the control to "ConstrutorDeTemplate2.java", and show the following error message:
Exception in thread "AWT-EventQueue-O" java.lang.NoClassDefFoundError : org/fontbox/afm/FontMetric
at org.pdfbox.pdmodel.font.PDFont.getAFM (PDFont.java:334)
I am using the NetBeans IDE 5.5.
I have added all of these libraries below to my project from c:\Program Files\netbeans-5.5\PDFBox-0.7.3\external:
* FontBox-0.1.0-dev.jar
* ant.jar
* bcmail-jdk14-132.jar
* junit.jar
* bcprov-jdk14-132.jar
* lucene-core-2.0.0.jar
* checkstyle-all-4.2.jar
* lucene-demos-2.0.0.jar
and PDFBox-0.7.3.jar from c:\Program Files\netbeans-5.5\PDFBox-0.7.3\lib.
There are no more jar from PDFBox-0.7.3 directory.
All of these libraries are in "Compile-time Libraries" option in Project Properties. Should I add they to "Run-time Libraries" option?
What is going on?
Thank you!
* ConstrutorDeTemplate2.java
* Created on 11 de Agosto de 2007, 14:54
* @author
package br.unifacs.dis2007.template2;
// Java core packages
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.*;
import java.util.*;
// Java extension packages
import javax.swing.*;
import org.pdfbox.*;
public class ConstrutorDeTemplate2 extends JFrame
implements ActionListener {
private JTextField enterField;
private JTextArea outputArea;
private BufferedWriter out;
private String word;
private PdfToText conversor = new PdfToText();
// ajusta a interface do usu?rio
public ConstrutorDeTemplate2()
super( "Testing class File" );
enterField = new JTextField("Digite aqui o nome do arquivo :" );
enterField.addActionListener( this );
outputArea = new JTextArea();
ScrollPane scrollPane = new ScrollPane();
scrollPane.add( outputArea );
Container container = getContentPane();
container.add( enterField, BorderLayout.NORTH );
container.add( scrollPane, BorderLayout.CENTER );
setSize( 400, 400 );
show();
// Exibe as informa??es sobre o arquivo especificado pelo usu?rio
public void actionPerformed( ActionEvent actionEvent )
File name = new File( actionEvent.getActionCommand() );
// Se o arquivo existe, envia para a sa?da as informa??es sobre ele
if ( name.exists() ) {
outputArea.setText(
name.getName() + " exists\n" +
( name.isFile () ?
"is a file\n" : "is not a file\n" ) +
( name.isDirectory() ?
"is a directory\n" : "is not a directory\n" ) +
( name.isAbsolute() ? "is absolute path\n" :
"is not absolute path\n" ) +
"Last modified: " + name.lastModified() +
"\nLength: " + name.length () +
"\nPath: " + name.getPath() +
"\nAbsolute path: " + name.getAbsolutePath() +
"\nParent: " + name.getParent() );
// informa??o de sa?da se "name" ? um arquivo
if ( name.isFile() ) {
String nameString = String.valueOf(name.getPath());
String nameTeste = new String(nameString);
if (nameString.endsWith(".pdf"))
nameTeste = chamaConversor(nameString);
else
if (nameString.endsWith(".doc"))
nameTeste = chamaConversorDoc(nameString); // chama conversor de arquivos DOC
else
if (nameString.endsWith(".txt"))
nameTeste = nameString;
// se o arquivo termina com ".txt"
if (nameTeste.endsWith(".txt"))
// acrescenta conte?do do arquivo ? ?rea de sa?da
try {
// Create the tokenizer to read from a file
FileReader rd = new FileReader(nameTeste);
StreamTokenizer st = new StreamTokenizer(rd);
// Prepare the tokenizer for Java-style tokenizing rules
st.parseNumbers();
st.wordChars('_', '_');
st.eolIsSignificant (true);
// If whitespace is not to be discarded, make this call
st.ordinaryChars(0, ' ');
// These calls caused comments to be discarded
st.slashSlashComments(true);
st.slashStarComments(true);
// Parse the file
int token = st.nextToken();
String word_ant = "";
outputArea.append( " \n" );
out = new BufferedWriter(new FileWriter(nameTeste, true));
while (token != StreamTokenizer.TT_EOF) {
token = st.nextToken();
if (token == StreamTokenizer.TT_EOL){
//out.write(word);
out.flush();
out = new BufferedWriter(new FileWriter(nameTeste, true));
//outputArea.append( word + "\n" );
// out.append ( "\n" );
switch (token) {
case StreamTokenizer.TT_NUMBER:
// A number was found; the value is in nval
double num = st.nval;
break;
case StreamTokenizer.TT_WORD:
// A word was found; the value is in sval
word = st.sval;
// if (word_ant.equals("a") || word_ant.equals("an") || word_ant.equals("the") || word_ant.equals("The") || word_ant.equals("An"))
outputArea.append( word.toString() + " \n " );
// out.append( word + " " );
// word_ant = word;
break;
case '"':
// A double-quoted string was found; sval contains the contents
String dquoteVal = st.sval;
break;
case '\'':
// A single-quoted string was found; sval contains the contents
String squoteVal = st.sval;
break;
case StreamTokenizer.TT_EOL:
// End of line character found
break;
case StreamTokenizer.TT_EOF:
// End of file has been reached
break;
default:
// A regular character was found; the value is the token itself
char ch = (char)st.ttype;
break;
} // fim do switch
} // fim do while
rd.close();
out.close();
} // fim do try
// process file processing problems
catch( IOException ioException ) {
JOptionPane.showMessageDialog( this,
"FILE ERROR",
"FILE ERROR", JOptionPane.ERROR_MESSAGE );
} // fim do if da linha 92 - testa se o arquivo ? do tipo texto
} // fim do if da linha 78 - testa se ? um arquivo
// output directory listing
else if ( name.isDirectory() ) {
String directory[] = name.list();
outputArea.append( "\n\nDirectory contents:\n");
for ( int i = 0; i < directory.length; i++ )
outputArea.append( directory[ i ] + "\n" );
} // fim do else if da linha 184 - testa se ? um diret?rio
} // fim do if da linha 62 - testa se o arquivo existe
// not file or directory, output error message
else {
JOptionPane.showMessageDialog( this,
actionEvent.getActionCommand() + " Does Not Exist",
"ERROR", JOptionPane.ERROR_MESSAGE );
} // fim do m?todo actionPerformed
// m?todo que chama o conversor
public String chamaConversor(String arquivoPdf){
String arquivoTxt = new String(arquivoPdf);
arquivoTxt = arquivoPdf.replace(".pdf", ".txt");
try {
conversor.pdfToText(arquivoPdf,arquivoTxt);
catch (Exception ex) {
ex.printStackTrace();
return (arquivoTxt);
// executa a aplica??o
public static void main( String args[] )
ConstrutorDeTemplate2 application = new ConstrutorDeTemplate2();
application.setDefaultCloseOperation (
JFrame.EXIT_ON_CLOSE );
} // fim do m?todo main
} // fim da classe ExtratorDeSubstantivos2
* PdfToText.java
* Created on 11 de Agosto de 2007, 10:57
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
//package br.unifacs.dis2007.template2;
* @author www
package br.unifacs.dis2007.template2;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL ;
import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.pdmodel.encryption.AccessPermission;
import org.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
import org.pdfbox.util.PDFText2HTML;
import org.pdfbox.pdmodel.font.PDFont.* ;
import org.pdfbox.util.PDFTextStripper;
import org.pdfbox.util.*;
import org.pdfbox.pdmodel.*;
public class PdfToText
public void pdfToText( String pdfFile, String textFile) throws Exception
Writer output = null;
PDDocument document = null;
try
try
//basically try to load it from a url first and if the URL
//is not recognized then try to load it from the file system.
URL url = new URL( pdfFile );
document = PDDocument.load( url );
String fileName = url.getFile();
if( textFile == null && fileName.length () >4 )
File outputFile =
new File( fileName.substring( 0,fileName.length() -4 ) + ".txt" );
textFile = outputFile.getName();
catch( MalformedURLException e )
document = PDDocument.load( pdfFile );
if( textFile == null && pdfFile.length() >4 )
textFile = pdfFile.substring( 0,pdfFile.length() -4 ) + ".txt";
//use default encoding
output = new OutputStreamWriter( new FileOutputStream( textFile ) );
PDFTextStripper stripper = null;
stripper = new PDFTextStripper();
stripper.writeText( document, output );
finally
if( output != null )
output.close();
if( document != null )
document.close();
}//finally
}//end funcao
You might have to modify you weblogic.policy to grant access rights for
WLAS.
Cheers - Wei
Nyman <[email protected]> wrote in message
news:[email protected]..
Hi everyone,
When running WLS in RedHat 6.2 with the command - ./startWebLogic.sh,an
error saying "Exception in thread mainjava.security.AccessControlException
: access denied (java.lang.RuntimePermission createSecurityManager) is
displayed.
Could anyone suggestion an solution?
Best Regardsm -
Help with "Exception in thread "Thread-4" java.lang.NullPointerException"
I am new to Java and I am trying a simple bouncing ball example from Stanford. Here is their simple example that works.
import acm.program.*;
import acm.graphics.*;
import java.awt.*;
public class BouncingBallWorking extends GraphicsProgram {
/** sets diameter */
private static final int DIAM_BALL = 30;
/** amount y velocity is increased each cycle */
private static final double GRAVITY = 3;
/** Animation delay or pause time between ball moves */
private static final int DELAY = 50;
/** Initial X and Y location ball*/
private static final double X_START = DIAM_BALL / 2;
private static final double Y_START = 100;
private static final double X_VEL = 3;
private static final double BOUNCE_REDUCE = 0.9;
private double xVel = X_VEL;
private double yVel = 0.0;
private GOval BallA;
public void run() {
setup(X_START,Y_START);
// Simulation ends when ball goes off right hand
// end of screen
while (BallA.getX() < getWidth()) {
moveBall(BallA);
checkForCollision(BallA);
pause(DELAY);
private void setup(double X_coor, double Y_coor) {
BallA = new GOval(X_coor, Y_coor, DIAM_BALL, DIAM_BALL);
add(BallA);
private void moveBall(GOval BallObject) {
yVel += GRAVITY;
BallObject.move(xVel,yVel);
private void checkForCollision(GOval BallObject) {
if(BallObject.getY() > getHeight() - DIAM_BALL){
yVel = - yVel * BOUNCE_REDUCE;
double diff = BallObject.getY() - (getHeight() - DIAM_BALL);
BallObject.move(0, -2 * diff);
} Now I am trying to modify "setup" so it I can create several balls. I made a simple modification to "setup" and now I am getting an error.
"Exception in thread "Thread-4" java.lang.NullPointerException
at BouncingBallNotWorking.run(BouncingBallNotWorking.java:36)
at acm.program.Program.runHook(Program.java:1592)
at acm.program.Program.startRun(Program.java:1581)
at acm.program.AppletStarter.run(Program.java:1939)
at java.lang.Thread.run(Unknown Source)"
Can you describe why I am getting an error? Thanks.
Here is what I changed.
Before:
private void setup(double X_coor, double Y_coor) {
BallA = new GOval(X_coor, Y_coor, DIAM_BALL, DIAM_BALL);
add(BallA);
}After:
private void setup(double X_coor, double Y_coor, GOval BallObject) {
BallObject = new GOval(X_coor, Y_coor, DIAM_BALL, DIAM_BALL);
add(BallObject);
}Here is the complete code.
* File:BouncingBall.java
* This program graphically simulates a bouncing ball
import acm.program.*;
import acm.graphics.*;
import java.awt.*;
public class BouncingBallNotWorking extends GraphicsProgram {
/** sets diameter */
private static final int DIAM_BALL = 30;
/** amount y velocity is increased each cycle */
private static final double GRAVITY = 3;
/** Animation delay or pause time between ball moves */
private static final int DELAY = 50;
/** Initial X and Y location ball*/
private static final double X_START = DIAM_BALL / 2;
private static final double Y_START = 100;
private static final double X_VEL = 3;
private static final double BOUNCE_REDUCE = 0.9;
private double xVel = X_VEL;
private double yVel = 0.0;
private GOval BallA;
public void run() {
setup(X_START,Y_START, BallA);
// Simulation ends when ball goes off right hand
// end of screen
while (BallA.getX() < getWidth()) {
moveBall(BallA);
checkForCollision(BallA);
pause(DELAY);
private void setup(double X_coor, double Y_coor, GOval BallObject) {
BallObject = new GOval(X_coor, Y_coor, DIAM_BALL, DIAM_BALL);
add(BallObject);
private void moveBall(GOval BallObject) {
yVel += GRAVITY;
BallObject.move(xVel,yVel);
private void checkForCollision(GOval BallObject) {
if(BallObject.getY() > getHeight() - DIAM_BALL){
yVel = - yVel * BOUNCE_REDUCE;
double diff = BallObject.getY() - (getHeight() - DIAM_BALL);
BallObject.move(0, -2 * diff);
} Edited by: TiredRyan on Mar 19, 2010 1:47 AMTiredRyan wrote:
That is great! Thanks. I've got two question though.
1.) Now I want to have 100 bouncing balls. Is the best way to achieve this is through an array of GOvals? I haven't gotten to the lecture on arrays on Stanford's ITunesU site yet so I am not sure what is possible with what I know now.An array would work, or a List. But it doesn't matter much in this case.
2.) Are references being passed by value only applicable to Java or is that common to object-oriented programming? Also is there a way to force Java to pass in "BallA" instead of the value "null"?I can't say about all OO languages as a whole, but at least C++ can pass by reference.
And no, there's no way to pass a reference to the BallA variable, so the method would initialize it and it wouldn't be null anymore.
When you call the method with your BallA variable, the value of the variable is examined and it's passed to the method. So you can't pass the name of a variable where you'd want to store some object you created in the method.
But you don't need to either, so there's no harm done. -
Hi
I am trying to use type 4 driver to connect to my Oracle 9i Rel2 database. I downloaded the odbc14.jar from oracle and added in the C:\Oracle9i\jdbc\lib path. As on the website, I setup my environment:
Setting Up Your Environment
On Win95/Win98/NT:
- Add [ORACLE_HOME]\jdbc\lib\classes111.zip and
[ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH.
(Add classes12.zip and nls_charset12.zip if JDK 1.2.x or 1.3 is
used. Add ojdbc14.jar and nls_charset12.zip if JDK 1.4 is used.)
- Make sure [ORACLE_HOME]\bin is in your PATH.
Still I am getting the following error during runtime:
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at jdbc.InsertQueryEx.main(InsertQueryEx.java:11)
Below is the source code:
import java.sql.*;
import java.io.*;
public class InsertQueryEx {
public static void main(String[] args)throws Exception{
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@Prashy:1521:orcl", "scott", "tiger");
DataInputStream din = new DataInputStream(System.in);
Statement stmt = con.createStatement();
while(true){
try{
System.out.println("enter emp name");
String name = din.readLine();
System.out.println("enter emp no");
int no = Integer.parseInt(din.readLine());
System.out.println("enter emp salary");
float sal = Float.parseFloat(din.readLine());
System.out.println("enter emp address");
String addr = din.readLine();
int count = stmt.executeUpdate("insert into myemp values("+no+",'"+name+"',"+sal+",'"+addr+"')");
if(count>0)
System.out.println("Record added");
else
System.out.println("Failed");
catch (Exception e){
System.err.println("Exception: "+e.getMessage());
Any help is appreciated
Thanks
PrashantI am sorry but I did add those in the classpath but still getting this error:
This is what I have for user variable in classpath:
.;C:\Oracle9i\jdbc\lib\ojdbc14.jar;C:\Oracle9i\jdbc\lib\nls_charset12.jar
error is:
java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at jdbc.InsertQueryEx.main(InsertQueryEx.java:14)
Thanks -
Exception in thread "main" javax.mail.NoSuchProviderException: invalid prov
HI,
I am trying to read mails from my inbox i amgetting the ErrorC:\javamail>java
Readmail
Exception in thread "main" javax.mail.NoSuchProviderException: No provider for IMAP
at javax.mail.Session.getProvider(Session.java:455)
at javax.mail.Session.getStore(Session.java:530)
at javax.mail.Session.getStore(Session.java:510)
at Readmail.main(Readmail.java:24)My Code is {
String host = "hostname";
String username = "user";
String password = "password";
// Create empty properties
Properties props = new Properties();
// Get session
Session session = Session.getDefaultInstance(props,null);
// Get the store
Store store = session.getStore("IMAP");
store.connect(host, username, password);
// Get folder
Folder folder = store.getFolder("Inbox");
folder.open(Folder.READ_ONLY);
// Get directory
Message message[] = folder.getMessages();
for (int i=0, n=message.length; i<n; i++)
System.out.println(i + ": " + message.getFrom()[0]
+ "\t" + message[i].getSubject());
// Close connection
folder.close(false);
store.close();
I have also tried POP3 and MIME and SMTP
Can anyone help me Thankshi bshannon,
I am getting the same error for others but for pop3 the error is as below
Exception in thread "main" javax.mail.MessagingException: Connect failed;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:148)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at Readmail.main(Readmail.java:25)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.pop3.Protocol.<init>(Protocol.java:81)
at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:201)
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:144)
... 3 more -
Use Java to collect data from HTML
Hi Guys
I am doing a online stock trading project, the main part is to collect raw data from http://finance.yahoo.com User can retrieve the stock detail by inputting the right stock symbol, such as "AOL". I dont have too much problem in this part because yahoo provde a spreedsheet format to display the result. If you type the URL below, it can bring you a set of stock data separating by comma. So, I can use StringTokenizer(date, ",") to collect each data from yahoo into my system.
========================================================================
http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s=AOL&
"AOL",15.57,"8/12/2003","4:01pm",+0.04,15.47,15.63,15.40,12097200
========================================================================
However beside this function, I also need to search Stock Symbol, because user may only know the company name. Although Yahoo finance also provide this function, with no spreedsheet format provided. So, if I type the URL below, it will only give me a set of result BUT in HTML format.
========================================================================
http://finance.yahoo.com/l?s=AOL&t=S&m=
========================================================================
So, can anyone tell me what is the best way to collect data from a HTML page? Or anyone know any good stock quoting sites which also provide spreedsheet format?
Thank you very much
KelI am doing a online stock trading project, the
the main part is to collect raw data from
http://finance.yahoo.com
Sounds fun.
So, can anyone tell me what is the best way to
to collect data from a HTML page? Or anyone know any
good stock quoting sites which also provide
spreedsheet format?I really don't know any other stock quote sites. But if you want to implement a search function for stock names, I would do it like this
1) Code the HTTP SUBMIT/POST to lookup the possible stock names
2) Use XSL to filter out the HTML path to the table with results, the layout is consistent, so there are no strange exceptions. You can check the DOM structure by using Mozilla's DOM inspector. Just write down the path to the TABLE element and select it, and transform it to CSV for example.
3) Reparse the CSV to fill some boxes
To possibly save some server load use a small fixed size in memory cache to store N requests based on some strategy.
The other part is actual a separate part of what you want to code and should be a separate class in which you can feed the stock name.
If the user types in a bad stock name, you can retrieve a list of possible names using the input as the company name.
Greets.
Maybe there is a SOAP service out there somewhere.
Maybe you are looking for
-
How to invoke an application when another applications is started
Hi All, Good day. I am a newbie to AppleScript and writing down this seeking your kind help here. Making my question detail here, Applcation 1 : Consider this to be some thing kind of server stuff which is running. Application 2: Consider thi
-
Ical does not work in Day View
When I was working in ICal I have input an event in a date but I can only see it or change it when in Week View. When I put in Day View it suddenly freezes and nothing appears. What can it be? it's curious that it freezes in October 15th. Anybody saw
-
Moved music folder to external drive, how do I get Match/ITunes to recognise it?
Hi guys, I've been rather stupid in restoring my computer. I moved all the music to an external harddrive before I restored my PC but forgot to bring the Itunes library file with it. I've got ITunes Match so I can stream all my songs, but is there an
-
Recognising Revenues based on costs in Service Orders
We have configured SD Revenue Recognition function (ECC 5.0). We have warranty maintenance contracts running. On this basis we have the following scenario and issue. The warranty maintenance contracts are created without a billing plan (Reqmt. type
-
i have about 20 photos in "my photos" folder. when the photos copy, it shows that all 20 are being copied to the ipod, but the only 1 that shows up in the ipod is the sample photo (that was there with windows). what am i doing wrong?