Introducing JDeveloper

Oracle JDeveloper is a J2EETM development environment with end-to-end support for developing, debugging, and deploying e-business applications. JDeveloper empowers users with highly productive tools, such as the industry's fastest Java debugger, a new profiler, and the innovative CodeCoach tool for code performance analysis and improvement.

To maximize productivity, JDeveloper provides a comprehensive set of integrated tools that support the complete development life cycle, from source code control, modeling, and coding through debugging, testing, profiling, and deploying. JDeveloper simplifies J2EE development by providing wizards, editors, visual design tools, and deployment tools to create high-quality standard J2EE components, including applets, JavaBeans, JavaServer Pages (JSP), servlets, and Enterprise JavaBeans (EJB). JDeveloper also provides a public Addin API to extend and customize the development environment and seamlessly integrate it with external products.

JDeveloper Covers the Complete Development Life Cycle

Java is a relatively new language, and Java development environments are catching up with traditional client/server tools. Developers now require a well-integrated development environment that supports the complete development life cycle:

In a typical scenario, a developer launches JDeveloper, checks out an application from the source control system and starts the development process. UML modelers help the developer with the design of the application, and possibly with the generation of source code. JDeveloper provides wizards and editor, both visual and code-based, to add functionality, and it includes various tools to compile, test, debug, and tune the application. When satisfied, the developer can check the application back into the source control system and deploy it to the final destination.

The 9i release of JDeveloper was completely rewritten in Java and now JDeveloper runs on any operating system that has a Java Virtual Machine (JDK 1.3 and later) and will be supported on Windows (NT, 2000, and XP), Linux and SolarisTM Operating Environment.

Another advantage is that the development environment is now fully extensible through the Addin API, which allows customers and third-party vendors to extend the product and integrate it with other products.

Java Alone Is Not Enough

Over the last few years, Java has become the programming language for the Internet. Some of the reasons for this popularity are its operating system independence, its simplicity, and its powerful component model.

To build complete e-business applications, however, developers will need more than Java alone. Oracle believes in, and has invested heavily, in the combination of Java, SQL, and XML. Java is used for programming the business and presentation logic, SQL for interacting with the database, and XML for passing information between loosely coupled applications.

JDeveloper helps developers build e-business applications using Java, XML, HTML, SQL, and PL/SQL. It provides various code editors and visual tools for each of these languages.

XML Tools in JDeveloper

The Oracle XDK is integrated into JDeveloper, offering many ways to create, handle, and transform XML. For example, with the XSQL Servlet, developers can query and manipulate database information, generate XML documents, transform the documents using XSLT stylesheets, and make them available on the Web.

Figure 24-1 JDeveloper's Schema-Driven XML Editor in Action

An XML Schema Definition defines the structure of an XML document and is used in the editor to validate the XML and help developers when typing. This feature is called Code Insight and provides a list of valid alternatives for XML elements or attributes in the document. Just by specifying the schema for a certain language, the editor can assist you in creating a document in that markup language.

Oracle JDeveloper simplifies the task of working with Java application code and XML data and documents at the same time. It features drag-and-drop XML development modules. These include the following:

XSQL Pages and Servlet support, where developers can edit and debug Oracle XSQL Pages, Java programs that can query the database and return formatted XML, or insert XML into the database without writing code. The integrated servlet engine enables you to view XML output generated by Java code in the same environment as your program source, making it easy to do rapid, iterative development and testing.

Oracle XML Developer's Kit (XDK) is integrated into JDeveloper, so that it offers many utilities to help Java developers handle, create, and transform XML. For example, when designing with XSQL Servlet, you can query and manipulate database information, generate XML documents, transform them using XSLT stylesheets, and make them available on the web.

Business Components for Java (BC4J)

To take J2EE application development to a higher level of productivity, JDeveloper now offers Business Components for Java (BC4J), a standards-based, server-side framework for creating scalable, high-performance Internet applications. The framework provides design-time facilities and runtime services to drastically simplify the task of building and reusing business logic.

