为了学习如何编写EJB 3.0,我遵循了这个指南http://jonas.ow2.org/doc/JONAS_5_1_7/doc/doc-en/html/ejb3_programmer_guide.html,但是我在2.3. Writing the Client Code
章之后卡住了。
我使用的是rad8.5和was7.0。我创建了EJB项目和会话bean,但是当我运行客户机(在bean的相同项目和EAR中)时,我总是得到这个错误:
22-lug-2014 12.33.15 null null
WARNING: WSVR0072W
22-lug-2014 12.33.15 null null
WARNING: WSVR0072W
22-lug-2014 12.33.15 null null
WARNING: WSVR0072W
22-lug-2014 12.33.15 null null
WARNING: WSVR0072W
22-lug-2014 12.33.15 null null
INFO: Client code attempting to load security configuration
Exception in thread "P=194786:O=0:CT" java.lang.ClassCastException: org.omg.stub.java.rmi._Remote_Stub incompatible with HelloWorldInterface
at Client.main(Client.java:26)
我已经尝试了几种解决方案,但没有结果。知道如何解决这个错误吗?
在java main或JUnit上下文中,您必须使用createejbstub .bat生成EJB 3存根。我正在使用ANT任务为我生成它…
。home - WAS安装根目录
locationName - EAR文件的位置
<target name="export_ear">
<earExport earProjectName="MyProject" earExportFile="${locationName}/MyProject.ear" exportSource="false" overwrite="true"/>
</target>
<target name="createStubs" depends="export_ear">
<exec executable="${was.home}/bin/createEJBStubs.bat">
<arg line="${locationName}/MyProject.ear" />
</exec>
</target>
生成存根后,必须从MyProject中提取MyProject.jar和MyProjectClient.jar。