Wednesday, 19 June 2013

Oracle Serive Bus: Get file name from proxy service

The following is how to get the file name of a file that is being processed by a proxy service in OSB.

1. We can get the URI via the $inbound context variable with the following XPath:
$inbound/ctx:transport/ctx:request/tp:headers/file:fileName

This results in:
<file:fileName
xmlns:file="http://www.bea.com/wli/sb/transports/file">
c:\temp\input\2635978486281_
test.xml</file:fileName>

2. To get the filename only, use the tokenize function (which returns the characters after the last "\\":
tokenize($inbound/ctx:transport/ctx:request/tp:headers/file:fileName, "\\")[last()]

Tuesday, 18 June 2013

Auto increment primary key with Oracle Databases

Suppose you have a database and you want each entry to be identified by a unique number. This can be achieved easily in MySQL by specifying "auto_increment" for the column, but Oracle requires a little bit of extra work to get this done.

One way to do it is by creating two database objects, a sequence and a trigger:

1. As a simple example, imagine we have a table called "tbl_test" with two columns, "test_id" and "test_data".
create table tbl_test (test_id number, test_data varchar2(145)); 

 2. Now, we create a sequence for the test_id column. Note that the numbering starts with 1 and is incremented by 1.
create sequence seq_test 
start with 1 
increment by 1 
nomaxvalue; 

3. Next we create the trigger that will automatically insert the next number from the sequence into the test_id column.
create trigger tgr_test 
before insert on tbl_test 
for each row 
begin 
select seq_test.nextval into :new.test_id from dual; 
end;
/

XMLType in SQL Developer

I thought I'd add this as for someone new to SQL Developer, this is not obvious at first glance. When creating a table with column(s) of type XMLType, the type is not available via the standard Create Table wizard. Below are the full steps to use that datatype:


  • Right-click on the 'Tables' node in the 'Connections' view
  • Select 'New Table'
  • Check the 'Advanced' check box located in the top right corner - This will show an alternate 'Create Table' dialogue which hosts considerably more functionality
  • In the 'Column Properties' area, select the 'Complex' radio button for datatype
  • Choose the SYS schema; the XMLType will be available in the drop down

Wednesday, 9 January 2013

Eclipse: "Resource is out of sync with file system"

I got this error when I tried renaming a Project in Project Explorer in Eclipse:

Resource is out of sync with file system

To fix this error: Right-click on the Project and select Refresh.

This error can be avoided via auto-refresh. To turn this on check the Refresh Automatically option found within the Preferences tab:

Window > Preferences > General > Workspace

Monday, 26 November 2012

Unexpected error during Oracle Service Bus synchronization.

I was attempting to export my OSB project as a Jar in Eclipse OSB 11g, but I was getting this error (visible in the Problem tab) which was halting my progress:

Unexpected error during Oracle Service Bus synchronization. Please see the logs for more information.

A solution I found for this was:

  1. Close all projects (including the OSB Configuration Project) in the Eclipse Project Explorer, except for the OSB Project you are trying to export.
  2. Refresh the OSB Project
  3. Reopen the OSB Configuration Project that corresponds to the OSB project




Tuesday, 13 November 2012

Eclipse OSB 11g: "This project is not associated with an Oracle Service Bus Configuration"

If you receive the error:

"This project is not associated with an Oracle Service Bus Configuration"

Go to Oracle Service Bus perspective (top right). Now you can drag your project into a OSB Configuration project in the Project Explorer. If there is not an OSB Configuration project available, create one (File > New > Oracle Service Bus Configuration Project).

Wednesday, 11 July 2012

The Java EE server classpath is not correctly set up - server home directory is missing.

I received this error when running 'clean dist' for my Java web application from Jenkins but it can also occur in NetBeans:

The Java EE server classpath is not correctly set up - server home directory is missing.
Either open the project in the IDE and assign the server or setup the server classpath manually.
For example like this:
ant -Dj2ee.server.home=<app_server_installation_directory>

The solution I found for this was to add this line to nbproject/project.properties:

j2ee.server.home=http://localhost

After this change the build was successful.