Steve Sinai

Greenhorn
+ Follow
since Aug 21, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steve Sinai

I was able to solve the problem by not throwing Timer exceptions up to a common exception handling method. Instead I caught them and dealt with them in the method in which they were caught.

It was turning out that if I threw an exception up the method chain, EJB would automatically embed it in some kind of transaction exception, which meant I couldn't write something to the database notifying people that an exception had occurred. If I didn't throw the exception, then there was no transaction exception involved.
Is there a way to run an EJB3 timer without it being inside a transaction?

Sometimes the methods run by the timer throw exceptions, and I'd like to be able to update a database with a failed flag if that happens. But the EJBTransactionRolledbackException that gets thrown prevents me from doing this.

Thanks.
As is always the case, I stumbled across a solution about 5 minutes after I posted the question. In this case, someone else had posted a similar problem, and was able to fix it by going to tomcat-users.xml, and setting the encoding to utf-8. It seems like a hack fix, but it works. I'm sure there must be a better way to solve the problem.

Thanks,
Steve Sinai
8 years ago
I'm trying to run some little example jsp and jspx programs from a book called "Beginning JSP, JSF and Tomcat" that require me to install xpath-related jar files. The book is a couple years old, so maybe things have changed, but following the instructions in the book, I downloaded xalan-j_2_7_1-bin.zip, unzipped it, and copied xalan.jar, xercesImpl.jar, serializer.jar, and xml-apis.jar to my Tomcat6.0/lib directory. After restarting Tomcat and typing the url of any previously working jsp or jspx file, Tomcat seemed to hang and I'd get a "Waiting for localhost..." message in the browser status bar, and a "Loading..." message in the browser tab . I'm mostly trying this with Firefox 3.5, but also tried it with IE 8, and had the same hanging problem. It also happened even if I rebooted the computer just to make sure Tomcat started up cleanly. Both Tomcat and browser are on the same laptop running Vista.

There was also an alternative way of downloading the required jars using Xerces-J-bin.2.9.0.zip, where I only had to copy xercesImpl.jar, serializer.jar and xml-api.jar libraries to Tomcat6.0/lib, but still had the hanging problem.

Anyone have a clue as to what might be happening. I haven't adjusted any classpaths or done anything outside of downloading the required jars and installing them in the Tomcat lib directory. I'll copy the error message I'm getting from the latest catalina.2009-07-17 log file below.

Thanks,
Steve Sinai

Jul 17, 2009 4:01:02 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.16.
Jul 17, 2009 4:01:02 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Jul 17, 2009 4:01:03 PM org.apache.coyote.http11.Http11AprProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jul 17, 2009 4:01:03 PM org.apache.coyote.ajp.AjpAprProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009
Jul 17, 2009 4:01:03 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3705 ms
Jul 17, 2009 4:01:03 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 1 column 40: Invalid encoding name "cp1252".
org.xml.sax.SAXParseException: Invalid encoding name "cp1252".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.createReader(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager$ScannedEntity.setReader(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.setEncoding(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanXMLDeclOrTextDecl(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$XMLDeclDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1663)
at org.apache.catalina.users.MemoryUserDatabase.open(MemoryUserDatabase.java:402)
at org.apache.catalina.users.MemoryUserDatabaseFactory.getObjectInstance(MemoryUserDatabaseFactory.java:103)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:113)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:71)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:137)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:109)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:81)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:703)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 17, 2009 4:01:03 PM org.apache.naming.NamingContext lookup
WARNING: Unexpected exception resolving reference
org.xml.sax.SAXParseException: Invalid encoding name "cp1252".
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1663)
at org.apache.catalina.users.MemoryUserDatabase.open(MemoryUserDatabase.java:402)
at org.apache.catalina.users.MemoryUserDatabaseFactory.getObjectInstance(MemoryUserDatabaseFactory.java:103)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:113)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:71)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:137)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:109)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:81)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:703)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 17, 2009 4:01:03 PM org.apache.catalina.mbeans.GlobalResourcesLifecycleListener createMBeans
SEVERE: Exception processing Global JNDI Resources
javax.naming.NamingException: Invalid encoding name "cp1252".
at org.apache.naming.NamingContext.lookup(NamingContext.java:805)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:113)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:71)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:137)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:109)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:81)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:703)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 17, 2009 4:01:03 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jul 17, 2009 4:01:03 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
Jul 17, 2009 4:01:03 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 1 column 40: Invalid encoding name "cp1252".
org.xml.sax.SAXParseException: Invalid encoding name "cp1252".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.createReader(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager$ScannedEntity.setReader(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.setEncoding(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanXMLDeclOrTextDecl(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$XMLDeclDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1663)
at org.apache.catalina.users.MemoryUserDatabase.open(MemoryUserDatabase.java:402)
at org.apache.catalina.users.MemoryUserDatabaseFactory.getObjectInstance(MemoryUserDatabaseFactory.java:103)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:253)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1037)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 17, 2009 4:01:03 PM org.apache.naming.NamingContext lookup
WARNING: Unexpected exception resolving reference
org.xml.sax.SAXParseException: Invalid encoding name "cp1252".
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1663)
at org.apache.catalina.users.MemoryUserDatabase.open(MemoryUserDatabase.java:402)
at org.apache.catalina.users.MemoryUserDatabaseFactory.getObjectInstance(MemoryUserDatabaseFactory.java:103)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:253)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1037)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 17, 2009 4:01:03 PM org.apache.catalina.realm.UserDatabaseRealm start
SEVERE: Exception looking up UserDatabase under key UserDatabase
javax.naming.NamingException: Invalid encoding name "cp1252".
at org.apache.naming.NamingContext.lookup(NamingContext.java:805)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:253)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1037)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 17, 2009 4:01:03 PM org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
LifecycleException: No UserDatabase component found under key UserDatabase
at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:261)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1037)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 17, 2009 4:01:03 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 135 ms
8 years ago
Given a PrintService from something like PrintServiceLookup.lookupDefaultPrintService(), does anyone know how I can query for the supported paper sizes for that print service/printer? For example, "Legal", "Letter", "A4", "B4", etc. I'm doing a print preview dialog, and I'd like to be able to preview documents based on the paper size the user wants to print to.

I actually implemented something like this about a year ago, but I don't have the code anymore, and for some reason (probably programmer's rotting-brain syndrome) I can't remember how to do it.

Thanks.
9 years ago
God I hate Java printing!!

I'm trying to print out a JTextPane that has an embedded JComponent using the new 1.6 JPrintComponent.print() method. Works great for text with no embedded components, but doesn't work so great for text WITH embedded components.

If you run the example program below, you'll see a text component with a circle drawn into an embedded component at the bottom of the document. When I hit the Print button at the bottom, the embedded component with the circle goes away. (This takes a few moments while the print system initializes.)

Does anyone have a guess as to how to keep the component from going away when I try to print the document?

Thanks.


9 years ago
Does anyone know of coding example for word-based text undo? By default, Swing undoes and redoes typed-in text one character at a time, but I'd like to undo and redo based on whole words. This is the way most professional word-processing programs do it.

I have a way of doing word-based undo and redo, but it's so complicated and kludgy that I figure there must be a better way out there.

Thanks.
10 years ago
Hi,

Does anyone know if it's possible to create a JTable (along with the table header) in headless mode? I've not been having much luck, and I'm not even sure it's possible. But I could be wrong.

Thanks,
Steve Sinai
10 years ago
Hi Michael,

I'm afraid in your example the nodes are of a fixed size. I need to be able to change sizes of the nodes dynamically. From what I can tell, you can set the preferred size of a node once, but then once the node is created, you can't change it's size.

Thanks,
Steve
11 years ago
Hi, I'm trying to adjust the width of DefaultTreeCellRenderers after they've been created, but can't figure out how to do it. For performance reasons, it looks like all the related DefaultTreeCellRenderer functions that should deal with this have been overridden., i.e,, validate, repaint, etc. The reason I want to do this is so that when the tree containing the nodes is resized so that some nodes are wider than the visible tree, then I want the clipped text at the end to of the long nodes to be replaced with a visible "...". Stand-alone JLabels will do this automatically, but the JLabel in a DefaultTreeCellRenderer won't. Any suggestions?

Thanks,
Steve Sinai
11 years ago
I haven't done any automated Swing GUI testing for a few years, and I always had a negative opinion of automated GUI testing in general. It's a nice idea, but there's something in the nature of GUI development that makes automated testing very difficult and arguably not worth the effort.

I'm wondering if anyone here has any strong opinions on this matter. Have automated Swing testing tools gotten better over the last few years? Of course, anyone is allowed to offer their opinions, but I really would value the opinions of people who have actually tried developing these tests, rather than people who just assume automated testing is good, but haven't really spent much time writing automated tests for Swing. In talking to people about this matter, I find that the people most enthusiastic about automated GUI testing tend to be managers and architects who don't actually develop GUI tests themselves.

Thanks.
11 years ago
I actually do use TabStops and TabSets now, but I was hoping there was an easy way to set the default behavior to align tabs along a decimal point in a number, rather than creating a bunch of TabStops and a TabSet. My pages are pretty dynamic, and it's hard to know how many TabStops will be needed on a page. Right now I'm just creating an array of 100 TabStops, but it's inevitable that someone's going to come up with a document that needs more than 100.
11 years ago
Hi - Does anyone know if there's a way to set TabStop.ALIGN_DECIMAL on a JTextPane as a default, i.e., without creating a TabSet containing lots of TabStops? I have a JTextPane with lots of numbers I'd like to align using tabs.

Thanks,
Steve Sinai
11 years ago
Thanks for the replies, everyone!
11 years ago
I'm loading some external .class files into my application during runtime, similar to the way Tomcat loads servlets. By "external" I mean classes that were not compiled as part of the main application. Once you've loaded an external class like this, is there a way to unload it and then reload with a modified class of the same name, without stopping and restarting the main application?

I hope this made sense. I think the answer is no, but usually when I assume no, the answer turns out to be yes. And vice-versa.

Thanks.
11 years ago