Skip to main content

· One min read

When you are running OC4J in stand alone mode you are using the HTTP server that is bundle with it. This HTTP server returns by default for the HTTP information the following information: Server: Oracle Containers for J2EE

If you want to change that you just need to set the http.server.header property. For example,

java -Dhttp.server.header="My blog on Oracle" -jar oc4j.jar

will now look like:

HTTP/1.1 200 OK
Date: Mon, 26 Feb 2007 21:52:53 GMT
Server: My blog on Oracle
Last-Modified: Mon, 09 Oct 2006 19:17:10 GMT
Accept-Ranges: bytes
Content-Length: 19882
Connection: close
Content-Type: text/html

Thanks to James Kirsh for this very useful tip...

· One min read

Packed with presentations on Grails, Groovy, Ajax & Web 2.0 and JavaEE and the core technologies that support the Grails technology, the first Grails eXchange conference (London from May 30th to June 1st) will be the place to be for any member of the Groovy/Grails community... You can already register on the conference web site: http://www.grails-exchange.com

Come to see speakers including Grails project lead Graeme Rocher, Groovy project lead Guillaume LaForge, creator of Spring Rod Johnson, Dojo's Alex Russel and Dylan Schieman as well as speakers from technology-leading organisations such as Google, Interface 21, JBoss, Oracle & Sun Microsystems

· One min read

In the previous entry I showed how you can easily take an XML feed and insert the content in the database. Let's do the opposite now, meaning taking the data out of your database as XML. In this post I am using the Sql Dataset again but to create an XML document, using the Groovy MarkupBuilder.

import groovy.sql.Sql;
import groovy.xml.MarkupBuilder;

def sql = Sql.newInstance("jdbc:oracle:thin:@//tgrall-linux:1521/XE",
"HR", "HR", "oracle.jdbc.driver.OracleDriver")
def set = sql.dataSet("EMPLOYEES");

def writer = new StringWriter()
def xml = new MarkupBuilder(writer)

xml.employees() {
set.each { emp ->
employee(first: emp.first_name , last: emp.last_name) {
email( emp.email )
}

}
}

println writer.toString();

As you can see, I use the builder to create XML Elements and attributes employee(first: emp.first_name , last: emp.last_name), I do reference the current record of the dataset (emp), and all this in very simple and concise code. This will give a result like:

<employees>
<employee first="'Steven'" last="'King'">
<email>SKING</email>
</employee>
<employee first="'Neena'" last="'Kochhar'">
<email>NKOCHHAR</email>
</employee>
<employee first="'Lex'" last="'De">
<email>LDEHAAN</email>
</employee>
...
</employees>

So once again quite simple.

· 2 min read

A friend of mine was looking for an easy way to import some XML content in his database. You have many ways to do it. But the easiest for a Java/Groovy developer is to use Groovy, and I have create this small example for him.

Groovy provides really simple solution to parse XML and manipulate your database. The following sample reads an RSS new feed and import the title and link in a table named NEWS that contains two columns TITLE and LINK.

import groovy.sql.Sql;

def rssFeed = "http://www.javablogs.com/ViewDaysBlogs.action?view=rss";
def xmlFeed = new XmlParser().parse(rssFeed);

def sql = Sql.newInstance("jdbc:oracle:thin:@//tgrall-linux:1521/XE",
"GROOVY",
"GROOVY",
"oracle.jdbc.driver.OracleDriver")
def set = sql.dataSet("NEWS");

(0..&lt; xmlFeed.channel.item.size()).each {
def item = xmlFeed.channel.item.get(it);
def title = item.title.value[0];
def link = item.link.value[0];
println("Importing $title ...");
set.add(TITLE: title, LINK: link);
}

First I create a Groovy SQL object and a DataSet to manipulate my data sql.dataSet("NEWS"). Do not forget, if like me you are using Oracle database, to add the Oracle JDBC driver to your classpath ;-)

Then I create a loop on each items of the RSS feed I am using: (0..&gt; xmlFeed.channel.item.size()).each {...}. As you see, Groovy XML help me to parse, and navigate the XML document.

