Archive

Archive for June, 2009

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 :

java.lang.NullPointerException
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.getTargetMethod(RemoteBusinessIntfProxy.java:162)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:53)
at $Proxy0.myServiceCall(Unknown Source)
at com.siemens.enginedevelopment.MyTest.testMyTest(MyTest.java:74)
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(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

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.project.name}: ${ant.file}” />
<taskdef name=”wlappc” classname=”weblogic.ant.taskdefs.j2ee.Appc”/>
<wlappc source=”build/classes” forceGeneration=”true” verbose=”true” deprecation=”true”>
<classpath>
<pathelement location=”${jpa.project}/build/classes”/>
</classpath>
</wlappc>
</target>
</project>

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,

Nicolas

Advertisements
Categories: ejb3, java Tags: , ,