Chapter 7: Creating Enterprise JavaBeans Components
If you are creating components from scratch in EAServer Manager, you must follow the steps in this section to deploy the component class and other classes that it depends on. If you deploy from JBuilder with the EAServer plugin, the plugin performs these steps for you. If you are using another EJB development tool that can export EJB JAR files, import the EJB JAR file as described in Chapter 9, “Importing and Exporting Application Components,” in the EAServer System Administration Guide. If you import an EJB-JAR file that calls EAServer components that are not implemented in the same JAR file, you must list the stub classes for the called components in the custom class list as described below.
EAServer supports hot refresh of components by using a Java class loader. This feature speeds the development process by allowing you to deploy new class versions without restarting the server. Repeat the steps below to deploy new versions of your implementation.
In a production environment, you may wish to disable refresh to improve performance. See “Disabling refresh” for details.
Deploying EJB component classes
Deploy the component class files, stub and skeleton files, and other classes required by the implementation to EAServer. For example, you may need to copy stubs for user defined types and utility classes that are in your component’s package.
If deploying class files, place each class in their respective java/classes package subdirectories. If deploying a JAR file, place it in the java/classes subdirectory.
The preferred code base is java/classes For security reasons, it is preferable to deploy Java components to the java/classes subdirectory or some other directory that is not accessible to HTTP downloads. Deploying to this directory also allows your component to be refreshed, and allows you to deploy classes in JAR files without reconfiguring the server’s CLASSPATH environment variable. If you deploy to another location, make sure it is listed in the server’s CLASSPATH environment variable.
Use EAServer Manager to configure the component’s custom class list, specifying the classes that must be loaded when your component is loaded or reloaded, as described in “Custom class lists for Java and EJB components”.
Use EAServer Manager to refresh the component by highlighting its icon and choosing File | Refresh. You can also refresh the component by refreshing the package, application, or server where it is installed.
Troubleshooting ClassCastException errors When calling javax.naming.InitialContext.lookup, if you see NamingContext exceptions with root-cause exception ClassCastException, check for the following errors:
You are casting to an incorrect type (check the class name of the object returned by lookup).
Your component has refresh enabled, and the custom class list does not contain some required classes.
Your component has refresh enabled, and calls a component that has refresh disabled or vice-versa.
For more information, see “Troubleshooting class loader configuration issues”.
In a production server, you may wish to disable refresh for Java components to decrease memory use and increase performance. When refresh is enabled, duplicate copies of common Java classes can be loaded for components. When refresh is disabled, you must restart the server in order for it to load a new version of your component class. You can also reduce duplicate in-memory classes by configuring the custom class list at the package, server, or application level as described in “Custom class lists for packages, applications, or servers”.
If your component calls another Java or EJB component, both must have refresh enabled or both must have refresh disabled.
To disable refresh:
Make sure the code bases for all classes used by your component are in the server’s CLASSPATH environment variable. JAR files referenced in the custom class list must be added to the server CLASSPATH setting, or expanded into the java/classes EAServer subdirectory.
Display the Component Properties dialog box, and click on the Advanced tab.
false (the default is true).
Restart the server for the changes to take effect.
|Copyright © 2005. Sybase Inc. All rights reserved.|