Like any Groovy iterator you have access to an implicit object available in the loop "it", so I can get the item using the Groovy XML : xmlFeed.channel.item.get(it)

Then you can get the different values you want of the item element.Using the dataset.add method, you can insert them in the table.This is done using the value pairs notation column:value, this looks like: set.add(TITLE: title, LINK: link)

· 2 min read

When preparing a complex topology, where you have multiple HTTP servers ,talking with many OC4J instances, it is sometimes hard to understand what is going on. Oracle Application Server Control provides the complete view of your topologies in different pages. If you want to have a quick overview of your topology, you may want a more graphical view of your Oracle Application Server instance.

One of the tool that I use a lot to present OracleAS and its components is OracleAS Hi-Av Tool 10g (10.1.3) also known as iHat. This utility uses Oracle Process & Notification Manager (OPMN) to gather information of all the components used in your topology, representing it in a nice graphical viewer. In addition to use iHat to show the different components, I do also use that to validate my configuration.

iHat View

In this case I am showing a specific instance, that contains 3 OC4Js instance, with 2 of them that are in the same group. When using iHat you will notice that you can, in addition to have some monitoring information start, stop, restart the different components directly from the view.

How do you install and start iHat?

1- Download iHat from Utilities for Oracle Application Server 10g OTN page

2- Unzip it, and this becomes the $IHAT_HOME

3- You have an ORACLE_HOME that is pointing to one of the OracleAS instance, so you can start iHat using the follling command:

java -cp $ORACLE_HOME/opmn/lib/optic.jar:$IHAT_HOME/ihat.jar oracle.ias.opmn.ihat.WebServer 8181 $ORACLE_HOME

Using this command, iHat is starting an HTTP server on port 8181, and use the OPMN configuration of the $ORACLE_HOME that I you have entered as parameter. iHat provided other parameters such as the host-name and OPMN port if you want to connect remotely without dependency on the $ORACLE_HOME. All this, is documented in the readme file located in the iHat folder.

· 4 min read

OracleAS Web Services Runtime provides a support for stateful Web Services that is based on HTTP /Servlet session. Some people will probably say that Web Services should not be stateful, or at least not based on the protocol... However, today most of Web Services are using HTTP, and in some specific cases it is very useful to be able to have a state.

In this post, I am not explaining how to enable stateful services and clients, since it is documented in the Java Classes and Stateful Web Wervices chapter of the developer guide. Here I am show you how you can using client side programming share the same state (session) between different web services calls (even different services running in the same server side application).

The tip used here is about the association of cookies to the client instance (JAX-WS Stub or Call object). Here the code you have to write to do that using DII, will be very similar when using static Stub

1- Enable the state management

...
Service service = sf.createService(qName);
QName port = new QName("CartService");
Call call = service.createCall(port);
call.setProperty(Stub.SESSION_MAINTAIN_PROPERTY, Boolean.valueOf(true)); // this is necessary to be able to manipulate cookie
...

2- Create a Map that contains the Cookies and assign it to the call (or Stub)


...
Map cookieMap = new HashMap();
call.setProperty(ClientConstants.COOKIE_MAP, cookieMap);
...

This specific step associates a map that will contains all the cookie with the call/stub instance. You will be able then to manipulate the Map to get or set the cookies.

3- How to get the JSESSION cookie

private Cookie getJSessionCookie(Call call) {
Map cookies = (Map)call.getProperty(ClientConstants.COOKIE_MAP);

if (cookies != null && !cookies.isEmpty()) {
Iterator it = cookies.values().iterator();
while (it.hasNext()) {
Cookie cookie = (Cookie)it.next();
if (cookie.getName().equals("JSESSIONID")) {
return cookie;
}
}
}

return null;
}

Note that the Cookie object is an instance of Oracle HTTPClient.Cookie.

4- Utilizing the Cookie

So now you have all the information to be able to get the Session information when the stateful conversation has started;

In this example each time the call.invoke() is done, a counter is incremented on the server.

