Set - 4

Question 1 :

When configuring a source or target messaging bridge destination, do I need to set the Adapter Classpath field?

Answer :

Leave the Adapter Classpath field blank when connecting to source and target destinations that are both running on release 6.1 or later. When connecting to either a source or target destination that is running on release 6.0 or earlier, the Adapter Classpath field must indicate the location of the classes for the earlier WebLogic Server release. When connecting to a third-party JMS provider, the bridge destination must supply the provider's CLASSPATH in the WebLogic Server CLASSPATH.


Question 2 :

Can the messaging bridge forward durable subscription messages between separate WebLogic Server 6.1 and release 7.0 or later domains?

Answer :

Yes, as long as the WebLogic 7.0 domain is using Service Pack 1 or later. To enable durable messages across the messaging bridge using the Administration Console, select the Durability Enabled attribute on the Messaging Bridge —> Configuration —> General tab.


Question 3 :

How do I enable debugging for the messaging bridge?

Answer :

You can enable debugging for the messaging bridge using either of the followings methods:
* Add the following lines to your WebLogic start script (before the weblogic.Server line):
-Dweblogic.Debug.DebugMessagingBridgeStartup=true
-Dweblogic.Debug.DebugMessagingBridgeRuntime=true
* Add the following statements to the ServerDebug entry in your configuration file (config.xml) for the server that the messaging bridge is running on:
DebugMessagingBridgeStartup="true"
DebugMessagingBridgeRuntime="true"
Once debugging is enabled for the messaging bridge, the debugging messages are sent to the server log by default. However, if you want them to appear in the Administration Console, add "DumpToConsole" to the statements show above. For example:
-Dweblogic.Debug.DebugMessagingBridgeStartupDumpToConsole=true


Question 4 :

How do I configure WebLogic to use a SOCKS proxy?

Answer :

You can configure a java.net socket to use SOCKS by setting a Java system property.


Question 5 :

How does WebLogic support CORBA and client communication via IIOP?

Answer :

"CORBA" support means many things to many people. It often means simply IIOP /ORB support and not much on CORBA services. WebLogic supports CORBA in multiple ways.
First, Java clients can tunnel through a CORBA environment to WebLogic Server. We call this "IIOP tunneling," and it is intended for use with applets coming through an IIOP firewall, such as the IONA Wonderwall product. This is a Java-to-Java model riding over an IIOP communications framework.
WebLogic RMI over IIOP provides RMI services for many clients (including CORBA clients) over IIOP.
WebLogic Enterprise Connectivity enables you to create IIOP connection pools to a BEA WebLogic Enterprise System, allowing you to execute WebLogic Enterprise CORBA objects from WebLogic Server servlets and Enterprise JavaBeans.


Question 6 :

Can WebLogic Server start with a UNIX boot?

Answer :

You can add a startup script to your UNIX rc scripts to run WebLogic Server at UNIX boot time. Here is an example from an HP-UX 11 system, running under JDK 1.1. You need to supply the URL for your WebLogic Server and your system password. This file, wlstart, is placed in the /sbin/init.d directory and there is a link to it in the /sbin/rc2.d directory:

export SHLIB_PATH=\
/home/user1/weblogic/lib/hpux11:/oracle/8.0.4/lib
export CLASSPATH=/home/user1/weblogic/classes:\
/home/user1/weblogic/lib/weblogicaux.jar
export ORACLE_home=/oracle/8.0.4
export ORACLE_SID=DEMO
export ORACLE_TERM=vt100
export QAT=/home/user1/weblogic
cd $QAT
PATH=/sbin:/usr/sbin:/usr/bin:/opt/java/bin
export PATH
case $1 in
'start')
java -ms64m -mx64m -verbosegc weblogic.Server > \
/home/user1/weblogic/server.out 2> #emp;
;;
'stop')
java weblogic.Admin URL shutdown system password
;;
*)
echo "usage: $0 {start|stop}"
;;
esac

You should work with your UNIX system administrator to set up scripts similar to this for your system


Question 7 :

Why do I get "NoClassDefFound"/"Too Many Open files"messages on Solaris?

Answer :

Problem: When I am using WebLogic Server on Solaris and try to run my application, I get a "NoClassDefFound" error, although the class causing the error does exist and is in the right directory. In fact, there are other classes in the same directory that are getting loaded. I also get a "Too many open files" error.

