lundi 27 avril 2009

Weblogic : your basic needs

Weblogic is a big product, people may be affraid of it. Don't panic ! For an web application (either web, either enterprise, either anything java-webbie), you just need five things :
1. Having weblogic installed (that implies having a domain)
2. Two servers : even if one could be enough, it's not the way it's meant to be. So you better have two servers : one admin, one managed.
3. ADF Libraries installed and ready to go (when you create the domain)
4. If needed by your application, one JDBC Data source
5. And, of course, your application.

There you go :



More : you don't need to configure any node manager ;)

mercredi 22 avril 2009

ADF BC : Two ways of inserting rows

A good habit when developing is to keep in mind the Service Oriented Architecture (SOA). With ADF, your service layer is (are) application(s) module(s). With it, you expose views and methods. Methods could be : getManagerId, setManagerNameById, ... but not only getters and setters. You could have createManager, deleteManagerById, ...

Today I'm going to explain two methods for creating a new row.

1. createRow

public String myOwnCreateInsert_Person (int pid, String pname)
{
ViewObjectImpl vo = this.getPersonsUpdatable1();

try {
Row r = vo.createRow();
r.setAttribute("PersonId", pid);
r.setAttribute("PersonName", pname);
vo.insertRow(r);
}
catch (oracle.jbo.TooManyObjectsException tmoe) {
return "error";
}

this.getDBTransaction().commit();

return "success";
}


2. createAndInitRow

public String myOwnCreateInsert_Person (int pid, String pname)
{
ViewObjectImpl vo = this.getPersonsUpdatable1();

try {
NameValuePairs nvp = new NameValuePairs();
nvp.setAttribute("PersonId", pid);
nvp.setAttribute("PersonName", pname);
vo.insertRow(vo.createAndInitRow(nvp));
}
catch (oracle.jbo.TooManyObjectsException tmoe) {
return "error";
}

this.getDBTransaction().commit();

return "success";
}


---

Not to mention the second one is my favourite ; but it's doing the exact same thing. Why ? Check here.

Also, if you insert the new row in a table that contains a foreign key column, you should add this :

catch (oracle.jbo.DMLConstraintException dmle) {
return "error";
}

jeudi 16 avril 2009

JDeveloper : debug at runtime

I just discovered a neat functionnality, allowing you to easyly be aware of what's happening when you test-run you application.

Right click your project (for a fusion web application, it's ViewController here), go to the project properties. In the tab Run/Debug, edit the profile you want and in the input Java Options, add or insert this :
-Djbo.debugoutput=console

Now test-run your application : you'll see in the console everything the framework does, and I tell you, it's priceless when it comes to debugging at runtime.

JDeveloper : format your code

A nice functionnality with JDeveloper 11G : formatting your code. It does not anything wonderful, I agree, but it's pretty neat. On any page containing code, just right click and in source sub menu, click format.

There ya gaw :)

mardi 14 avril 2009

Deploying an ADF Application to Weblogic : two mistakes to avoid

Last friday I was supposed to demonstrate our application ; you may know that if you follow this blog. Actually we wasn't able to do show anything because of two errors ; I'm sharing with you :

1. Couldn't find jdbc datasource
In this article from Chris Muir is explained how to configure a jdbc datasource for an adf application deployed on weblogic. What's not actually told is what caused us troubles : the jdbc ds should not contain any "_" or "-" or any other special characters like these.
Because of that, the application was not able to resolve in the jndi tree the matching data source, and it was a source of error. Renaiming it in the application and on weblogic solved it.

2. 500 internal server error ; could'nt find faces context
It actually was a tricky one. On the welcome page of the application you have to input a login and a password, then click an action button. Clicking it, and others actions components in the application causes the server to crash due to an "internal error". Checking the logs revealed that the application could'nt find its context. The error in the stack trace pointed to a line of the backing bean action method which invoked a method-binding (with bindings.getOperationBinding("")). And on top of that, just so you know, the application behaved perfectly on integrated weblogic.

What causes the problem ? Check right now your web.xml, welcome-file node : we just had the name of the page :
/login.jspx
Instead, you should have :
/faces/login.jspx

In fact this is a known bug of Jdeveloper inherited from the 10g version. It is generated when you run the viewController project of the application for the first time. JDev asks you to set a default run target, wich is a jsp page, and write it in the web.xml under this welcome node, without /faces/.

But what's unresolved here -for me- is why this error only occured on the remote server, and not on the local integrated one.

jeudi 9 avril 2009

Going prod. Today!

Hi kids.

See, going prod on a one year project, one member -that's me-, is really exciting. Anyway : this blog is not feelings.

Here is a procedure I wrote after 1 month of fight with my prod server. It's inspired from Duncan's Mills, but his procedure did not worked for me. Mine is designed for JDeveloper 11g build 5188 and Weblogic 10.3 on a linux VM.

Oh. And I forgot : it's in french. I'll transalte someday if I ever take the time.

Update : it has been deleted since it's an intenal document :( You may ask me and I will email it right away.

mardi 7 avril 2009

Easy ADF ?

Not so easy.
The not-so-famous Application Developer Framework is quitte hard to seize. I'm currently on a project, by myself, using JDeveloper 11g. And we're going prod (with a pinch voice).

See, with ADF there are some really cool stuff. All RC (for Rich Client) components provide professional deisgn without effort. The AJAX technology built-in allow to do some cool stuff, without again, to much effort. Also, popup and dialog window : you've never seen such nice popups.

But, on the other hand, there are some incovenients. Let's say, on the top of my mind ...

- Displaying components the way you want is sometime a pita (pita ? we'll get back to that later)
- Application may not be stable with the only drags and drops of component. You have to fight for it (with a cave voice)
- In general, if you want to do something specific ... well. How to put it gently. Let's just say ADF Developpers will understand me here.Everything's said ! Wait no. What you may find on this blog : some serious shit (with a Dr Dre voice). I'm kidding.

You may find a lot of stuff related to ADF : development patterns, JAVA, designing application, nice stuff you may want to use, workarounds of certains issues, uses and tests cases ... All in one!

See ya