Showing posts with label ejbclient. Show all posts
Showing posts with label ejbclient. Show all posts

Friday, April 28, 2017

WebLogic EJB call timeout

If you get often this type of stuck threads:

"[STUCK] ExecuteThread: '170' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=0x00002b4f841f1b20 nid=0x5763 in Object.wait() [0x00002b4f8c842000]
   java.lang.Thread.State: WAITING (on object monitor)
 at java.lang.Object.wait(Native Method)
 - waiting on <0x0000000776826778> (a weblogic.rjvm.ResponseImpl)
 at weblogic.rjvm.ResponseImpl.waitForData(ResponseImpl.java:90)
 - locked <0x0000000776826778> (a weblogic.rjvm.ResponseImpl)
 at weblogic.rjvm.ResponseImpl.getTxContext(ResponseImpl.java:130)
 at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:110)
 at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:222)


you might want to set these 2 parameters (this for WLS 10.3.6 )
-Dweblogic.rmi.clientTimeout=valueInMilliseconds
weblogic.jndi.requestTimeout=valueInMilliseconds

The reason of that WAITING is that there is a synchronized block followed by an Object.wait(timeout):

  private void waitForData()
  {
    int i = 0;
    synchronized (this)
    {
      long l1 = this.timeout;
      while (!isAvailable()) {
        try
        {
          int j = 0;
          long l2 = System.currentTimeMillis();
          wait(l1);
          if (this.timeout > 0)
          {
            long l3 = System.currentTimeMillis() - l2;
            if (l3 >= l1) {
              j = 1;
            } else {
              l1 -= l3;
            }
          }
          if ((!isAvailable()) && (j != 0))
          {
            this.t = new RequestTimeoutException("RJVM response from '" + this.rjvm + "' for '" + (this.md != null ? this.md.toString() : "null") + "' timed out after: " + this.timeout + "ms.");
            
            i = 1;
          }
        }
        catch (InterruptedException localInterruptedException) {}
      }
    }
    if (i != 0) {
      this.rjvm.removePendingResponse(this.id);
    }
  }

See also:
Oracle Support doc "JNDI Thread Stuck" (Doc ID 1482310.1)
For alternative ways to specify timeouts in WLS 12 , see https://docs.oracle.com/middleware/1212/wls/WLRMI/rmi_api.htm#WLRMI251
In WLS 10, https://docs.oracle.com/cd/E11035_01/wls100/ejb/DDreference-ejb-jar.html#wp1362824 use remote-client-timeout in your weblogic.ejb-jar.xml
The Timeout event will cause a RequestTimeoutException which is a IOException : http://docs.oracle.com/cd/E57014_01/wls/WLAPI/weblogic/rmi/extensions/RequestTimeoutException.html See also Oracle Support article "How to configure timeout for an EJB Client (Doc ID 943282.1)"

in a nutshell:
-Dweblogic.rmi.clientTimeout=timeoutinmilliseconds sets the timeout on the client (consumer) side
remote-client-timeout in weblogic-ejb-jar.xml sets the timeout on the server (provider) side.


Monday, June 7, 2010

java.lang.NoClassDefFoundError: weblogic/kernel/KernelStatus

This saved my life:

http://blogs.oracle.com/jamesbayer/2008/08/workshop_for_weblogic_103_jee.html

In the classpath tab, be sure to add the wlclient.jar file located here \wlserver_10.3\server\lib to the User Entries section and remove the WebLogic System Libraries from the Bootstrap Entries section.  If you forget to remove the WebLogic System Libraries, you will get a stack like this: Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/kernel/KernelStatus

Wednesday, May 26, 2010

OSB and EJB 3.0 Client Jar File

Now, we want to expose an EJB 3.0 Stateless Session Bean in a Business Service in OSB11.

Create an EJB 3.0 Project, and ASSOCIATE IT to a EAR, and enable generation of EJB Client Jar.

The EJB will look like this:

package com.lassi.mejb;
import javax.ejb.Stateless;

/**
 * Session Bean implementation class LassiEJB
 */
@Stateless(mappedName="
LassiEJB")
public class LassiEJB implements LassiEJBRemote, LassiEJBLocal {

    /**
     * Default constructor.
     */
    public LassiEJB() {
        // TODO Auto-generated constructor stub
    }

    @Override
    public String hello(String message) {
        System.out.println("message=" + message);
        return "hello " + message;
    }

    @Override
    public String helloLocal(String message) {
        System.out.println("messagelocal=" + message);
        return "hellolocal " + message;
    }

   
}




and the interfaces:


package com.lassi.mejb;
import javax.ejb.Remote;

@Remote
public interface LassiEJBRemote {
    String hello(String message);
}



and


package com.lassi.mejb;
import javax.ejb.Local;

@Local
public interface LassiEJBLocal {
    String helloLocal(String message);
}



To generate the Client EJB Jar, just export the EAR project as an EAR, then unzip it.
You will get a LassiEJBProjectClient.jar in APP-INF/lib.
Otherwise you can right-click on the EJB project, choose Java EE  Tools and Generate EJB Client JAR.

Make sure that your Local and Remote interfaces are created in the EJBClient project, otherwise your EJB Client JAR will contain only the manifest.mf file and you will be very disappointed.

THIS EJB Client JAR is the JAR you need to import into OSB.

To find the JNDI name of your EJB click on the WLServer in the console and look into "View JNDI tree".
It should be something like LassiEARLassiEJBProject_jarLassiEJB_Home
Also, in OSB create a JNDI provider with t3://localhost:7001 and call it myjndiprovider

Create a Business Service, Transport Typed,
the URI will be like ejb:myjndiprovider:LassiEJB#com.lassi.mejb.LassiEJBRemote

In the Business Interface  you can choose the Local or the Remote interface (of course if you choose Local it will be faster! But if you use the JNDI name of the Remote interface it will not work... I presume ???? )....


At the end, if you get a

java.lang.ClassCastException: weblogic.ejb.container.internal.StatelessEJBHomeImpl

or a


java.lang.ClassCastException: $Proxy224
 at com.bea.wli.sb.transports.ejb.Jws.hellopierrelocal(Unknown Source)



most likely it means you are binding to the wrong JNDI name...