Oliver's Blog

5 Posts

A lot of work has already been done in the area of desktop widgets by people like https://weblogs.sdn.sap.com/pub/u/251690412 [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] and Tarun Telang just to name a few. Although desktop widgets didn't worked out for me yet, a SDN Points on Your Desktop inspired me while I was working on my new blog. Wouldn't it be nice to have your SDN points in a dedicated space in your blog?

With this idea in my head I grabed a basic plugin source here and a feed import plugin there, took a tip from PHP expert Nigel James to look into curl for fetching websites and the result is the SDN Contributor Wordpress widget.

SDN Contributor Sidebar Widget

A picture can say more that a thousand words but for software it is better to see it running live. If you want to take a look I'm using the widget in a test instance of my blog at the moment.

It is designed to work as a sidebar widget in your wordpress blog and displays your name on SDN, your contribution points and your latest blog posts. There are also a couple of minor things to configure like the widget title, the number of blog posts to display and if you want to have the publishing date and a short desciption for each blog post.

SDN Contributor Configuration

For the widget to work, it is necessary that you provide it with your Business Card id and your blogger id. If you don't provide any of them (maybe you haven't written a blog on SDN yet) its related information simple won't be displayed.

I have set up a Wiki page on my own server where you will find a lot of additional information, installation instructions and a download link for the widget.

As far as I know it isn't possible to add new plugins to a blog hosted by Wordpress.com (that's why I moved my new blog to my own server) so you have to host your blog on your own to make this work.

It always good to get some feedback so let me know what you think, if and where you use it for your blog and if you would like to see more or other information displayed. Maybe you have your own blog but it's not running on Wordpress. The basic functionality should be fairly easy to port to other platforms as well so don't hasitate and give it a try.

Oh and I have to admit, the new blog editor here is so much better. Thanks SDN!

Dealing with databases on SAP NetWeaver Java stack is is usually done by using JDBC. Each installation of an app server has a standard db schema named sapdb which SAP encourages you to use for your applications via OpenSQL , SAP's database abstraction layer for Java. There are a couple of advantages that you get by using OpenSQL, e.g. support for Java Dictionary (which lets you deploy your table definitions and data types from NWDS), Table Buffer, Statement Pool, SQL Checker and SQL Trace. Further by using SQLJ, part of the OpenSQL framework, you get compile time checks for your SQL statements and that's one thing we all really like in ABAP, do we?

 

In order to connect to this standard schema you would probably use a resource reference to connect from EJB like this:

 

java.sql.DataSource ds =
  (java.sql.DataSource) jndiCtx.lookup(“java:comp/env/datasourceRef”);

 

When connecting from outside of EJB you should use a DataSource Alias (DSA) instead. You define a resource reference and DSA as parts of your application. By that your application is easy portable once you need to move it to a new database instance or schema. You'll find more on this in the DataSource Alias FAQ.

 

Welcome to RL

 

When you find yourself in a situation where you can't use the standard schema, you'll face a couple of problems you may wouldn't expect.

 

1. OpenSQL is only supported in the standard schema. Each additional schema has to use either Native_SQL or Vendor_SQL. That means you'll loose a couple to many of the advantages mentioned before, because they are only supported in OpenSQL.

2. It may not always easy for a developer to get the necessary access to the server for setting up a new DataSource and as a developer being dependent from an administrator isn't always desirable.

 

There are a couple of ways to create a new DataSource and most of them need an administrator account or direct access to the servers file system.

 

1. Probably best know procedure is to use our all favorite admin tool Visual Administrator, a rich client but you'll need an admin account for that. (docs@help.sap.com ).

2. Second best known is probably the web based version using NW Administrator but to get access to it you'll face the same hurdles as with VA. (docs@help.sap.com ).

3. For the ones who prefer to use a shell there is the MAKE_DATA_SOURCE from DBPOOL. Be sure to have file system access on the server here. (docs@help.sap.com ).

4. There is a fourth way to deploy your new DataSource as a part of your application. The only thing you need here is the SDM password that you probably already have for your usual deployments. The official documentation is a little weak on that point. So let's take a look at the necessary steps for this task.

 

DataSource Deployment

 

A DataSource definition used in a NW Java stack is described by a XML file that is based on a data-sources.dtd. You can generate a proper data-sources.xml file from this DTD definition. Another way is to create a new DataSource in Visual Admin under Services->JDBC Connector and export it as shown below.

 

 

That way you already have the necessary information filled into the right place. Just make sure to set for the +password +tag the attribute encrypted to +false +and provide the right password.

 

 

Next you have to store both files data-sources.dtd and data-sources.xml into the META-INF directory inside your Enterprise Application Project so that they will get deployed as part of your .ear archive.

 

 

That's it and with your next deployment you'll find your new created DataSource on your app server. Access to it is the same as for a DSA.

 

The Sad Part

 

One thing to keep in mind is that when you go with an alternative db schema you can't use Open_SQL anymore because this is only supported for the standard schema as mentioned already above. You therefor have to switch to Native_SQL, which has to be configured in your DS definition like this.

 

 

Another option is to use Vendor_SQL but you should do this unless you have some good reasons and know exactly what you're doing. You can find more about the differences in this SDN article.

At the time when one of the early release versions of Firebug came out I was looking for a nice JavaScript debugger. Firebug looked promising and already polished. Somewhere around early December a friend of mine pointed me to the first Firebug RC. I was hooked. They made a weapon and it's free. This is a MUST HAVE for every serious web developer! HTML & CSS ToolsFirebug has an inspector for HTML and CSS that let you see, how an element of a web page is coded by just hovering it. Here it doesn't only show the the direct responsible CSS code but also all code inherited. They do this in a very dynamic and interactive way that you have to see. JavaScript ToolsJavaScript support in Firebug is close to perfect. You get a full featured debugger including watch statements, normal and conditional breakpoints, single step debugging or break on the first error. Additionally it lets you profile your JS code and logging calls to any function in your code. DOM ExplorerTo help you navigate inside your code Firebug provides a good DOM explorer that let you change values even including autocompletion. Network MonitoringTo give you a further look behind the curtain Firebug has a build in network monitor that let you see e.g. how long each file takes to load and which files are already cached. It also gives you monitoring of XMLHttpRequest calls and let you examine HTTP headers. Firebug in other browsersNext to version 1.0 they released a lite cousin of Firebug that can also be used in other browsers than Firefox eg in Internet Explorer. Here you can find download and installation instruction for Firebug Lite.  Once you get knee deep into Firebug be sure to check out Joe Hewitts expert level introduction: Joe Hewitt: "Welcome to Firebug 1.0" Firebug and Web Developer Toolbar. I wish I had theese ten years ago.
Oliver Kohl

Pimp Up My NWDS Part 2

Posted by Oliver Kohl Aug 22, 2006

Welcome to part 2 in our series about the extensibility of NetWeaver Developer Studio (NWDS) through plug-ins.

In the Pimp Up My NWDS Part 1 I showed up a way to install and manage additional plug-ins in NWDS without modifying the standard file structure to much. This approach gives you more flexibility when doing an upgrade and also helps you maintaining the same set of plug-ins for two different NWDS installations on the same machine, e.g. for NetWeaver04 (6.40) and NetWeaver2004s (7.0).

In this part I want to show you a plug-in that will check your code using static code analysis to give hints to possible bugs and anti patterns and inefficient code. This way it will help you write better and often faster code.

PMD

PMD finds possible problems and shortcomings in your programs by analysing the Java source code. It does this by using a set of rules that you can run on your programs source code to find unused variables, unnecessary object creation, empty catch blocks, and so forth. Rules in PMD are defined in an extensible way that let’s you write your own rules specific for your organization or project.

PMD is already covered in a Analysing your Java code with PMD so I won’t go into many details but show you how to use it in NWDS. If you want to get deeper knowledge about PMD there is also a book PMD Applied written by one of its lead developers, Tom Copeland.

As most of today’s plug-ins PMD is currently developed for Eclipse 3.x but there is one brave hero still maintaining an Eclipse 2.x version named pmd-eclipse-2.3 that is only one minor version behind the official release. You can get it at PMD’s official download site. After downloading follow the instructions for installation covered in Pimp Up My NWDS Part 1.

