Posts Tagged ‘NPE’

NullPointerException calling RemoteBusinessInterface

June 25, 2009 1 comment

I recently ran into the following issue while trying to JUnit myself into an EJB3 service running inside my Weblogic 10.3 :

at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.getTargetMethod(
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(
at $Proxy0.myServiceCall(Unknown Source)
at com.siemens.enginedevelopment.MyTest.testMyTest(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

There was no apparent reason for this to happen, the service was running well when called from inside the weblogic instance, and JUnit calls made on other workstations, with older workspaces, still worked without a hitch.
I did some digging on the interwebz, and managed to find the solution to my problems. Seems there is a bug in Weblogic 10R3. All you need to make this work is force your IDE to run wlappc on your EJB Service classes, this will generate appropriate stubs and the problem will go away.

The solution can be found here. I’m transcribing it for posterity:

All right, after having spent two days on this issue, I finally found out that in order to be able to use generics in EJB with WebLogic, one needs to have appc generated stubs on the client side. Doing that is not trivial in Eclipse (OEPE) but adding an ant script like the following

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?>
<project basedir=”.” default=”build-project” name=”ww204-ejb”>
<property name=”jpa.project” value=”../ww204-jpa”/>
<target name=”build-project”>
<echo message=”${}: ${ant.file}” />
<taskdef name=”wlappc” classname=”weblogic.ant.taskdefs.j2ee.Appc”/>
<wlappc source=”build/classes” forceGeneration=”true” verbose=”true” deprecation=”true”>
<pathelement location=”${jpa.project}/build/classes”/>

which generates the appc stubs in the EJB Project’s binary output directory and using this directory in the remote client CLASSPATH solves the problem. This is probably not regular as there is no any other application server having such a requirement but, if you want to use EJB with WebLogic and if, as myself, you think it would be too stupide not to use generics, you need to do that. You may continue using the WTP build facilities of Eclipse (OEPE) but you need to add to your EJB Project an ant builder which runs the script above. That’s a pain, I know, but it seems to be the only way to decently do EJB/JPA with WebLogic. That’s crazy that I needed to spend two days to come to something which is probably already known since longtime. So, I hope that, as oposed to myself, other people will be luckyer and beneficiate of this post.

Kind regards,


Categories: ejb3, java Tags: , ,