Weblogic Administration tutorial
1. Question: Why Can’t I Receive a Response to a Message That I Send Within a Transaction?
Answer: If you are using container-managed transactions, the original message sent from the EJB will never be sent. Here is what is happening.
- The container starts the transaction.
- Start method.
- Generate a new message.
- Send message (message isn’t sent – it’s buffered until transaction commit).
- Do a blocking receive in a queue.
- End method.
- Transaction Commit never Reached becauseoriginal message was never sent because you can’t get past blocking receive.
The solution is to either use bean-managed transactions or to break the send and receive it into two separate methods.
2. Question: How Do I Integrate Another Vendor’s XAResource With WLS to Get JTA Transactions With Another Resource Manager?
Answer: In most cases, WebLogic JMS will do this for you. For more information, see the “Using Foreign JMS Providers With WebLogic Server” white paper (jmsproviders.pdf) on the JMS topic page.
3. Question: Why Am I Getting JDBC XA Errors When Using JMS in Conjunction With JDBC Calls?
Answer: Whenever two resources (such as JMS and a database) participate in a transaction, the transaction becomes two-phase. The database driver you are using is not XA compatible and can’t normally participate in a two-phase transaction. The solution is to either use an XA compatible driver or to configure the JDBCTxDataSource value to set enableTwoPhaseCommit to true. The caveat for the latter is that this can lead to heuristic errors.
4. Question: What Happens If Acknowledge() is Called Within a Transaction?
Answer: As per Sun Microsystems’ JMS specification, when you are in a transaction, the acknowledge mode is ignored. I acknowledge() is called within a transaction, it is ignored.
5. Question: How Do I Perform a Manual Fail-Over?
Answer: The procedures for recovering from a WebLogic Server failure, and performing a manual failover, including programming considerations, are described in “Recovering From a WebLogic Server Failure” in Programming WebLogic JMS.
6. Question: Why Do I Get an “ORA-01400: Cannot Insert NULL Into Column Name” When Inserting a Blank String?
Answer: This is a known Oracle issue. When inserting or updating a value for a varchar2, if you try to insert an empty string (“), Oracle interprets the value as NULL. If there is a NOT NULL restriction on the column in which you are inserting the value, the database throws the ORA-01400 error.
7. Question: Why Do I Get Error “ORA-03120” When Trying to Access Multi-byte Characters From the CLOB/NCLOB Column?
Answer: Accessing exceeded characters would result in an ORA-03120 error when getting the length of the club from the CLOB/NCLOB column returns a bigger value than the actual length from the OCI layer. Using Oracle 8.1.6.3 solves this problem.
8. Question: How Do I Connect to an SQL Server Instance That is Running on a Machine With Multiple Instances of SQL Server 2000?
Answer: Each instance of MS SQL Server must be listening on a different port. So, you can use the port number in the properties that you pass to the getConnection() method or, in case of connection pools, you can specify the port property in the following properties:
server=machineName
port=instancePort
To find the port number where each MS SQL Server instance is running, run the server network utility (in the Microsoft SQL Server program group), select the server instance, select TCP/IP, and click the Properties button.
9. Question: Why Does FOR UPDATE in Oracle 8 Cause an ORA-01002 Error?
Answer: The Oracle 8 server generates an ORA-01002: fetch out of sequence error message when you use a FOR UPDATE statement with AUTOCOMMIT turned on (which is the default state when using JDBC). This is known to happen on Oracle 8.0 and 8.1 on Solaris and on Oracle 8.1 on Windows NT. If you turn AUTOCOMMIT off, you will not receive this error. Because this problem is due to a change in the Oracle 8 server, you should contact Oracle support for more information.
10. Question: Why Do I Get an “ORA-01453” When I Use SET TRANSACTION?
Answer: When using Oracle, the message “java.sql.SQLException: ORA-01453: SET TRANSACTION must be the first statement of transaction” may be logged. This is due to a limitation in the Oracle interfaces, starting in Oracle 8.1.7. WebLogic tries to minimize the problem by not calling SET TRANSACTION if the mode already matches the current state.
11. Question: How Do I Enlist an Oracle XAResource?
Answer: This code will only work on the server side. It cannot be run in a client. Also note that enlistment is generally done transparently for JDBC resources that implement XAResource.
// Here is the XAResource for oracle
String URL = “jdbc:oracle:thin:@DbmsHost:DbmsPort:DbmsName”;
DriverManager.registerDriver(new OracleDriver());
// Create XA Connection
OracleXADataSource oxds1 = new OracleXADataSource();
oxds1.setURL(URL);
oxds1.setUser(“scott”);
oxds1.setPassword(“tiger”);
javax.sql.XAConnection pc1 = oxds1.getXAConnection();
m_oracleResource = pc1.getXAResource ();
m_oracleConnection = pc1.getConnection();
// Here is the source code for getting the TM.
Context ctx = null;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
“weblogic.jndi.WLInitialContextFactory”);
// Parameters for the WebLogic Server.
// Substitute the correct hostname, port number
// user name, and password for your environment:
env.put(Context.PROVIDER_URL, “t3://localhost:7001”);
env.put(Context.SECURITY_PRINCIPAL, “system”);
env.put(Context.SECURITY_CREDENTIALS, “managers”);
ctx = new InitialContext(env);
m_tManager =
(TransactionManager)ctx.lookup(“javax.transaction.TransactionManager”);
//Here is the source code for registering the TM.
m_tManager.begin();
m_transaction = m_tManager.getTransaction();
weblogic.transaction.TransactionManager weblogicTManager =
((weblogic.transaction.TransactionManager) m_tManager);
weblogicTManager.registerStaticResource(“oracle”,m_oracleResource);
// enlist the resources with the transaction
m_transaction.enlistResource(m_oracleResource);
12. Question: How Do I Create and Update Oracle Blob Fields?
Answer: The following code sample shows how to create and update Oracle Blob fields. (How Do I Create and Update Oracle Blob Fields)
public void insert() throws SQLException {
try {
// Connect to the database using WebLogic JDBC connection pool
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
“weblogic.jndi.WLInitialContextFactory”);
ht.put(Context.PROVIDER_URL, “t3://localhost:7001”);
InitialContext ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource)
ctx.lookup(“java:comp/env/jdbc/DSName”);
Connection conn = ds.getConnection();
// This is necessary in any case where you are doing
// a select for update. Not doing this will result in a ORA-1002
conn.setAutoCommit (false);
BLOB blob = null;
// Create a Statement
Statement stmt = conn.createStatement ();
// Drop the table if it exists
try {
stmt.execute (“drop table ImageTable”);
System.out.println(“Table droped …”);
}
catch (SQLException e) {
System.out.println(“Table does not exist”);
}
// Create the table
stmt.execute (“create table ImageTable (column1 varchar2(20),
image BLOB)”);
System.out.println(“Table created …”);
// create a blob entry in the table
stmt.execute(“insert into ImageTable values (‘one’, empty_blob())”);
stmt.execute(“commit”);
System.out.println(“inserted empty blob”);
String cmd = “select * from ImageTable for update”;
ResultSet rset = stmt.executeQuery(cmd);
if (rset.next()) {
blob = ((OracleResultSet)rset).getBLOB(2);
System.out.println(“got blob reference”);
}
else System.out.println(“no row to get!!!!”);
rset.close();
blob = readFromFile();
cmd = “update ImageTable set image = ? where column1 = ‘one’”;
PreparedStatement pstmt = conn.prepareStatement(cmd);
pstmt.setBlob(1, blob);
pstmt.execute();
stmt.execute(“commit”);
System.out.println(“blob updated”);
blob = null;
cmd = “select * from ImageTable for update”;
rset = stmt.executeQuery(cmd);
if (rset.next()) {
System.out.println(“get blob”);
blob = ((OracleResultSet)rset).getBLOB(2);
// do something with blob
else
System.out.println(“no row to get (2)!!!!”);
catch (SQLException sqle) {
System.out.println(“SQL Exception occured: ” + sqle.getMessage());
sqle.printStackTrace();
catch(FileNotFoundException e) {
System.out.println(“File Not Found”);
catch (IOException ioe) {
System.out.println(“IO Exception” + ioe.getMessage());
catch (Exception ioe) {
System.out.println(“Exception” + ioe.getMessage());
13. Question: Why Does Execute the PreparedStatement Class Cause a “TRUNC fails: ORA-00932: Inconsistent Datatypes” Error?
Answer: According to Oracle Metalink Bug Database Doc ID: 144784.1, in the absence of explicit data typecasting, OCI assumes that a bind variable is a CHAR data type. If the SQL statement intends to use the bind variable as a DATE data type, but I thought it was a CHAR, the SQL parser will have a conflict in data types. The fix is to explicitly use data conversion functions to convert the bind variables in the problem queries. For example, a select string of (Why Does Execute the PreparedStatement Class Cause a TRUNC fails: ORA-00932: Inconsistent Datatypes Error)
String st = “select count(*) from simple_table where TRUNC(my date) = TRUNC(?)”;
14. Question: How Do I Look Up an “ORA” SQLException?
Answer: If your WebLogic driver for Oracle application produces an SQLException, you can look up the Oracle error by using the oerr command. For example, if you see the following SQLException:
java.sql.SQLException: ORA-12536: TNS: operation would block.
You can find the description of error ORA-12536 can be found with the command:
15. Question: How Do I Learn What Codesets are Available in Oracle?
Answer: To find out what codesets you currently have available in Oracle, execute the following SQL query from SQLPlus at the command line: SQL> SELECT value FROM v$nls_valid_values
WHERE parameter=’CHARACTERSET’;
The response lists all codesets currently installed on your system. This listing will look something like the following shortened list:
VALUE
US7ASCII
WE8DEC
WE8HP
US8PC437
WE8EBCDIC37
WE8EBCDIC500
WE8EBCDIC285
If you want to constrain the value in the query to a specific codeset you are searching for, you can use a SQL query like the following:
SQL> SELECT value FROM v$nls_valid_values (Company)
WHERE parameter=’CHARACTERSET’ and VALUE=’AL24UTFFSS’;
This would produce the following response if the codeset is installed:
VALUE
AL24UTFFSS
You can use Oracle’s installation tools to install additional codesets. Contact Oracle for more information.
16. Question: How Do I Bind String Values in a Prepared Statement?
Answer: Suppose you are trying to get 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();
17. Question: How Do I Call Oracle Stored Procedures That Take No Parameters?
Answer: Try this:
CallableStatement cstmt = conn.prepareCall(“Begin procName;
END;”);
cstmt.execute();
where procName is the name of an Oracle stored procedure.
This is standard Oracle SQL syntax that works with any Oracle DBMS. You can also use the following syntax:
CallableStatement cstmt = conn.prepareCall(“{call procName};”);
cstmt.execute();
This code, which conforms to the Java Extended SQL specification, will work with any DBMS, not just Oracle.
18. Question: What Causes an OCIW32.dll Error?
Answer: You may see the following error message when using your JDBC driver for Oracle: “The ordinal 40 could not be loaded in the dynamic link library OCIW32.dll.” This problem is caused by an out-of-date version of OCIW32.DLL in your system directory. Some programs install this file in the system directory in order to run. If you remove this file from the system directory you should no longer receive this error.
19. Question: Why Do I Get a SystemException Failure When Trying to Enlist My XAResource in a Client?
Answer: WebLogic Server does not allow you to register or enlist an XA resource on a client. The reason for this restriction is that a client is deemed to be less reliable than a server in terms of availability. This is also why a client is not allowed to act as a transaction coordinator and register Synchronization objects.
Your client could invoke a remote object on a server that accesses the resource within a transaction. If it’s a JDBC resource, then you can configure a JDBCConnectionPool and JDBCTxDataSource using an Oracle XA driver and obtain a connection from the data source. Or the client could look up the data source using JNDI and retrieve and manipulate a connection in a transaction. Transaction enlistment is performed automatically.
20. Question: If a Distributed Transaction Involves JMS and JDBC, How Do I Ensure That the JDBC Update is Available When the JMS Message is Processed?
Answer: The problem is that an application can receive the JMS message from the destination before the associated JDBC data is in the database. (If a Distributed Transaction Involves JMS and JDBC, How Do I Ensure That the JDBC Update is Available When the JMS Message is Processed)
Distributed transactions guarantee all involved changes will either succeed or fail as a unit, but cannot guarantee that they will happen exactly simultaneously (the transaction manager instructs all resource managers to commit but cannot control the timing of the completion of that operation).
For the WebLogic transaction manager, if the JDBC connection pool and the JMS server are both on the same server, and the transaction starts on the same server, the changes are committed in the order in which they were asked for by the transaction. This is not supported behavior, it just happens to be the current behavior. So if you can co-locate JMS and the JDBC connection pool, then you may have a chance.
You could send the JMS message with a delayed birth-time and hope that this is good enough. If the receiver fails to find the associated JDBC record, it could rollback/recover the message. You could use the WebLogic JMS redelivery delay feature to prevent the message from being redelivered instantly.
21. Question: How Do I Ensure That a New Database Connection is Created Each Time an EJB’s Container-Managed Transaction is Started (So That I Get a New Authentication/Authorization Each Time)?
Answer: The EJB should be tx-requires, which means it will start a transaction when called if one is not underway already or will join the transaction in progress if there is one. Your code will use the standard JTS/JTA API to obtain and start a User Transaction. Then you should obtain your JDBC connection from a tx data source, and it will be included in the transaction. To get a new connection each time, you could use the dynamic pool API to make a one-connection pool. We suggest configuring the server to have a one-connection pool and a tx data source for it at startup. Then when you want to do a transaction in an external client, you would destroy the initial pool and recreate it with the DBMS user you want. This will allow you to use the tx data source to get a connection, which if obtained in the context of a running UserTransaction, will get automatically included in the tx.
22. Question: Why Do I Get a java.lang.AbstractMethodError When Calling a Method On a Driver?
Answer: This usually indicates that the driver has not implemented the method. For instance, you might be calling a JDBC 3.0 method on a driver that has only implemented the JDBC 2.0 methods.
23. Question: Can I Use a Prepared Statement Across Multiple Transactions?
Answer: Yes. Every transaction uses a dedicated JDBC connection, and all database interaction needs to use this connection object in order to participate in the transaction. So a prepared statement is tied to a particular connection and can’t be shared with other connections. But a prepared statement can span transactions.
24. Question: Why Should I Not Use DriverManager.getConnection?
Answer: DriverManager.getConnection can cause a deadlock. In the server, all DriverManager calls are class-synchronized including many frequent calls that all drivers make, and JDBC drivers do a lot of synchronization internally. One long-waiting call can stop all JDBC work in the whole JVM and cause deadlocks. Also, you should not reregister the driver repeatedly. Regardless of the DBMS state, the one driver that is initially loaded at startup will always work.
25. Question: Are There Recommended Programming Practices For Using JDBC Connections?
Answer: The general rule is to get the connection from the connection pool as late as possible and give it back to the connection pool as soon as possible. Ensure that the connection is a method variable, and get and release the connection within the same method as to where you use it (each thread should have its own connection). The cost of getting the connection is small, the prepared statement cache will reduce the preparation time, the set statements are small, the executive needs to be done no matter what the usage and the close are small. It is not recommended to create the connection at ejbCreate/activate and close it on EJB remote/passivate.
26. Question: How Do I Use the Prepared Statement Cache?
Answer: See “Increasing Performance with the Statement Cache” in the Administration Console Online Help.
There is also an article on using prepared statements at https://www.theserverside.com/resources/article.jsp?l=Prepared-Statements.
27. Question: What Happens When My Database is Restarted or Becomes Unreachable Does My Connection Pool Stick Around?
Answer: Yes. The pool is independent of its ability to communicate with the DBMS. All connections in the connection pool may become defunct, but the connection pool still exists. You can configure the connection pool so that WebLogic Server tests the connections in the pool and replaces bad connections when it can. See “Testing Connection Pools and Database Connections” in Programming WebLogic JDBC for more information.
To manually restart the connection pool using the Administration Console after a database failure, you can undeploy the connection pool by removing all of its deployment targets, and then redeploy the connection pool by adding deployment targets. See “Shutting Down a JDBC Connection Pool” in the Administration Console Help.
To do this from the command line using “Weblogic. Admin”, set the “Targets” attribute of the pool to an empty string (“) and then set it to the desired set of targets. See “Using WebLogic.Admin Commands to Target Resources” in the WebLogic Server Command Reference.
28. Question: When are JDBC Connections Returned to the Connection Pool?
Answer: It depends on how the application obtains the connection. If the connection is obtained by an EJB or other application code in a way that the connection is part of a WebLogic-managed transaction (using a tx data source, the JTS driver, and so forth), then the connection is returned to the connection pool as soon as the transaction ends, either by commit, rollback, or timeout.
If the connection is obtained by application code outside the context of a WebLogic-managed transaction, such as from a non-tx data source, the connection is returned to the pool as soon as the application code closes it. If the connection is not closed, eventually it will be garbage collected and then returned to the connection pool, but this is slow and indeterminate and can cause failures for applications that need a connection, so it is important to ensure that applications close pool connections when finished using them. Also, in JSPs and servlets, where one class may be running simultaneously in multiple threads, it is important that Connection objects be method objects, not a class or instance variables, because one thread may overwrite a connection object with a new one. The overwritten connection cannot be closed and will be unavailable (out of the connection pool) until it is garbage collected.
29. Question: How Can I Avoid ResourceExceptions When Sending More Requests For Database Connections From the Connection 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.
You can also enable connection requests to wait for a connection. See “Enabling Connection Requests to Wait for a Connection” in Programming WebLogic JDBC.
Note that 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 it to the connection 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 final block as in the following example:
try{
…
} catch(Exception handles) {
…
} finally {
try{ conn.close(); // always return the connection to pool
}catch (Exception ignore){}
30. Question: Can I Enable Requests to a JDBC Connection Pool For a DataBase Connection to Wait Until a Connection is Available?
Answer: Yes. You can set two JDBC connection pool properties to enable connection requests to wait for a connection:
- ConnectionReserveTimeoutSeconds
- HighestNumWaiters
31. Question: How Should I Set the Connection Pool’s Maximum Size?
Answer: In production environments, the best maximum pool size depends on the application and the system. A good starting point is to set the maximum pool size equal to the execute thread count. This allows each execute thread to get its own JDBC connection without blocking while waiting for a connection in use by another thread.
Some applications can run with a maximum pool size less than the number of executing threads. This case generally occurs when there is work entering the server that does not ever need a JDBC connection, and the server has lots of threads doing I/O tasks.
Some applications require a maximum pool size greater than the number of executing threads. In this case, each thread may require more than one connection from the same connection pool. A common way this occurs is when an EJB method uses a connection and then calls a RequiresNew method on another EJB before committing its transaction. The RequiresNew EJB then gets its own connection from the pool.
Theoretically, you need as many connections as you need concurrent users to be served (though this may not be practical and connections may need to be serially reused).
Note that these recommendations do take into account any connection leaks (connections that you reserve but do not close).
During development, set the maximum size to a small value. Unless you are doing load tests against your development machine, you probably do not have very many concurrent users so you don’t need many connections. Also, with fewer connections in the connection pool, it will be easier to run into situations where connections are leaking from the connection pool because the application code is not closing them. It is better to encounter this during development and fix it before going into production.
If a connection is not explicitly released by an object, the connection is returned back to the connection pool when the object is destroyed or the connection is actually closed. When the references to a connection are gone, the connection is returned to the connection pool during garbage collection. Note that in case of remote references to a connection (when a connection is obtained using a data source), there is an extra delay that may look as though the connection did not get returned. This is because the distributed garbage collection is more time-consuming. It may take 6 minutes or more before it is returned to the pool.
Do not rely on the garbage collection to return connections to the connection pool. It is best to track down offending code that doesn’t properly return connections to the connection pool after use and fix the code.
32. Question: How Should I Set the Connection Pool Initial Size?
Answer: In a production system, set the initial size equal to the maximum size. This will create all necessary JDBC connections at the server start-up. The reason is that if an initial number of connections is less than the maximum number of connections, the server has to create additional connections when it becomes loaded. When a server is under heavy load, the goal is to only do useful work with minimal overhead. That is exactly the time that you do not want to burden the server with creating additional database connections. For both performance and stability reasons, it is best to have the connection pool make all its connections at startup. During development, set the initial size to a small value like 1. This helps the server boot faster and allows you to use a database that doesn’t support as many concurrent connections.
33. Question: When Should I Use a TxDataSource Instead of a DataSource?
Answer: See “When to Enable Global Transactions in a Data Source” in the Administration Console Online Help. When you select Honor Global Transactions in the Administration Console, you create a JDBCTxDataSource in the config.xml file (the default). If you clear the Honor Global Transactions checkbox, you create a JDBCDataSource in the config.xml file.
34. Question: The BEA com.bea.adapter.dbms.cci.ConnectionImpl Does Not Directly Implement javax.resource.cci.Connection. Is There a Work-around For This?
Answer: Yes. The BEA com.bea.adapter.dbms.cci.ConnectionImpl extends com.bea.adapter.cci.AbstractConnection; this, in turn, implements the Connection interface. The Proxy is constructed using the interfaces from the most-derived class (ConnectionImpl). The dumpFamilyTree printout shows that the getInterfaces call on the ConnectionImpl class does NOT include the Connection interface. However, the get interfaces call on AbstractConnection does include the Connection interface.
The work-around is that the ConnectionImpl class must directly implement the interface class specified in the ra.xml file. (This might be a redundant statement in the code, particularly if it extends a class that has already implemented the class.) Then rebuild the adapter and try your test again.
35. Question: Why Do I Get an Exception When I Compile My EJB to Use a Resource Adapter That Supports CCI?
Answer: Make sure your EJB-jar.xml is referencing the EJB2.0 DTD instead of the EJB1.1 DTD. The ConnectionFactory resource ref is only supported in the EJB 2.0 DTD.
36. Question: What Information Do I Need to Set Up Communications With a Remote JMS Provider?
Answer: You will need the following information to set up communications with a remote JMS provider:
1. The destination type—whether the remote JMS destination is a queue or a topic.
2. The JNDI name of the remote JMS destination.
3. For durable topic subscribers—the connection-id and subscriber-id names that uniquely identify them. Message Driven EJBs provide default values for these values based on the EJB name.
4. For non-WebLogic remote JMS providers
- Initial Context Factory Class Name— the java class name of the remote JMS Provider’s JNDI lookup service.
- The file location of the java jars containing the remote JMS provider’s JMS client and JNDI client libraries. Ensure that these jars are specified in the local JVM’s classpath.
5. The URL of the remote provider’s JNDI service. For WebLogic servers, the URL is normally in the form t3://hostaddress: port. If you are tunneling over HTTP, begin the URL with https rather than t3. No URL is required for server application code that accesses a WebLogic JMS server that resides on the same WebLogic server or WebLogic cluster as the application.
6. The JNDI name of the remote provider’s JMS connection factory. This connection factory must exist on the remote provider, not the local provider.
If the JMS application requires transactions, the connection factory must be XA capable. WebLogic documentation refers to XA capable factories as user transactions enabled.
By default, WebLogic servers automatically provide three non-configurable connection factories:
- weblogic.jms.ConnectionFactory—a non-XA capable factory.
- weblogic.jms.XAConnectionFactory—an XA-capable factory
- weblogic.jms.MessageDrivenBeanConnectionFactory—an XA-capable factory for message driven EJBs.
Additional WebLogic JMS connection factories must be explicitly configured.
37. Question: What Does a JMS Client Do to Communicate With a Remote JMS Provider?
Answer: To communicate with any JMS provider, a JMS client must perform the following steps:
- Lookup a JMS connection factory object and a JMS destination object using JNDI
- Create a JMS connection using the connection factory object
- Create message consumers or producers using the JMS connection and JMS destination objects.
38. Question: What is Automatic Transaction Enlistment?
Answer: Operations on resources such as database servers or messaging servers participate in a J2EE JTA transaction provided that:
- the resource has been enlisted with the current transaction
- the client library used to access the resource is transaction aware (XA enabled).
Automatic participation of operations on an XA capable resource in a transaction is technically referred to as automatic enlistment.
- WebLogic clients using XA enabled WebLogic APIs automatically enlist operation in the current thread’s JTA transaction. Examples of XA enabled WebLogic clients to include WebLogic JMS XA enabled (or user transaction enabled) connection factories and JDBC connection pool data sources that are global transaction enabled.
- Foreign (non-WebLogic) JMS clients do not automatically enlist in the current JTA transaction. Such clients must either go through an extra step of programmatically enlisting in the current transaction or use WebLogic provided features that wrap the foreign JMS client and automatically enlist when the foreign JMS client is accessed via wrapper APIs.
JMS features that provide automatic enlistment for foreign vendors are:
- Message-Driven EJBs
- JMS resource-reference pools
- Messaging Bridges
To determine if a non-WebLogic vendor’s JMS connection factory is XA capable, check the vendor documentation. Remember, support for transacted sessions (local transactions) does not imply support for global/XA transactions.
39. Question: Are JMS Local Transactions Useful For Integration Purposes?
Answer: Local transactions are generally not useful for integration purposes as they are limited in scope to a single resource, typically a messaging or database server.
40. Question: How Does JMS Provide Local Transactions?
Answer: Local transactions are enabled by a JMS specific API called transacted sessions. For vendors other than WebLogic JMS, the scope of a transacted session is typically limited to a single JMS server. In WebLogic JMS, multiple JMS operations on multiple destinations within an entire cluster can participate in a single transacted session’s transaction. In other words, it is scoped to a WebLogic cluster and no remote JMS provider to the JMS session’s cluster can participate in a transaction.
41. Question: Why Did My JDBC Code Throw a Rollback SQLException?
Answer: Your JDBC code may throw the following exception:
“The coordinator has rolled back the transaction.
No further JDBC access is allowed within this transaction.”
The WebLogic JTS JDBC driver throws this exception when the current JDBC connection transaction rolls back prior to or during the JDBC call. This exception indicates that the transaction in which the JDBC connection was participating was rolled back at some point prior to or during the JDBC call.
The rollback may have happened in an earlier EJB invoke that was part of the transaction, or the rollback may have occurred because the transaction timed out. In either case, the transaction will be rolled back, the connection returned to the pool and the database resources released. In order to proceed, the JTS JDBC connection must be closed and reopened in a new transaction.
42. Question: My Transaction Aborted, But My Database Changes Did Not Rollback?
Answer: You must obtain your JDBC connections from a TxDataSource.
43. Question: How Should I Obtain My JDBC Connection So That It Participates in the EJB Container’s Transaction?
Answer: You must get your JDBC connection from a TxDataSource or the JTS driver. If you get a JDBC connection from a plain DataSource or directly from the JDBC driver, it will NOT participate in the EJB container transaction.
TxDataSources are recommended instead of accessing the JTS driver directly. TxDataSources are the standard mechanism in JDBC 2.0 for connection pooling, and they support 2PC/XA transactions.
44. Question: How Can I Avoid Violating NOT NULL Constraints on Foreign Keys That are Mapped to CMR-fields?
Answer: In WLS 7.0 and later, you can set delay-database-insert-until to ‘commit’ and assign the CMR-field a value before the current transaction commits. You can also set delay-database-insert-until to ‘ejbPostCreate’ and assign the CMR-field a value during ejbPostCreate.
45. Question: What’s the Purpose of the delay-database-insert-until Deployment Descriptor Element?
Answer: This setting allows you to specify at what point the database insert occurs when creating a CMP bean. Non-null foreign key constraints in your database can make creating CMP beans with relationships tricky. We offer this setting to give developers more flexibility to satisfy those constraints. Also, this setting is necessary to enable the bulk insert feature that was added in WLS 7.0. To enable the bulk insert feature and to provide yourself the maximum amount of flexibility to satisfy any non-null foreign key constraints, we recommend setting the delay-database-insert-until option to commit.
46. Question: When are CMP Fields Loaded Is it Always Determined By the finders-load-bean Setting What is the Default Behavior?
Answer: Finders-load-bean is true by default. A bean is retrieved via a finder explicitly if you call a find XXXX() method to get the bean and implicitly if you retrieve the bean via a CMR-field getXXX method. Either of these will result in eager loading of the bean’s fields if the finders-load-bean is true for the bean.
If you aren’t calling a finder, but just accessing the bean via a reference you obtained in a different transaction, then fields are always loaded lazily when using 2.0 CMP, i.e. they aren’t read from the DBMS during ejbLoad, but rather when a getXXX() method is called. By default, there is a single field group that contains all the fields if you don’t define any field groups. So, calling a CMP-field getXXX() method loads all of the persistent states of the bean by default.
47. Question: How Should I Set an initial-beans-in-free-pool For Stateless Beans?
Answer: By default, no stateless session EJB instances exist in WebLogic Server at startup time. As individual beans are invoked, WebLogic Server initializes new instances of the EJB.
However, in a production environment, WebLogic Server can provide improved performance and throughput for stateless session EJBs by maintaining a free pool of unbound stateless session EJBs—instances that are not currently processing a method call. If an unbound instance is available to serve a request, response time improves, because the request does not have to wait for an instance to be created. The free pool improves performance by reusing objects and skipping container callbacks when it can.
Upon startup, WebLogic Server automatically creates and populates the free pool with the number of instances you specify in the bean’s initial-beans-in-free-pool deployment element in the WebLogic-EJB-jar.xml file. By default, the initial-beans-in-free-pool is set to 0.
If you configure a pool, WebLogic Server will service method calls with an EJB instance from the free pool, if one is available. The EJB remains active for the duration of the client’s method call. After the method completes, the EJB instance is returned to the free pool. Because WebLogic Server unbinds stateless session beans from clients after each method call, the actual bean class instance that a client uses may be different from invocation to invocation.
If all instances of an EJB class are active and max-beans-in-free-pool has been reached, new clients requesting the EJB class will be blocked until an active EJB completes a method call. If the transaction times out (or, for non-transactional calls, if five minutes elapse), WebLogic Server throws a RemoteException for a remote client or an EJBException for a local client.
Note: The maximum size of the free pool is limited by the value of the max-beans-in-free-pool element, available memory, or the number of executing threads.
When an application requests a bean instance from the free pool, there are three possible outcomes:
- An instance is available in the pool. WebLogic Server makes that instance available and your application proceeds with processing.
- No instance is available in the pool, but the number of instances in use is less then max-beans-in-free-pool. WebLogic Server allocates a new bean instance and gives it to you.
- No instances are available in the pool and the number of instances in use is already max-beans-in-free-pool. Your application must wait until either your transaction times out or a bean instance that already exists in the pool becomes available.
48. Question: How Should I Set max-beans-in-free-pool For Stateless Beans?
Answer: By default, no stateless session EJB instances exist in WebLogic Server at startup time. As individual beans are invoked, WebLogic Server initializes new instances of the EJB.
However, in a production environment, WebLogic Server can provide improved performance and throughput for stateless session EJBs by maintaining a free pool of unbound stateless session EJBs—instances that are not currently processing a method call. If an unbound instance is available to serve a request, response time improves, because the request does not have to wait for an instance to be created. The free pool improves performance by reusing objects and skipping container callbacks when it can.
Upon startup, WebLogic Server automatically creates and populates the free pool with the number of instances you specify in the bean’s initial-beans-in-free-pool deployment element in the WebLogic-EJB-jar.xml file. By default, the initial-beans-in-free-pool is set to 0.
If you configure a pool, WebLogic Server will service method calls with an EJB instance from the free pool, if one is available. The EJB remains active for the duration of the client’s method call. After the method completes, the EJB instance is returned to the free pool. Because WebLogic Server unbinds stateless session beans from clients after each method call, the actual bean class instance that a client uses may be different from invocation to invocation.
If all instances of an EJB class are active and max-beans-in-free-pool has been reached, new clients requesting the EJB class will be blocked until an active EJB completes a method call. If the transaction times out (or, for non-transactional calls, if five minutes elapse), WebLogic Server throws a RemoteException for a remote client or an EJBException for a local client.
Note: The maximum size of the free pool is limited by the value of the max-beans-in-free-pool element, available memory, or the number of executing threads.
When an application requests a bean instance from the free pool, there are three possible outcomes:
- An instance is available in the pool. WebLogic Server makes that instance available and your application proceeds with processing.
- No instance is available in the pool, but the number of instances in use is less then max-beans-in-free-pool. WebLogic Server allocates a new bean instance and gives it to you.
- No instances are available in the pool and the number of instances in use is already max-beans-in-free-pool. Your application must wait until either your transaction times out or a bean instance that already exists in the pool becomes available.
49. Question: Where Can I Get a Copy of the EJB Specification?
Answer: You can download it from Sun’s EJB site. (Where Can I Get a Copy of the EJB Specification.
50. Question: Must EJBs Be Homogeneously Deployed Across a Cluster Why?
Answer: Yes. In WebLogic Server 6.0 and later, EJBs must be homogeneously deployed across a cluster for the following reasons:
- To keep clustering EJBs simple
- To improve performance by avoiding cross-server calls. If EJBs are not deployed on all servers, cross-server calls are more likely.
- To ensure that every EJB is available locally.y
- To ensure that all classes are loaded in an undeployable way. Every server must have access to each EJB’s classes so that it can be bound into the local JNDI tree. If only a subset of the servers deploys the bean, the other servers will have to load the bean’s classes in their respective system classpaths which makes it impossible to undeploy the beans.
Weblogic Administration Tutorial Over View
What is Oracle WebLogic Administration Course?
We provide flawless weblogic administration training online Course. WebLogic Application Server is developed as per Java EE specifications. This supports the deployment of mission critical applications using a robust, secure and scalable infrastructure. WebLogic Administration Training Online Course leads to better understanding about real time work environment. Middleware administration of WebLogic Application Server includes a wide range of activities, from creating and configuring server domains. It also includes to deploy and secure applications, to monitoring and troubleshooting server, application and performance issues. The main objective of our Weblogic Administration Training Online is students should master in WebLogic administration trained by 10 years experienced specialized expert with hands-on. The basic administrative unit for a WebLogic Server installation is called a domain. Admin Server can be only one for a Domain, which works like a Central Configuration/Monitoring controller for the entire domain.
Oracle WebLogic Administration Course Overview
Oracle webLogic administration is quite for some years as it is the key platform for Enterprise Java Applications. Through its long history of development and building, it has become the most complete, mature and stable application server platform. It is ready to serve old technology but more than ready for the coming new technologies which are following up each other in a speed that no one would ever thought of. The WebLogic Administration Service an implementation of Sun’s Java Management Extension (JMX) standard provides the facilities for managing WebLogic resources. Through the WebLogic Administration Training Online, you can configure attributes of resources, deploy applications or components. You can monitor resource usage such as server load or Java Virtual Machine memory usage or database connection pool load, view log messages, or perform other management actions. An interrelated set of webLogic administration server resources managed as a unit is called a domain.
Job Opportunities on Oracle WebLogic Administration
If you’re searching for WebLogic Admin Online Training then you are at the right place. Choose the best online training course, we suggest you weblogic administration training online as weblogic administration is the number one Java Platforms, as where it once began; still rest on those very first concepts is serving Java application technology. weblogic administration training online provides you with all the necessary requirements that are helpful in getting placed in a good job. Average Senior Weblogic Server Administrator salaries for job postings in Rockville, MD are 25% higher than average Senior Weblogic Server Administrator salaries nationwide in USA.
- SVR Technologies provides you well knowledge and highly qualified educated tutors.
- All the trainers engaged in this weblogic administration training online website which gives in you all the information which you need on that particular course.
SVR Features
Here all trainers of SVR Technologies have experienced the joy of WebLogic Administration Training Online and trained resources are available throughout the world. Our real time experienced trainers fulfil your dreams and create professionally driven environment. Our Faculty will assist you
- Resume preparation for your Interview
- Sample Real Time examples
- Assessments and clarifying doubts
- Materials
We provide WebLogic Administration Training Online Classes to India, USA, UK, Canada and Australia. SVR Technologies is an online education marketplace to help Administrators, Developers, students to learn the latest technology, build their skills, and advance their careers. We offer WebLogic Administration Training Online to the learners in all parts of the world. We provide the finest WebLogic Administration Training Online and personal guidance to enable students from all walks of life to fulfil their dreams. Students can work at their own place and receive one-on-one instruction through virtual lessons.
Conclusion
Distributing an application and its components across a set of Managed Servers has a number of possible advantages. EJBs that do processing can be distributed to ensure for the main application entry point. This weblogic administration training online even makes more people getting into our online website in learning and mastering the weblogic administration skills.
- So from this, we have started a new innovative thing of placements i.e. letting the best knowledge seek the best knowledge user, which is our main motto.
- Trainers of SVR Technologies helps that right person get into the right company. So, make sure that there will be no wastage of the acquired knowledge.
You can depend on our weblogic administration training online, every SVR student can able to work on your own. Our WebLogic Classes will help you to clear interview and provides you the ability to complete the tasks in office.