Correctly installed PMD will give you two ways to check your code in NWDS. One way is to trigger the code checks manually against single files, folders or projects. Therefore you have to select a node or element in the Navigation view. Right click the element and the resulting context menu will show an entry PMD with several subentries. Select Check Code With PMD to start it.

The other way is to enable PMD in the project properties. Here you can also define a specific rule set for you project. This way code analysis will executed each time a file is added or saved.

image

The results of the code check will be displayed in the Tasks view or in the special PMD Violations view, which gives a more tailored display and more specific filtering options.

image

The PMD Violations view gives a more detailed view on the detected problems. It includes e.g. a severity level for each entry to help you prioritize your pending violations or filter the displayed entries. In case you don’t remember the cause of the violation you can also get more detailed information for each of the violated rules by selecting Show Rule from the context menu for an entry.

Either if you use PMD for your own project or if you introduce coding standards into an organisation it is a good practice to tailor the number of rules to the specific needs. In a project this set can be defined by a joint decision and then imported into each single NWDS.

To configure a NWDS global rule set (project specific rule sets can be defined in the project properties) open the Preferences window and go to the PMD->Rules Configuration entry. Here you can see a list of all the available PMD rules. From this list, you can go through the rules, adjust priorities, modify any of the other rule-specific properties, or remove any rules you don't need. If necessary export your defined set and import it to any other NWDS.

image

That’s basically all you need to know about PMD in an NWDS environment. Let’s hope that the Eclipse 2.x version will be maintained another couple of month (or years?) until we get our hands dirty in a New York (a.k.a. NetWeaver 7.1) project.

Checkstyle and Findbugs

There are two other well knows tools that can help you in your development process in a similar way like PMD.

Checkstyle by Oliver Burn also analyses your code, like PMD, using the Java source. There is an Eclipse plug-in available named CheckClipse. Even though you still find a compatible 2.x version on the download page it won’t be maintained anymore and is frankly two years old now. But maybe you like it and give it try anyway or use the stand alone version.

Code analyser FindBugs by Bill Pugh takes a different approach on this topic. It examines your class or JAR files looking for potential problems by matching your bytecodes against a list of bug patterns. Checking is also done using a set of rules but because it works on the bytecode the results of course very different from what you would get with PMD or Checkstyle. Sadly the Eclipse 2.x plug-in situation is the same as with Checkstyle so if you want to try it out in NWDS you have to deal with an old version from 2004 or use the stand alone version.

Conclusion

PMD and similar tools can help you significantly reduce the time and afford involved in code reviews. All code conventions and best practices, which can be described by rules, can automatically be verified in the development process. Seamlessly integrated into your IDE they popup if necessary and get out of the way otherwise. On the other hand any automated code analysis won’t replace human code reviews, as there will always be errors that can’t be detected by machine analysis.

That’s it for part 2 of Pimp Up My NWDS. The last thing that’s missing is to point you to a nice weblog by Maksim Rashchynski The Story About How 2 Eclipse Plugins helped me to make a lot of points on SDN forum were he talks about JadEclipse and JAR Class Finder, two plug-ins which helped him getting points in the forms. Thanks Maksim!

Oliver Kohl

Pimp Up My NWDS Part 1

Posted by Oliver Kohl Jul 24, 2006

SAP's decision to use Eclipse as their RCP for the NetWeaver Developer Studio (NWDS) has been a great decision for us developers. Eclipse has been developed by IBM and was released as open source in 2001 and got a lot of attention in the developer community. One of the main reasons may have been that Eclipse was designed as a Rich Client Platform (RCP). A RCP is an application skeleton providing a plug-in framework that is used for building extensions. That said and by providing its own plug-in SDK out of the box, it becomes natural that Eclipse has always been a playground for developers. A lot of plug-ins have been build by the open source community using Eclipse itself. This gives you the ability to configure Eclipse to your special needs so that you don't have to leave your favourite IDE for most of your development tasks. In addition Eclipse has a build in Software Update Service that guides you for the tasks of downloading and installing plug-ins and keeping them up to date with the latest versions.