We have seen this situation when the user account runs out of file descriptors. On Solaris, each user account has a certain limited number of file descriptors. You can find out how many file descriptors you have with the limit command in csh.
You can increase file descriptors if you have enough privileges with the ulimit command in the csh. Otherwise, ask your system administrator to increase the file descriptors available to your processes.


Question 8 :

How do I increase WebLogic Server memory?

Answer :

Increase the allocation of Java heap memory for WebLogic Server. (Set the minimum and the maximum to the same size.) Start WebLogic Server with the -ms32m option to increase the allocation, as in this example:
$ java ... -ms32m -mx32m ...
This allocates 32 megabytes of Java heap memory to WebLogic Server, which improves performance and allows WebLogic Server to handle more simultaneous connections. You can increase this value if necessary.


Question 9 :

What causes Java.io exceptions in the log file?

Answer :

You may see messages like these in the log file:
(Windows NT)
java.io.IOException Connection Reset by Peer
java.io.IOException Connection Reset by Peer

(Solaris)
java.io.Exception: Broken pipe
These messages occur when you are using servlets. A client initiates an HTTP request, and then performs a series of actions on the browser:
1. Click Stop or enter equivalent command or keystrokes
2. Click Refresh or enter equivalent command or keystrokes
3. Send a new HTTP request.
The messages indicate that WebLogic Server has detected and recovered from an interrupted HTTP request.


Question 10 :

Java-CORBA integration: RMI-IIOP or Java IDL?

Answer :

It is important to understand the distinction between these two ways of integrating Java with CORBA.
RMI-IIOP is for Java programmers who want to program to the RMI interfaces but use IIOP as the underlying transport. RMI-IIOP provides interoperability with other CORBA objects implemented in various languages, but only if all the remote interfaces are originally defined as Java RMI interfaces. It is of particular interest to programmers using Enterprise JavaBeans (EJBs), because the remote object model for EJB is RMI-based.
Java IDL is for CORBA programmers who want to program in Java based on interfaces defined in CORBA IDL. This is "business as usual" CORBA programming, supporting Java in exactly the same way as other languages like C++ or COBOL.


Question 11 :

How do an RMI-IIOP application and an existing CORBA object interoperate?

Answer :

If the existing CORBA object has its remote interfaces defined originally in CORBA IDL, then interoperability is not possible. RMI-IIOP applications can interoperate with other CORBA objects only when their remote interfaces are originally defined as Java RMI interfaces.
For example, to interoperate between an RMI-IIOP client and a C++ object you need to:
1. Define the remote interface of the object in Java as an RMI interface.
2. Run rmic -iiop against the interface to produce the stub for your RMI-IIOP client.
3. Run rmic -idl against the interface to produce IDL compatible with the RMI interface.
4. Run a C++ stub compiler against the IDL file to produce the C++ skeleton for your C++ server object


Question 12 :

What is the function of T3 in WebLogic Server?

Answer :

T3 provides a framework for WebLogic Server messages that support for enhancements. These enhancements include abbreviations and features, such as object replacement, that work in the context of WebLogic Server clusters and HTTP and other product tunneling.
T3 predates Java Object Serialization and RMI, while closely tracking and leveraging these specifications. T3 is a superset of Java Object. Serialization or RMI; anything you can do in Java Object Serialization and RMI can be done over T3.
T3 is mandated between WebLogic Servers and between programmatic clients and a WebLogic Server cluster. HTTP and IIOP are optional protocols that can be used to communicate between other processes and WebLogic Server. It depends on what you want to do. For example, when you want to communicate between
* A browser and WebLogic Server-use HTTP
* An ORB and WebLogic Server-IIOP.


Question 13 :

How can I debug the Java code that I have running in WebLogic Server?

Answer :

You can use tools such as WebGain, JBuilder, NetBeans and JDB that rely on the Java Platform Debugger Architecture (JPDA) to debug your Java code running in WebLogic Server.
JPDA is integrated in the Java 2 Platform, Standard Edition (J2SE) SDK 1.3 on all platforms and SDK 1.2.2 for Linux. There is a download available from Sun to add JPDA support to the J2SE SDK 1.2.2 on Solaris and Microsoft Window platforms. If you are using J2SE SDK 1.2.2 on these platforms you must first get this download.
To allow a debugger to attach to the virtual machine that WebLogic runs you have to start WebLogic in debug mode. In order to start WebLogic in debug mode using a Sun virtual machine follow these steps (start with step one only if using a Solaris platform):
1. If using a Solaris platform, change the LD_LIBRARY_PATH environment variable to prepend $JAVA_home/lib/sparc:
export LD_LIBRARY_PATH=$JAVA_home/lib/sparc:$LD_LIBRARY_PATH
2. Add the following parameters to the java command line (before the "weblogic.Server" string) that launches WebLogic server:
-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket
server=y
address=
suspend=n
-Djava.compiler=NONE

