October 4, 2011

JavaBeans PropertyChangeSupport Template

by Jay Jonas

Property-change events occur whenever the value of a bound property changes for a java bean. You can use a Eclipse template to help you to write all the standard setter code

Open Windows | Preferences. Browse to Java | Editor | Templates. Click on New and enter property_change_support as Name, choose Java Statements as Context and mark Automatically Insert option. Write a meaning description as “property change support for setter method” and copy & paste into Pattern the code as follows:

if (this.${enclosing_method_arguments} == null && ${enclosing_method_arguments} == null) {
return;
}
propertyChangeSupport.firePropertyChange("${enclosing_method_arguments}", this.${enclosing_method_arguments}, ${word_selection})

Take care about that there is no new line at the end of the last line.
Take notes and will never forget it.

Advertisements
October 4, 2011

Tab Mix Plus dragging broken in Firefox

by Jay Jonas

Tab dragging (drag and drop to move the tabs around each others, but also to move a tab into a new window) has been broken in the Firefox 8 (Beta) version I use. That was not a Firefox fault, but a problem with the great Tab Mix Plus add-on.
The solution for this was to install Tab Mix Plus Dev-Build 0.3.8.7pre.110917a, a preview development version.

Futher information and download at Tab Mix Plus Forums.

// Updated 20111019:

Development Channel
The Development Channel lets you test an experimental new version of this add-on before it’s released to the general public. Once you install the development version, you will continue to get updates from this channel.
Install development version

August 6, 2011

How to remove unwanted Preference Pages

by Jay Jonas

Remove them in the ApplicationWorkbenchWindowAdvisor.postWindowCreate():

PreferenceManager pm = PlatformUI.getWorkbench( ).getPreferenceManager();
pm.remove("org.eclipse.ui.preferencePages.Workbench");

The org.eclipse.ui.preferencePages.Workbench id removes the “General” preference page group. If you don’t know the id for the page you want to remove, so you can first try to print them like this:

PreferenceManager pm = PlatformUI.getWorkbench( ).getPreferenceManager();
IPreferenceNode[] arr = pm.getRootSubNodes();

for(IPreferenceNode pn:arr){
 System.out.println("Label:" + pn.getLabelText() + " ID:" + pn.getId());
}
July 17, 2011

Eclipse API baseline warning

by Jay Jonas

In case you encounter the warning “An API baseline has not been set for the current workspace” you can disable this type of warning.

Eclipse Problems View

In order to solve this, you go to your Eclipse Preferences and then select Plug-In Development/API baselines.
Here you can set an API baseline or set missing API baseline to Ignore.
An API baseline defines an eclipse API against which your code is compared and checked for compatibility.
To se an API base line, click on Add Baseline… and in New API Baseline dialog select the path to eclipse installation you intend to use as your baseline.

Rebuild the project afterwards.

 

 

 

March 6, 2011

Error 1747: The Authentication Service is Unknown

by Jay Jonas

Do not ask me why, my notebook Windows 7 64-bit woke up this morning bothering me with this error

Windows Could not start the Windows Event Log service on Local Computer.
Error 1747: The authentication service is unknown.

I will not even attempt to look for explanations, not worth it. The solution to so, at least in my case, was to follow the steps below:

  • Go to the Start Menu, type cmd and right click or (Ctrl + Shift and hit Enter), and select “Run As Administrator”.
  • Type the following commands, each followed by pressing enter.
ipconfig /flushdns
nbtstat -R
nbtstat -RR
netsh int reset all
netsh int ip reset
netsh winsock reset
netsh interface tcp set global autotuninglevel=disabled

// http://support.microsoft.com/kb/811259

February 28, 2011

Splash Screen of the Day: STS 2.5.2

by Jay Jonas

 

SpringSource Tool Suite version 2.5.2

SpringSource Tool Suite™ (STS) provides the best Eclipse-powered development environment for building Spring-powered enterprise applications. STS supplies tools for all of the latest enterprise Java, Spring, Groovy and Grails based technologies as well as the most advanced tooling available for enterprise OSGi development. It is freely available for development and internal business operations use with no time limits.

// From http://www.springsource.com

February 26, 2011

java.lang.ClassFormatError: Truncated class file

by Jay Jonas

For future reference in case others encounter same
problem when running grails run-app command.  To confirm the problem try this:

$ export JAVA_OPTS="-Xverify:none"
$ grails run-app

For this case, you will see this error message:

Error executing script RunApp: Incompatible magic value <magic_number>  in class file  RunApp_groovy
java.lang.ClassFormatError: Incompatible magic value <magic_number> in class file RunApp_groovy

To fix it, delete the .grails folder in your home directory:

rm -rf $HOME/.grails

That’s it!

February 24, 2011

Periodic Table of Google API

by Jay Jonas

Interactive Web 2.0 periodic table with dynamic layouts  showing all Google API.

Take a look  here at Google Code.

Google API

By the way, if you are looking for a real interactive Web 2.0 periodic table, so check out this alternate link.

February 22, 2011

Firefox User Agent Switcher

by Jay Jonas

The User Agent Switcher extension adds a menu and a toolbar button to switch the user agent of a browser. The extension is available for Firefox and will run on any platform that this browser supports including Windows, Mac OS X and Linux.

January 30, 2011

ClassNotFoundException: org.objectweb.asm.ClassVisitor

by Jay Jonas

Yes! I’m a Jetty Server and Vaadin newbie. But that was a pain try to run Address Book Demo Vaadin tutorial with EclipseLink JPA 2.0 support. I tried with Jetty 7 and Jetty 8 and got all sort of errors using Eclipse WTP. I tested so many configurations and I restarted from ground zero many many times without any success.

Frustrated I installed Apache Tomcat 7 server and automagically all worked as expected on the first strike.

But I really like Jetty and I will give it a new try as soon as I solve this error:

2011-01-30 01:09:50.590:WARN::Unable to reach node goal: started
java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
 at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:71)
 at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:473)
 at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1174)
 at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:598)
 at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:496)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
 at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
 at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:180)
 at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:481)
 at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:137)
 at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:137)
 at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:50)
 at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:470)
 at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:382)
 at org.eclipse.jetty.util.Scanner.scan(Scanner.java:339)
 at org.eclipse.jetty.util.Scanner.start(Scanner.java:275)
 at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:114)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
 at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:542)
 at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:214)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
 at org.eclipse.jetty.server.Server.doStart(Server.java:227)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
 at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1061)
 at java.security.AccessController.doPrivileged(Native Method)
 at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:994)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.eclipse.jetty.start.Main.invokeMain(Main.java:476)
 at org.eclipse.jetty.start.Main.start(Main.java:618)
 at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:272)
 at org.eclipse.jetty.start.Main.main(Main.java:80)

[Updated: 20111013 | from the Juuso Backman’s comment. Thanks, Juuso!]

The problem was that Eclipse hadn’t added all the necessary .jars into the Jetty classpath.

The jars can be added to the classpath for Jetty via Eclipse like so:

  • Open the Servers view
  • Open your server’s config (right-click -> Open, or F3)
  • On the Overview tab, click “Open launch configuration”
  • Classpath tab -> add external jars

// Adding JPA based persistence to the Address Book Demo