Call call = service.createCall(port);
call.setProperty(Stub.SESSION_MAINTAIN_PROPERTY, Boolean.valueOf(true)); // this is necessary to be able to manipulate cookie
Map cookieMap = new HashMap();
call.setProperty(ClientConstants.COOKIE_MAP, cookieMap);
... // The session will only be created after the first invoke
call.invoke(...); // counter = 1 call.invoke(...); // counter = 2 since on the same session

... // the session is now created so you can get the cookie
Cookie mySession = getJSessionCookie(call)
...

You can now use the cookie in another call using the following code:

mySession ..  // was extracted from the call #1
...// now I am creating a new call instance (myNewCall) that could be in another class
Call myNewCall = service.createCall(port);
myNewCall.setProperty(Stub.SESSION_MAINTAIN_PROPERTY, Boolean.valueOf(true)); // this is necessary to be able to manipulate cookie
Map cookieMap = new HashMap();
// add the cookie to the map this will add the cookie to the HTTP request so it will be associated to the same session (/state)
cookieMap.put(mySession,mySession);// associate the cookie Map to the call
myNewCall.setProperty(ClientConstants.COOKIE_MAP, cookieMap);
...
myNewCall.invoke; // counter = 3 since we share the same session
...

Using this sample you have 2 instances of a client calling a service and reusing the same session -state-. You can also use the same approach to have 2 different clients talking to different services and share the same session. To do that you will have on the server side to use the HTTP Session directly to store your data between calls, and share it between services.

· One min read

The Grails developer team is pleased to announce the release 0.4 of Grails. The release can be obtained from the downloads page.

Notable improvements include:

  • ORM enhancements with support for more relationship types, easy transactions and criteria building, constraints to SQL schema mappings, and upgrade to Hibernate 3.2
  • All-new non-invasive plugin system for writing reusable plugins for Grails applications
  • Greater Spring integration thanks to a new syntax for scripting Spring (http://grails.org/Spring+Bean+Builder) and an upgrade to Spring 2.0
  • Easier unit testing of controllers and custom taglibs
  • Validation improvements, including support for inherited constraints and simplified size constraint handling
  • Automatic encoding of unsafe HTML characters and URL parameters in all scaffolding and taglibs
  • Fixes to support Grails on more containers such as GlassFish and over 200 issues and bugs resolved in JIRA
  • Grails now ships with Groovy 1.0!

· 2 min read

Oracle JDeveloper (10.1.3.2.0) extends the SOA development features from the previous release by introducing the Oracle WebCenter extension. Oracle WebCenter Suite combines the standards-based, declarative development of JavaServer Faces (JSF), the flexibility and power of portals, and a set of integrated Web 2.0 services to boost end-user productivity. Oracle WebCenter Suite provides the tools and services to embed portlets, content, customizable components, Web 2.0 content, collaboration and communication services directly into your JavaServer Faces (JSF) application. These WebCenter features are in addition to the large set of new features that were introduced in Oracle JDeveloper 10.1.3.0 and 10.1.3.1.0. For more information on WebCenter, visit the Oracle WebCenter Suite page on OTN.

  • Build Portlets
    • Build JSR 168 portlets
    • Build Oracle PDK-Java portlets
    • Expose JavaServer Faces (JSF) applications as portlets
    • Preconfigured OC4J within Oracle JDeveloper
  • Consume Portlets
    • Consume JSR 168 portlets through WSRP
    • Consume other WSRP portlets
    • Consume Oracle PDK-Java portlets
    • Inter-component communication
  • Business User Web 2.0 Enterprise Mashup Tools
    • Rich Text / Blog Portlet
    • WebClipping Portlet
    • OmniPortlet
  • Runtime Customization
    • showDetailFrame
    • panelCustomizable
  • Integrate Content using JCR 1.0
    • Access content using data controls
    • Access to many content repositories
  • WebCenter Services
    • Secure Enterprise Search (SES)
    • Oracle Communication and Mobility Server (OCMS)
    • Oracle Content Database
    • Discussions
    • Wiki
  • Declarative Security
    • ADF Security Wizard
    • Authorization Editor
  • Lifecycle Tool
    • Embedded Lifecycle Tool
    • Command Line Lifecycle Tool
    • ANT Tasks

Some links: