Friday, January 23, 2015

Eclipse hangs on start up after proxy configuration change

The problem appeared after I had changed the proxy settigns of IDE in Preferences/General/Network Connections. After that eclipse started sticking on loading workbench. The following solution solved the problem:

  1. Go to your eclipse installation folder
  2. Switch to configuration/.settings
  3. Open file org.eclipse.core.net.prefs
  4. Set all the boolean properties related to proxy to false
  5. Save the changes
  6. Start Eclipse again
This solution has worked for me. Hope it will work for you as well.

Eclipse xpath parser fails to search elements by the tag names

For those who encountered the same issue (when you try to access the element using xpath by the node name in Eclipse built-in parser) I would recommend either to remove namespace definition from the document at all or remove the default namespace.
Example:

<apprepo xmlns="asdasd">
<app name="good-app">
<appinfo>
<author name="John Smith"/>
<stores>
<store name="goo" price="1"/>
<store name="app" price="1.5"/>
</stores>
</appinfo>
</app>
<app name="another-good-app">
<appinfo>
<author name="James Smith"/>
<stores>
<store name="goo" price="2"/>
</stores>
</appinfo>
</app>
</apprepo>

Query: //appinfo returns "no matches"

Let's now change the namespace so that it is bound to some prefix (let's even not use that prefix in our document)

<apprepo xmlns:pref="asdasd">
<app name="good-app">
<appinfo>
<author name="John Smith"/>
<stores>
<store name="goo" price="1"/>
<store name="app" price="1.5"/>
</stores>
</appinfo>
</app>
<app name="another-good-app">
<appinfo>
<author name="James Smith"/>
<stores>
<store name="goo" price="2"/>
</stores>
</appinfo>
</app>
</apprepo>

Result: query returns all the appinfo nodes found

P.S. - the proper parsing happens even if you completely get rid of the namespace attribute. So Eclipse xpath parser is not working with the documents having the default namespace set.

Thursday, December 11, 2014

Tip: add element to JScrollPane with not specifying it in constructor

Tip: If you created JScrollPane object and didn't set the scrollable client as the constructor parameter, you can add it later by invoking setViewportView method of JScrollPane.

Thursday, December 04, 2014

Caption text disappears on JButton if Action is assigned

While implementing yet another tool helping to automate project processes I faced an issue that took some amount of time to resolve. That might be quite obviouse for those how's been dealing with s
Swing for a long time but I spent a day to find the solution out.

So I had the code to create JButton with caption like

JButton jbPerformSomeJob = new JButton("Perform Some Job");

After I had completed building my UI I ran the app and having no logic assigned to my buttons I got the result I expected to get. I had some UI controls on my JFrame including that my button with the expected caption.

So after that I added some Action to my button as anonymous class object.

jbPerformSomeJob.setAction(new AbstractAction() {

@Override
public void actionPerformed(ActionEvent e) {
performCustomJob();
}
});

After I started the application again I couldn't see the caption on the button any more.

So the solution is not obvious enough as to me. It turned out that the name of the action overrides the button caption so to have my caption back I had to define separate named class like:

class PerformSomeJobAction extends AbstractAction{

public GenerateReportAction(String text) {
super(text);
}

@Override
public void actionPerformed(ActionEvent e) {
performCustomJob();
}

}

and use the following construction for my JButton

jbPerformSomeJob.setAction(new PerformSomeJobAction("Perform Some Job"));

Thursday, November 27, 2014

Error executing Proguard in Eclipse

Recently faced an issue in Eclipse with ADT plugin while trying to Export Signed Application Package. On the very final step I was getting the error message "Failed to run proguard: Error executing Proguard. Please check Proguard is present at ...". However I knew that proguard is installed. After several minutes of confusion I noticed that there is no slash after the android sdk folder in the path to Proguard. So if you encounter the same issue under the same circumstances you likely did not put slash symbol to the end of the path to your android sdk in Eclipse preferences.

Monday, September 09, 2013

Apache Felix fails to run in background (including nohup case)

How to run Apache Felix in background with nohup. Solution is here. In my case I faced the problem when tried to run Squash TM in background. That application is built over Apache Felix and the exceptions told something like:

java.util.zip.ZipException: ZipFile closed
at java.util.zip.ZipFile.ensureOpenOrZipException(ZipFile.java:642)
at java.util.zip.ZipFile.access$1300(ZipFile.java:56)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:675)
at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:413)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at org.apache.felix.framework.util.WeakZipFileFactory$WeakZipFile$WeakZipInputStream.read(WeakZipFileFactory.java:707)

or

Spring DM context shutdown thread WARN 06/09 14:35:39 [org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext] - Exception
thrown from ApplicationListener handling ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context:
OsgiBundleXmlApplicationContext(bundle=org.squashtest.tm.plugin.testautomation.jenkins, config=osgibundle:/META-INF/spring/*.xml): startup date
[Fri Sep 06 14:35:34 BST 2013]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:340)

Certain amount of investigation shown that the common solution in such the case is to exclude the application binding to the console. So do the following:

  1. As it's recommended here check if you have ConsoleHandler enabled for your Log4j and disable it using the following entry: java.util.logging.ConsoleHandler.level = OFF (if you're using property file to configure your logging. otherwise use the xml equivalent)
  2. Drop the bundles holding -shell suffix from your Bundles folder. They could look like the following:
    1. org.apache.felix.shell.tui-version.jar
    2. org.apache.felix.gogo.shell-version.jar
  3. As the alternative of the previous step you may add -Dgosh.args=--nointeractive  option to the jvm arguments on calling your app from sh sctipt
  4. Run your application in the regular way like nohup ./startup.sh &
This should help.

Saturday, August 31, 2013

Yet another hint on "unbound prefix" in your programmatically composed SVG file

If you compose your SVG file programmatically you might experience the following issue. Your resulting file won't be parsed with the following exception coming from the parser:

com.larvalabs.svgandroid.SVGParseException: org.apache.harmony.xml.ExpatParser$ParseException: At line 4, column 0: unbound prefix
This exception basically says that somewhere in your SVG markup you use either the tags or the attributes fromt he namespace you didn't specify in SVG header. Examine your resulting SVG code for such the sort of problem. Fixing should help.