cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to co-locate ear files in same WAS instance

Former Member
0 Kudos

Hi all,

I have two J2EE apps, one depending on the other. Everything works fine, until I try to deploy them both in the same instance of the application server. If I run them both in the same instance of WAS, I get an IllegalArgumentException when I call create() on the Home interface. It appears that the underlying stub (dynamic proxy) is botched in some way. Here is a snippet from the stack trace:

java.lang.IllegalArgumentException: object is not an instance of declaring class

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at com.sap.engine.services.rmi_p4.reflect.LocalInvocationHandler.invokeInternal(LocalInvocationHandler.java:61)

at com.sap.engine.services.rmi_p4.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:46)

at $Proxy11.create(Unknown Source)

at

turtle.common.server.connect.RemoteFactory.getRegistryRemote(RemoteFactory.java:134)

....

....

The offending code looks like:

String initialContextFactory = "com.sap.engine.services.jndi.InitialContextFactoryImpl";

String url = "172.16.1.38:50004";

Properties env = new Properties();

env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);

env.put(Context.PROVIDER_URL, url);

String user = "user";

String pw = "pw";

env.put(Context.SECURITY_PRINCIPAL, user);

env.put(Context.SECURITY_CREDENTIALS, pw);

try {

Context ctx = new InitialContext(env);

Object o = ctx.lookup(jndiName);

SBRegistryRemoteHome home = (SBRegistryRemoteHome)PortableRemoteObject.narrow(o, SBRegistryRemoteHome.class);

return home.create();

} catch (Exception e) {

...

}

The JNDI lookup works find, but all bombs on the home.create() method.

I suspect this may have something to do with classloading (duplicate class definitions, etc). Keep in mind, this all works fine if the applications are running in separate containers. Also, both apps are full on J2EE apps, not "application clients" in the J2EE sense.

I am running WAS early release 6.4 on window XP.

Anybody seen this before or know what the problem is?

TIA,

Chad

Accepted Solutions (0)

Answers (1)

Answers (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Chad,

Three things:

1. Try to declare a reference in the application-j2ee-engine.xml of app A (that makes the lookup) to app B (that contains the referenced EJB) and leave the EJB interfaces only in app B.

2. Since you make the lookup from a server-side component (I suppose a servlet/jsp or another EJB) you should not pass <b><i>env</i></b> properties to the InitialContext constructor, just use <b><i>new InitialContext();</i></b>

3. Declare and use an <b><i>ejb-ref</i></b> from the component in app A to the EJB in app B that you want to lookup. Please have a look at these documents:

http://help.sap.com/saphelp_nw04/helpdata/en/55/29ed5eff965448941c0b42f01b9804/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/a0/019b3e25f95f14e10000000a114084/frameset.htm

Hope that helps!

Vladimir

Former Member
0 Kudos

Hi Vladimir,

Thanks for the help.

First the good news: Using the <ejb-ref> mechanism fixed the IllegalArgumentException that I was experiencing.

Okay, now the bad news: Using the ejb-ref mechanism is highly undesirable for this particular application. I know it is the recommended approach, but undesirable for us none the less. I am currently porting (to SAP-WAS) a very large application that is actually used to create other J2EE applications. There is a huge amount of existing code that relies heavily on a physical jndi naming scheme. For this reason, among others, I would like to avoid using the <ejb-ref> mechanism (in this case).

Is there some SAP-WAS specific reason I must use the ejb-ref mechanism? Are there other options?

Thanks again for your help.

Cheers,

Chad

Vlado
Advisor
Advisor
0 Kudos

Hi Chad,

Firstly, sorry for the late reply, somehow I missed this topic in the last few days.

The reason to use the ejb-ref mechanism is that in this way all references between deployed EJBs are managed by the EJB Container. This includes, amongst other features, the proper classloader management within different apps. Have you tried points 1. and 2. from my previous post? I think that if you go this way your scenario should work without using ejb-refs, though.

Hope that helps!

Vladimir

Former Member
0 Kudos

Vladimir,

I upgraded to SP11 and this issue disappeared. Thanks for your help.

Chad