Chart Enterprise Java Bean (EJB) deployment model takes advantage of J2EE multitiered distributed application model which is particularly suitable for large scale applications. Davisor Chart provides explicit support for such applications with an EJB remote interface that can be used through standard J2EE usage models. The "davisorchart.jar" found from the Chart download package is a multipurpose class library containing also Chart EJB classes.

A J2EE application is delivered and installed in an Enterprise Archive (EAR) file. The EAR file contains all J2EE modules used by the application, like EJB components. A J2EE application using Davisor Chart as an EJB component should resemble following structure. To learn more about the J2EE standard visit Sun's J2EE pages.

Underlined file names should have been edited and green colored files should have been copied from the Davisor Chart package.
Copy the davisorchart.jar from "chart/WEB-INF/lib" to your EAR main directory. ChartEJBObject class in the davisorchart.jar is pre configured to run as a stateless session bean, but the just added EJB-JAR must be configure for the application by editing a "application.xml" file.
<module>
<ejb>davisorchart.jar</ejb>
</module>
When the enterprise application is deployed to a J2EE server the server will identify the EJB classes inside the davisorchart.jar based on the meta data found in "META-INF/ejb-jar.xml" file.
When EJB is referenced from a web module a "ebj-ref" setting must be added to the "WEB-INF/web.xml" file. There should also be a configuration that maps EJB JNDI name to EJB reference name. In this example the reference name is "ejb/chart". JNDI to EJB ref mapping is done in a server specific way, typically with an extra XML configuration file. You can find example files for Bea Weblogic and JBoss from this directory. The davisorchart.jar also contains ready made EJB name to JNDI name mappings for Weblogic and JBoss. The JNDI name used is "ejb/chart".
<ejb-ref>
<description>Chart EJB</description>
<ejb-ref-name>ejb/chart</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.davisor.ejb.chart.ChartEJBHome</home>
<remote>com.davisor.ejb.chart.ChartEJBObject</remote>
</ejb-ref>
You can build servlets that returns chart content directly or servlets that forwards control to a JSP page. Eitherway there are three common steps:
// 1. Lookup a Chart home interface from a JNDI.
Context initialContext = new InitialContext();
ChartEJBHome home = (ChartEJBHome) PortableRemoteObject.narrow(
initialContext.lookup("java:comp/env/ejb/chart"), ChartEJBHome.class);
// 2. Get reference to a Chart EJB interface from a home interface.
ChartEJBObject chartEJBObject = home.create();
// 3. Collect data from other resources like EJB's or use Chart XML
// to get direct connection to a data source.
// 4. Create a Chart object.
// Arg 1: URL context used to create a valid URL address (can be null)
// Arg 2: Chart XML doc name
// Arg 3: Map of attributes used in Chart XML (can be null)
Chart chart = chartEJBObject.createChart(URLContext, ChartDoc, null);
// 5. Return the chart image directly or forward control to a JSP page with out tag.
This example will not run if "ejbServlet" example servlet or Chart EJB is not configured correctly and if the used server does not have EJB support.
If you like to get a ready configured "chart.ear", please contact support@davisor.com