Oracle Business Components for Java (BC4J) is a 100%-Java, XML-powered framework that enables productive development, portable deployment, and flexible customization of multitier, database-savvy applications from reusable business components.

These application services can then be deployed as either CORBA Server Objects or EJB Session Beans on enterprise-scale server platforms supporting Java technology.

The same server-side business component can be deployed without modification as either a JavaServer Pages/Servlet application or Enterprise JavaBeans component. This deployment flexibility, enables developers to reuse the same business logic and data models to deliver applications to a variety of clients, browsers, and wireless Internet devices without having to rewrite code.

In JDeveloper, you can customize the functionality of existing Business Components by using the new visual wizards to modify your XML metadata descriptions.

Integrated Web Services Development

JDeveloper integrates standard J2EE development techniques seamlessly with both the latest XML and emerging Web Services Standards (including SOAP, UDDI, and WSDL) and their Java-based equivalents. To preserve existing investments in PL/SQL and J2EE applications, JDeveloper makes it very easy for developers to create, deploy and consume Web Services from J2EE and PL/SQL applications using:

Figure 24-2 JDeveloper's XSQL Component Palette

Page Selector Wizard

When you need to create XSQL pages while building a web application, you can invoke Page Wizard which enables you to create XSQL Pages on top of either database tables directly or on top of BC4J View Objects. When you choose to build an XSQL Page on top of a BC4J View Object, you are prompted to select an application module from a list or create a new application module and then build the XSQL Pages based application.

XDK Features in JDeveloper

You can use the XML Parser for Java including the XSLT Processor and the XML SQL Utility in JDeveloper as all these tools are written in Java. JDeveloper provides these components.

Sample programs which demonstrate how to use these tools can be found in the [JDeveloper]/Samples/xmlsamples directory.

Oracle XDK Integration in JDeveloper

Oracle XDK for Java consists of the following XML tools:

XML Parser for Java

XML SQL Utility for Java

XML Java Class Generator

XSQL Servlet

XML Transviewer Beans

All these utilities are written in Java and hence can easily be dropped into JDeveloper and used with no further effort. You can also update the XDK for Java components with the latest versions downloaded from Oracle Technology Network (OTN) at http://otn.oracle.com/tech/xml.

Oracle XDK for Java also includes the XML Transviewer Beans. These are a set of JavaBeans that permit the easy addition of graphical or visual interfaces to XML applications. Bean encapsulation includes documentation and descriptors that make them accessible directly from JDeveloper.

Developing Web Applications in JDeveloper Using XSQL Pages

The XSQL Servlet is a tool that processes SQL queries and outputs the result set as XML. This processor is implemented as a Java servlet and takes as its input an XML file containing embedded SQL queries. It uses the XML Parser for Java and the XML SQL Utility to perform many of its operations.

The XSQL Servlet offers a productive and easy way to get XML in and out of the database. Using simple scripts you can:

Generate simple and complex XML documents

Apply XSL Stylesheets to generate into any text format

Parse XML documents and store the data in the database

Create complete dynamic web applications without programming a single line of code

With JDeveloper you can easily develop and execute XSQL files. The built in Web Server and the user's default Web Browser will be used to display the resulting pages.

Using Action Handlers in XSQL Pages

XSQL Action Handlers are Java classes which can be invoked from XSQL Page applications very easily. Since these are Java classes they can be debugged from JDeveloper just like any other Java application.

If you are building an XSQL Pages application, you can make use of the XSQL Action Handler to extend the set of actions that can be performed to handle more complex jobs. You will need to debug this Action Handler.

Your XSQL Pages should be in the directory specified in the Project Property "HTML Paths" settings for "HTML Source Directory".

To debug your Action Handler carry out these steps:

