Manually clear your JDeveloper cache

Recently I’ve been working more and more with JDeveloper Extension Projects. When working with Extension Projects, you deploy to your target platform a lot. I’ve noticed that sometimes, your JDeveloper Platform gets confused with this and the extension you’re working on doesn’t load correctly.

For example, you deploy your extension to the target platform, you follow this deployment in the log file and you see it got deployed successfully. After this, you debug the extension and wait for JDeveloper to start up. However, when trying to debug the extension, you notice something isn’t working. 
While working on the ADF EMG Audit Rules extension, I noticed that sometimes none of the rules where configured in the Audit menu under Tools -> Preferences. This means that the whole extension wasn’t installed correctly. 

The easiest way to solve this, was for me to clear the JDevelopers cache manually. To do so follow the following steps: 
First close your JDeveloper, to make sure JDeveloper doesn’t lock any files. Then go to your Oracle_Home where you installed JDeveloper. There is a subfolder \Oracle_Home\jdeveloper\jdev\extensions:

In here, locate the extension you’re working on, and delete this jar file. In my case this was the ADF EMG Audit Rules extension.

Next navigate to your JDevHome and go into your system folder of JDeveloper:

In here you see your installed extensions, but you should be able to locate a system_cache directory as well. Delete this whole directory. 

After deleting this directory, go deeper into the system folder. You should be able to find the following location:
This is the system_cache of the JDeveloper you start when clicking 'Debug Extension', delete this system_cache folder as well.

After deleting these directories, startup JDeveloper again and open your project. Don’t forget to deploy to the TargetPlatform again and after this run or debug your extension.

This should’ve done the trick and you should be able to run your extension again. However, during the last few weeks, it happened to me one time that even this didn’t help and I had to delete the whole system folder instead of only the system_cache. 
You can delete this folder without any problems, because JDeveloper will recreate it for you, but you will lose your settings, preferences and configurations you made to JDeveloper or the integrated WebLogic server. 

Distribute your Extension with an JDeveloper Update Center

If you created an extension project, you can share this with others by creating a zip file. However, there is a powerful mechanism in JDeveloper called Update Centers. This blog will show you how you create an Update Center to share your own Extension Projects.

I’ll use my workspace from this blog about Audit Rules as example. Step 1 is creating an bundle.xml within your Project source. The bundle.xml should like like this:

    
        Audit Rules
        1.0
        Richard Olrichs
        http://www.olrichs.nl        
        
            
            
            
                       
            
                
           


In this XML file you configure some properties about your extension, like the name, author and the requirements. Most of this information you already configured in the Extension.xml as well. 

After this we need to create a new deployment profile. Go to your Project Properties, create a new Jar File deployment Profile. In the jar options, change the extension from .jar to .zip:

Go to your Profile Dependencies and tick the Project:

Now there are a few steps you need to take in the File Groups section:
  • First select the predefined Project Output and press Delete
  • Select the File Groups again and press New:
    • Enter ‘Extension Jar’ as name and choose ‘Libraries’ as Type.
    • Go to the Contributors under Extension Jar and make sure the jar file is selected. 
  • Again select the File Group and press New:
    • Enter bundle.xml as name and leave the Packaging as Type.
    • As Target Directory in Archive, enter: META-INF
    • Go to Filters under bundle.xml and deselect everything except the bundle.xml

The result should looks like this:

Now press OK to exit the properties. Right click your Project, select deploy and select the newly created deployment profile. This should result in a zip file being created by JDeveloper:

We’re now done with creating the zip file and bundle. You could share this zip and let other people install it on their JDeveloper. However, we rather distribute this through an update center. Typically, you want this zip file on a network drive or on the web, but in this example we’ll leave it locally on the computer. The general idea is the same.
Now we’re going to create the update center, this is a simple XML file, you can create this anywhere on your file system.

     
        Audit Rules
        1.0
        Richard Olrichs
        http://www.olrichs.nl        
        
                        
              
        URL_TO_JWS\Extension\deploy\DeployExtensionZip1.0.zip
    

It looks a lot like the bundle.xml that we created, with the exception of a location being presented as bundle-url. This is pointing to your zip file, in this case I left the zip file in the deployment folder.
Now, when you go to Help -> Check for Updates, you can add a new Update Center:

Enter a name and browse to the created XML file and click OK.
After this, unselect the Oracle checkboxes and only check your own update center and click Next:

You’ll find your extension here, if you click next, you see it is under the New installs. Now press Finish and after the popup for a Restart press Yes. After JDeveloper has been restarted, your plug-in has been installed.

Now we can have a look at the power of creating an update center over sharing the zip file. Imagine you’ve been working on your extension for some time and want to create a 2.0 version. The steps involved here are:
  • Update the bundle.xml.
    • Update the bundle version to 2.0.
    • Update the version of the update to 2.0.
  • Redeploy to create a new zipfile (also a 2.0 version).
  • Update the UpdateCenter XMLfile to be in sync:
    • Update the version of updates
    • Update the version in update
    • Update the bundle-url to point to the 2.0 zip.

Next we go back to the Check for Updates menu. Select our update center and unselect the others and press Next:
Here we see the new version of our Audit Rules, version 2.0.

Now, without distributing the new zip file again, anyone who has installed the update center, will be able to get the 2.0 version of your Extension project. 

Dynamic table height with the autoHeightRows property

Our use case was to have a table displaying data, with under this table some content. The content needed to be directly under the last table row. In ADF 12c this goes a lot better, but in ADF 11g, the table takes up some default space. 

I recreated this on a HR example application: 

ADF has a cool feature which can help in situations like this, it’s called ‘autoHeightRows’.  In the documentation of the af:table we can find the following information about this property: ‘The height of the component can grow to a maximum of 'autoHeightRows' after which a scrollbar is displayed.’

So if in the above example the autoHeightRows would be set to 2, we get the following result:

This is getting close to what we want, but if we would navigate to a different department, the table would still be incorrect, department 30 has only 6 rows in the table, which should be displayed without a scrollbar:

Luckily the autoHeightRows can also be defined by an expression. This means we can use the rangeSize to define this autoHeightRows property, after which the table will be stretched to the correct amount of rows:



Index page for Audit Rules

Over the last few weeks, I gathered and produced more and more info about Audit Rules, JDeveloper Extension Projects and other stuff related to creating Audit Rules.
I thought it might be wise to create some sort of an index page to refer to all these blogs, guides, articles and so on …

I will try to keep this page up to date. 

Oracle Documentation:


By the Community:


Open source projects on java.net:


Interesting Reads:


Published on www.olrichs.nl:


Feel free to let me know if I missed anything.