Note that with the Hotspot Performance engine the -Xnoagent and -Djava.compiler=NONE options are no longer required, but are accepted and ignored for compatibility reasons.
If server=y and no address parameter is supplied, WebLogic Server chooses the transport address and prints it to the standard output stream. So, if a line such as:
Listening for transport dt_socket at address: 46666
prints in your standard output stream when the server starts, the number 46666 is the port number to be supplied to your tool's remote debugger in order to attach it to WebLogic's virutal machine.


Question 14 :

How do I call a servlet with parameters in the URL?

Answer :

The usual format of a servlet parameter is a name=value pair that comes after a question-mark (?) at the end of the URL. To access these parameters, call the getParameter() method on the HttpServletRequest object, then write code to test the strings. For example, if your URL parameters are "func=topic," where your URL appears as:

http://www.myserver.com/myservlet?func=topic
then you could parse the parameter as follows, where "req" is the HttpServletRequest object:
String func = req.getParameter("func");
if (func.equalsIgnoreCase("topic")) {
. . . do some work
}


Question 15 :

How do I identify the document type of an XML document?

Answer :

If the XML document has a Public ID, then that is its document type. For example, if an XML document contains the following DOCTYPE declaration:
"http://foo.com/url/to/my/dtd">

then its document type is My public ID String.

If the DOCTYPE declaration does not contain a Public ID, but specifies a System ID, then the document type is the System ID. For example, in the following DOCTYPE declaration:

the document type is http://foo.com/url/to/my/dtd.
Note: The System ID is of the DTD, not of the XML document itself. It can, however, still be used as a way to identify the XML document.
If the XML document does not specify a DOCTYPE declaration, then the document type can be either the root element name or the namespace URI, if it has one.


Question 16 :

How can I run multiple instances of the same servlet class in the same WebLogic Server instance?

Answer :

If you want to run multiple instances, your servlet will have to implement the SingleThreadModel interface. An instance of a class that implements the SingleThreadModel interface is guaranteed not to be invoked by multiple threads simultaneously. Multiple instances of a SingleThreadModel interface are used to service simultaneous requests, each running in a single thread.
When designing your servlet, consider how you use shared resources outside of the servlet class such as file and database access. Because there are multiple instances of servlets that are identical, and may use exactly the same resources, there are still synchronization and sharing issues that must be resolved, even if you do implement the SingleThreadModel interface.


Question 17 :

How do I restrict access to servlets and JSPs?

Answer :

The Java Servlet API Specification v2.2 allows you to declaratively restrict access to specific Servlets and JSPs using the Web Application Deployment descriptor. Section 13.3.2 of the specification has an example deployment descriptor that uses declarative security. For more information, see Programming WebLogic HTTP Servlets.


Question 18 :

How do I protect WebLogic Server from security attacks from bogus clients using the WL-Proxy-Client-Cert header?

Answer :

The WL-Proxy-Client-Cert header can be spoofed (used) by any client which has direct access to WebLogic Server. WebLogic Server takes the certificate information from that header, trusting that is came from a secure source (the plug-in) and use that information to authenticate the user. In previous releases of WebLogic Server, the default behavior was to always trust that header. Now you need to explicitly define trust of the WL-Proxy-Client-Cert header. A new parameter clientCertProxy allows WebLogic Server to on the implicit trust of the certificate header. If you need an additional level of security, use a connection filter to limit all connections into WebLogic Server (therefore allowing WebLogic Server to only accept connections from the machine on which the plug-in is running).
The clientCertProxy parameter has been added to the HTTPClusterServlet and Web applications.
For the HTTPClusterServlet, add the parameter to the web.xml file as follows:

clientCertProxy
true


For Web applications, add the parameter to the web.xml file as follows:

ServletRequestImpl context-param

weblogic.http.clientCertProxy
true


You can also use this parameter in a cluster as follows:
ClientCertProxyHeader="true"/>


Question 19 :