Only a few weeks back the latest Eclipse IDE version 3.2 was released. Unfortunatly NWDS for NetWeaver 2004 and 04s are based on Eclipse 2.x wich was released back in 2004. Because of a major change in the plug-in SDK from version 2.x to 3.0 all of the new plug-ins for 3.x won't work on the older releases. It's of course the 3.x release where most of the plug-in current development happens but you will still find older plug-ins for the 2.x release on the net and a handfull of them are still maintained for both releases.

In this series of articles I want to show you how to extend NWDS in a clean and easy way using free or even open source third party plug-ins that I have found on the net. The version I'm using here is NWDS 6.40 (2.0.14) but it works the same way in the latest NWDS 7.0 for NetWeaver 2004s! Unfortunately SAP has disabled the build in Software Update Service so that we have to manual install our plug-ins.

But before we start to add our first plug-in to the NWDS we have to do some preparations that help us in our task.

Log output to console and debug mode

To get a little insight into what's going on with NWDS and its plug-ins we are going to start it in debug mode with console output. Normally there should already exist a shortcut in your start menu with an additional "(Console)" in its name. If not create one.

The target field should read similar to this:
C:\Programme\SAP\IDE\eclipse\SapIde.exe -vm "C:\Programme\Java\jre1.5.0_06\bin\java.exe" -consolelog -debug

Starting NWDS using this shortcut will bring up a console window like this one:

image

Now we have a better look on what’s going on e.g. when a plug-ins throws an exception. You will find more information about the Eclipse runtime options on the Eclipse online documentaion.

Setting up an additional plug-in directory

Eclipse has the ability to load plug-ins that do not reside in the usual plug-in directory. This helps us from separating our extensions from the standard installation and will also give us the ability to have the same plug-ins for different NWDS installations on the same machine.

We assume NWDS is installed at C:\Programme\SAP\IDE\
Follow these steps:

  1. Create a directory where you want to store the Eclipse plug-ins. Let's assume we take C:\plugins.
  2. Create a directory named "eclipse" in your in step 1 created directory.
  3. Create two directories with the names "features" and "plugins" in the directory created in step 2. This is where actual the plug-ins get stored.
  4. Create a directory named "links" in your Eclipse directory at C:\Programme\SAP\IDE\eclipse.
  5. In your newly created "links" directory at C:\Programme\SAP\IDE\eclipse\links create a text file named ".link".
  6. Write the path to the newly created plug-ins directory into the file like this: path=c:/plugins
Be aware to use forward slashes even on Windows!
Now NWDS will look into the new created plug-ins directory at start up for additional plug-ins to load.

 

The first additional plug-in

The first plug-in I want to introduce here is Class Locator by Dani Kenan and Avner Linder. It will help you to find classes that are not in the current project’s classpath, automatically adds the location to the projects classpath and also adds the necessary import statement to your source. Writing applications for big frameworks like SAP’s Enterprise Portal you don’t want to miss this nice goody anymore.

To install Class Locator download the latest version from this location and unzip it to our newly created plug-in directory at C:\plugins\eclipse\plugins (the features directory won’t be used in this case). To active plug-ins you need to restart NDWS afterwards.

If the installation was successful you should now have an additional menu entry from where you can start a wizard to look up a class.

image

But before you can do that you need to set up the locations where you want Class Locator to search. A good start should probably the NWDS plug-ins directory (this time the original in the Eclipse directory) where the NetWeaver specific JARs are stored.

image

Now you can look up a JAR and its location by using the wizard or by selecting a class name and using the context menu.

image

Class Locator will show you all the JARs it has found where the class is included. Choose the one you need and Class Locator will extend the classpath of your project and will add the necessary import statement to the current active source.

You will find additional documentation for Class Locator here.

That’s all for now. Thanks for being with me and be sure i'll come back with more plug-ins to show.

Update & Disclaimer: This blog was created during my time when I was not with SAP. The process described here is not supported by SAP. For any help and support please get on contact with the community of the tool in question.