Assume you have created an .xsql file which has reference to a custom Action Handler called MyActionHandler.

Debug this Action Handler because it is not exactly behaving as you expect.

Set breakpoints in your Java source file.

Right mouse click on the .xsql file and then choose Debug... from the menu.

See Also:

The JDeveloper Guide under the online HELP menu.

Building XML Applications with JDeveloper

Consider the following example that demonstrates how XML is used to represent data, not present it. It shows the many to one relationship between employees and departments.

When you finish these steps in the Page Wizard, you should have an XSQL Page based on the Business Components for Java (BC4J) framework View objects. When you run this page, it sends the XML data to your browser. You could optionally create a stylesheet to format the data so that it appears in a way that you prefer or you can tune it so that it can be displayed on a PDA or cellphone.

Using XSQL Servlet from JDeveloper

XSQL Servlet offers a productive and easy way to get XML in and out of the database.

Frequently Asked Questions About JDeveloper and XML Applications

This section lists JDeveloper questions and answers.

How Do I Construct an XML Document in JSP?

I am dynamically constructing an XML document in a JSP page (from the results of data returned by a PL/SQL API) using the classes generated by the Class generator (based on a DTD) and then applying a XSL stylesheet to render the transformation in HTML. I see that this works fine only for the first time, that is, when the JSP is first accessed (and internally compiled), and fails every time the same page is accessed thereafter.

The error I get is:

"oracle.xml.parser.v2.XMLDOMException: Node doesn't belong to the current
document"

The only way to make it work again is to compile the JSP, by just 'touching' the JSP page. Of course, this again works only once. I am using Apache JServ.

How can this be overcome? Does the static code in the Java class generated for the top level node have to do anything with it?

Answer: It seems to me that you may have stored some invalid state in your JSP. The XML Parser picks this invalid state, then, throws the exception you mentioned.

As far as I know, CRM does not use an HTTP session in their application. I guess this is true in your case also. You may have used a member variable to store some invalid state unintentionally. Member variables are the variables declared by the following syntax:

<%! %>

For example:

<%! Document doc=null; %>

Many JSP users misunderstand that they need to use this syntax to declare variables. In fact, you do not need to do that. In most of cases, you do not need a member variable. Member variables are shared by all requests and are initialized only once in the lifetime of the JSP.

Most users need stack variables or method variables. These are created and initialized for each request. They are declared as a form of scriptlet as shown in the following example:

<% Document doc=null; %>

In this case, every request has its own doc object, and the doc object is initialized to null for each request.

If you do not store an "invalid" state in session or method variables in your JSP, then there may be other reasons that cause this.

How Do I Retrieve Data from messages.xml?

Is it, or will it be, possible to retrieve the data stored in messages.xml from the database? How is the document() instruction going to work where listener and servlet will run inside the database?

Answer: Yes. By the spec, the XSLT engine should read and cache the document referred to in the document() function. It caches the parsed document based on the string-form of the URI you pass in, so here's how you can achieve a database-based message lookup:

This is great if you want to fetch the message from over the web. Alternatively, you could use the msg.xsql preceding but include it in your XSQL Page if that makes sense using:

<xsql:include-xsql href="msg.xsql?lang={@lang}&amp;code={@code}"/>

Or you could write your own custom action handler to use JDBC to fetch the message and include it in the XSQL page yourself.

How Do I Move Complex XML Documents to a Database?

I am moving XML documents to an Oracle database. The documents are fairly complex. Can an XML document and the Oracle Developer's Kit (XDK) generate a possible DDL format for how the XML Document should be stored in the database, ideally generating an Object-Relational Structure. Does anyone know of a tool that can do this?

Answer: The best way may be to use the Class Generator. Use the XML SQL Utility (XSU) if DTD files are not already created. You'll still have to write a mapping program.

Another method is to create views and write stored procedures to update multiple tables. Unfortunately, you'll have to create your tables and views beforehand in either case.