Which XML parser comes with WebLogic Server 6.1?

Answer :

We bundle a parser, based on Apache's Xerces 1.3.1 parser, in WebLogic Server 6.1. In addition, we include a WebLogic proprietary high-performance non-validating parser that you can use for small to medium sized XML documents. The WebLogic XML Registry allows you to configure the parser you want to use for specific document types.


Question 20 :

Can I use the getAttribute() and setAttribute() methods of Version 2.2 of the Java Servlet API to parse XML documents?

Answer :

Yes. Use the setAttribute() method for SAX mode parsing and the getAttribute() method for DOM mode parsing. Using these methods in a Servlet, however, is a WebLogic-specific feature. This means that the Servlet may not be fully portable to other Servlet engines, so use the feature with caution.


Question 21 :

How can I avoid ResourceExceptions when sending more requests for database connections from the pool than are currently available?

Answer :

The fundamental problem is too few resources (database connections in the connection pool) for the work load. The correct response is to increase the maximum number of connections in the connection pool. Optimally designed applications only require the server to have one pool connection per execute thread.
The proper application response to a resource exception is not to retry the request in a tight loop, which would tie up execute threads on the server.
You should design your application to gracefully fail if no connections are available. Try to ensure that you get the connection as late as possible in your application code and return them to the pool as early as possible so that you do not see as many NoResource exceptions. It is better to have the connection as a method level variable and close the connection in a finally block as in the following example:

try{
...
} catch(Exception handleEx) {
...
} finally {
try{ conn.close();
}catch (Exception ignore){} // always return the connection to pool
}


Question 22 :

How do I use Unicode codesets with the WebLogic jDriver for Oracle driver?

Answer :

To use Unicode codesets:
1. Install the appropriate codeset when you install Oracle. If you did not do this in the original installation, you will need to re-run the Oracle installer and install the proper codeset.
2. Define the NLS_LANG variable in the environment where the JDBC driver is running. Do this by assigning the proper codeset to NLS_LANG in the shell from where you start the WebLogic Server.
The Developers Guide has more information about internationalization support.


Question 23 :

How do I bind string values in a PreparedStatement?

Answer :

Suppose you are trying to tget the PreparedStatement class to bind Strings in a statement. The setString() method doesn't seem to work. Here is how you have set up the PreparedStatement:

String pstmt = "select n_name from n_table where n_name LIKE
'?%'";
PreparedStatement ps = conn.prepareStatement(pstmt);
ps.setString(1, "SMIT");
ResultSet rs = ps.executeQuery();

The preceding code does not work because the complete value needs to be specified in a String (without using embedded quotes) and then bound to an unquoted question-mark (?). Here is the corrected code:

String matchvalue = "smit%";
String pstmt = "select n_name from n_table where n_name LIKE ?";
PreparedStatement ps = conn.prepareStatement(pstmt);

ps.setString(1, matchvalue);
ResultSet rs = ps.executeQuery();


Question 24 :

How do I look up an "ORA" SQLException?

Answer :

If your WebLogic jDriver for Oracle application produces an SQLException such as:
java.sql.SQLException: ORA-12536: TNS: operation would block
You can look up an Oracle error by using the oerr command. For example, the description of error ORA-12536 can be found with the command:
> oerr ora 12536


Question 25 :

What is error "ORA-6502?"

Answer :

The default length of a string bound to an OUTPUT parameter of a CallableStatement is 128 characters. If the value you assign to the bound parameter exceeds that length, you will get this error.
You can adjust the length of the value of the bound parameter by passing an explicit length with the scale argument to the CallableStatement.registerOutputParameter() method.


Question 26 :

How can I control on which WebLogic Server(s) my application will run?

Answer :

A system administrator can specify on which WebLogic Server(s) applications will run by specifying targets when configuring connection factories. Each connection factory can be deployed on multiple WebLogic servers.
Note: If you use the default connection factory, you have no control over the WebLogic server on which the connection factory may be deployed. If you would like to target a particular WebLogic server, create a new connection factory and specify the appropriate JMS server target(s).


Question 27 :

How do I use a startup class to initialize and later reference JMS objects?

Answer :

You can use a shutdown class that does something like the following: JMSobject WLSobject = null; try { WLSobject = JMSStartUp.getJMSobject(); WLSobject.JMSCleanup(); } catch(Exception e) {} Servlets can provide a nice solution to provide both initialization and cleanup.