Posts tagged ‘Eclipse’

September 22, 2012

Eclipse Task Tags Meaning

by Jay Jonas

TODO, along with FIXME and XXX, is known in Eclipse as a task tag, and is indexed by the IDE to let you find the spots marked with those tags easily. You can edit such tags in the Eclipse Preferences -> Java -> Compiler -> Task Tags.

This is the list for default Eclipse Task Tags and their meaning:

TODO

Comments that mark something for later work, later revision or at least later reconsideration. ODO comments should be considered a very useful technique, although like all good things on Earth, there’s certainly potential for abuse.

FIXME

A standard put in comments near a piece of code that is broken and needs work.

 XXX

A marker that attention is needed. Commonly used in program comments to indicate areas that are kluged up or need to be. Some hackers like `XXX’ to the notional heavy-porn movie rating. Use it to flag something that is bogus but works. Use FIXME to flag something that is bogus and broken.

ZZZ   /* This tag is mine!  ; ) */

Sometimes I like to use this marker for a stuff that was commented as deprecated just to remind me what happened there. However, when I’m sure, I delete it along with the code.

// TODO Need to optimize this before the end of the world.
// FIXME This won't work if the programmer is missing. 
// XXX This method badly needs refactoring: should be decaffeinated.
// ZZZ This was useful before the Y2K Millennium Bug.

--
From Sun/Oracle's Java code conventions, section 10.5.4:

Advertisements
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.

 

 

 

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

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

January 26, 2011

ClassNotFoundException: org.mortbay.start.Main

by Jay Jonas

I was trying to set up Eclipse to run and deploy my projects to a Jetty 7 server. I have downloaded it and unpacked it, and I  installed the Jetty plugin from the available server adapters list, but when I try to configure a new Jetty server, the server type list only contains “Jetty 6”. If I use this and point it at my server runtime, when I try to start it I get the following error:

java.lang.NoClassDefFoundError: org/mortbay/start/Main
Caused by: java.lang.ClassNotFoundException: org.mortbay.start.Main
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)
Exception in thread "main"

The problem is that the package name changed with the migration from Codehaus to Eclipse. So, we need a new WTP Adaptor for Jetty 7.x/Jetty 8.x that can be downloaded from the update sites as follows:

To install the WTP Adaptor, complete the following steps.

  1. Open Eclipse.
  2. In the taskbar at the top of your screen, click Help -> Install New Software. The Available Software dialog box opens.
  3. In the Work with: field, type one of the URLs provided above.
  4. Press Return.
  5. In the Name/Version box below, select the box for Jetty WTP Adaptor Site.
  6. Click Next.
  7. The Install Details dialog box opens.
  8. Click Next again.
  9. The Review Licenses dialog box opens.
  10. Accept the terms and click Finish.
  11. The Installing Software dialog box opens, displaying progress for installing the WTP adaptor. When it completes, the Software Updates dialog box opens with a message that you need to restart Eclipse to complete the installation.
  12. Click Restart Now.

Next step will be create a Jetty WTP Server.  Stay tuned as I will show it in the next post.

Tags: , ,
January 20, 2011

Splash Screen of the Day: Eclipse 1.0

by Jay Jonas
Eclipse 1.0

Eclipse 1.0 Splash Screen - version 1.0

Released at November 7, 2001.  (c) Copyright IBM Corp. 2000, 2001. All Rights Reserved. It can be downloaded in Eclipse Foundation following this link here.

January 19, 2011

PDE build: Bundle failed to resolve

by Jay Jonas

When exporting a feature, or a product based on features you get an error like:

Processing inclusion from feature <your feature here>: Bundle org.eclipse.core.net.linux.x86 <version here> failed to resolve.:

This is caused by a missing window system/operating system/architecture filter on the fragment’s inclusion in the feature.xml. This can easily be set in the Plug-ins Tab of the feature editor by selecting the fragment on the left and specifying the Operating System, Window System and Architecture on the right.

Plugins and Fragments

Plugin details in Plugins and Fragments editor

Quoted from Eclipse PDE Build FAQ.

Tags:
January 17, 2011

Eclipse: Import cannot be resolved

by Jay Jonas

Eclipse suddenly, and everyone is against you (or some) of its import are displaying the error message:

 import MyClassName cannot be resolved.

Do not panic yet. Before, you could try the following tips:

  • Clean Project command is your friend: go to Project > Clean menu.
  • If using Ant or Maven, use – clean option to clean your builds.
  • Refresh your project folder:  right click on your project folder  and click Refresh command.
  • Re-build your project.
  • Create a new Workspace and Import your project there.
  • ‘Switch’ Workspace – go to other Workspace the return back.
  • Double-check your JRE. Remove and re-add as follows:
  1. right click on your Project and click on  Properties from context menu;
  2. click on the Libraries tab;
  3. next, click on the JRE;
  4. click Remove, then OK;
  5. repeat 1-3 again, but this time add the JRE.
  • Finally, if your Target Plataform is divided into components in various folders, double check for duplicate plugins, ie plugins with same ID and version. If find one, remove it  mercilessly.

The tips can be followed in the order you prefer because not have a specific order and can work or not. Do not blame me if not. And make a backup before start.

January 13, 2011

Open a Eclipse View zoomed

by Jay Jonas
public class MyOpenViewZoomedCmdHandler extends AbstractHandler {

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {

        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);

        IWorkbenchPage page = window.getActivePage();

        try {

            // any view in your application
            IViewPart view = page.showView(MyView.VIEW_ID);

            if (!page.isPageZoomed()) {
                IWorkbenchPartReference ref = page.getReference(view);
                page.toggleZoom(ref);
            }
         } catch (PartInitException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return null;
    }
}