Pages

Showing posts with label IDE. Show all posts
Showing posts with label IDE. Show all posts

Friday, June 19, 2015

How to set up Eclipse template for inserting SLF4J Logger

Adding private static final Logger logger = LoggerFactory.getLogger(XXX.class); by hand to your Java classes is tiring.

Use Eclipse template. For SLF4J this looks as follows:
private static final Logger LOG 
  = LoggerFactory.getLogger(${enclosing_type}.class);
  ${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)}
Note, that there are two import statements, one for the Logger and another for the LoggerFactory class.

The single steps needed to configure this template in the IDE, is explained in an older post here.

Wednesday, April 9, 2014

Exclude external JavaScript libraries from beeing validated in Eclipse 4

Due to an Eclipse Bug, JavaScript errors of external JavaScript libraries are marked as erroronous showing the red failure marker even if JavaScript errors are excluded from the contents Markers view, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=349020

Workaround as spooted in the Eclipse bug history:
I have found that I can leave the JavaScript Validator enable and ignore 
specific files by adding a suitable exclusion pattern e.g. **/jquery*.js to 
the JavaScript/Include Path/Source/Excluded group 
(Project->Properties->JavaScript->Include Path->Source).

Sunday, June 23, 2013

Eclipse with Eclemma: java.lang.NoClassDefFoundError: oracle/security/pki/OracleWallet

Trying to determine the code coverage of my JUnit 4 tests with EclEmma an java.lang.NoClassDefFoundError was thrown. As we all love Java stack traces, here a short excerpt:
java.lang.NoClassDefFoundError: oracle/security/pki/OracleWallet
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:169)
 at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:57)
 at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
 at
 ...
What does my JUnit Test wants from the OracleWallet? The application uses JDBC for the access of the Oracle DB, but OracleWallet is never directly used in my application. Without Eclemma the tests are running successfully. Not nice.

This seems to be a known problem which is fixed in EclEmma 2.1.3, see http://sourceforge.net/p/eclemma/bugs/108/. If you don't want (or are not allowed...) to update, then the workaround is to exclude oracle.* from the coverage agent in the Code Coverage preferences, see http://www.eclemma.org/userdoc/preferences.html.

Sunday, April 21, 2013

Migrating Plug-in Configuration when updating Eclipse Release

I just downloaded the latest Eclipse Juno Release with the latest fixes etc. But how to migrate my plugins from my "old" Eclipse to the "new" one?

1. Export

First, you must export your plug-ins from your "old" Eclipse installation as follows:
1.0 Start your "old" Eclipse instance
1.1 Package explorer, right mouse click, choose Export

1.2 Choose Install: Installed Software Items to File

1.3 Select All and export to p2f file (remember the file path, as you will import this file into your "new" Eclipse instance)



2. Import

After exporting, you must import the exported p2f file to your "new" Eclipse installation as follows:
2.0 Shutdown the "old" Eclipse instance if you want to use the same workspace as used for the export and start your "new" Eclipse instance
2.1 Package explorer, right mouse click, choose Import

2.2 Choose Install: Install Software Items from File

2.3 Select your exported p2f file (see step 1.3 above)
2.4 Select All and Finish

That's it. Let me know if this was helpful!

Monday, June 18, 2012

How to set up Eclipse template for inserting Log4j Logger

Eclipse Template for inserting Log4j Logger

Tired adding private static final Logger logger = Logger.getLogger(XXX.class); by hand to your Java classes?
Use Eclipse templates! Navigate to Windows -> Preferences -> Java -> Editor -> Templates. And add following new template to the Java context:
private static final Logger logger 
  = Logger.getLogger(${enclosing_type}.class);
  ${:import(org.apache.log4j.Logger)}
Finally, this should look as follows:



Now, if you are in the Java context, then type "logger" followed by "Ctrl+space". You are invited to choose from different templates including your template entered above:



After choosing the template, you ending up with an added logger plus the corresponding Java import: