-
Folks
I am trying to convert an EJB2.1 bean to a EJB3.0 Bean which can be accessed from EJB2.1 clients.
I am getting the following StackTrace on running Weblogic.appc using Weblogic 10
[java] <Compiling EAR module 'admin-ejb.jar'>
[java] In EJB EJB3 both the remote home and remote component interface must be specified. Currently, only one of them is specified.
[java] at weblogic.ejb.container.deployer.ClientDrivenBeanInfoImpl.checkClientViews(ClientDrivenBeanInfoImpl.java:1483)
[java] at weblogic.ejb.container.deployer.ClientDrivenBeanInfoImpl.(ClientDrivenBeanInfoImpl.java:149)
[java] at weblogic.ejb.container.deployer.SessionBeanInfoImpl.(SessionBeanInfoImpl.java:106)
[java] at weblogic.ejb.container.deployer.Ejb3SessionBeanInfoImpl.(Ejb3SessionBeanInfoImpl.java:94)
[java] at weblogic.ejb.container.deployer.BeanInfoImpl.createBeanInfoImpl(BeanInfoImpl.java:664)
[java] at weblogic.ejb.container.deployer.MBeanDeploymentInfoImpl.initializeBeanInfos(MBeanDeploymentInfoImpl.java:499)
[java] at weblogic.ejb.container.deployer.MBeanDeploymentInfoImpl.(MBeanDeploymentInfoImpl.java:224)
[java] at weblogic.ejb.container.ejbc.EJBCompiler.getStandAloneDeploymentInfo(EJBCompiler.java:1412)
[java] at weblogic.ejb.container.ejbc.EJBCompiler.setupEJB(EJBCompiler.java:169)
[java] at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:511)
[java] at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:471)
[java] at weblogic.application.compiler.AppcUtils.compileEJB(AppcUtils.java:298)
[java] at weblogic.application.compiler.EJBModule.compile(EJBModule.java:83)
[java] at weblogic.application.compiler.flow.CompileModuleFlow.compileModules(CompileModuleFlow.java:103)
[java] at weblogic.application.compiler.flow.CompileModuleFlow.compile(CompileModuleFlow.java:58)
[java] at weblogic.application.compiler.FlowDriver$FlowStateChange.next(FlowDriver.java:69)
[java] at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
[java] at weblogic.application.compiler.FlowDriver.nextState(FlowDriver.java:36)
[java] at weblogic.application.compiler.FlowDriver.run(FlowDriver.java:26)
[java] at weblogic.application.compiler.EARCompiler.compile(EARCompiler.java:46)
[java] at weblogic.application.compiler.flow.AppCompilerFlow.compileInput(AppCompilerFlow.java:118)
[java] at weblogic.application.compiler.flow.AppCompilerFlow.compile(AppCompilerFlow.java:43)
[java] at weblogic.application.compiler.FlowDriver$FlowStateChange.next(FlowDriver.java:69)
[java] at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
[java] at weblogic.application.compiler.FlowDriver.nextState(FlowDriver.java:36)
[java] at weblogic.application.compiler.FlowDriver.run(FlowDriver.java:26)
[java] at weblogic.application.compiler.Appc.runBody(Appc.java:172)
[java] at weblogic.utils.compiler.Tool.run(Tool.java:158)
[java] at weblogic.utils.compiler.Tool.run(Tool.java:115)
[java] at weblogic.application.compiler.Appc.main(Appc.java:183)
[java] at weblogic.appc.main(appc.java:14)
[java] In EJB EJB3, both the remote home and remote component interface must be specified. Currently, only one of them is specified.
Here is the code:
Can somebody please tell me what is going on?
Markiv
-----------------------------------------------------------------------------------------
package EJB3Code;
import java.rmi.RemoteException;
import javax.ejb.*;
import javax.ejb.EJBHome;
public interface EJB3Home extends EJBHome
{
EJB3Remote create() throws javax.ejb.CreateException, RemoteException;
}
---------------------------------------------------------------------------------------
package EJB3Code;
import java.util.ArrayList;
import java.util.Collection;
import java.lang.annotation.*;
import javax.annotation.PreDestroy;
import javax.ejb.*;
import javax.ejb.Stateless;
import javax.ejb.Init;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.ejb.Remove;
import javax.ejb.RemoteHome;
import org.apache.log4j.Category;
@Remote({EJB3Remote.class})
@Stateless(name="EJB3")
@RemoteHome(EJB3Home.class)
public class EJB3EJB implements EJB3Remote
{
private SessionContext ctx;
private static Category log;
@Init
public void ejbCreate() throws CreateException
{
}
public void EJB3EJB() {
log = Log4JCategoryFactory.getCategoryInstanceFor(EJB3EJB.class.getName());
}
@PreDestroy
public void ejbRemove()
{
}
@PostActivate
public void ejbActivate()
{
}
@PrePassivate
public void ejbPassivate()
{
}
public void setSessionContext(SessionContext sc)
{
ctx = sc;
}
public String getPasswordHint(String userName, String districtOid) throws AuthenticationFailedException
{
return passwordHint;
}
}
------------------------------------------------------------------------------------------------
package EJB3Code;
import java.util.Collection;
import javax.ejb.EJBException;
import javax.ejb.EJBObject;
@Remote
public interface EJB3Remote
{
public String getPasswordHint(String userName, String districtOid) throws AuthenticationFailedException;
}
-
Have you found the reason for your problem? I'm facing the same issue myself... :(
-
Have you guys found the answer to the question. I am facing the same problem and no help from BEA.
-
The solution for EJB 2.1 backwards compatibility is to make a specific EJB 2.1 remote business interface where the methods throw RemoteExeption and the interface extends EJBObject. We must also make a Home interface and where the create method returns the 2.1 business interface.
------------- the EJB 3.0 ejb ---------
@Stateless(name = "Ejb21HelloWorld", mappedName = "helloEjb3Wold")
@RemoteHome(value = Ejb21HelloWorldHome.class)
@Remote( { Ejb21HelloWorldBI.class })
public class Ejb21HelloWorldEJB implements Ejb21HelloWorld {
private static final long serialVersionUID = 1L;
@TransactionAttribute(value = TransactionAttributeType.NOT_SUPPORTED)
public void hello(String message) {
System.out.println("hello: "+message);
}
@SuppressWarnings("unused")
@Init
public void ejbCreate() throws CreateException {
// Due to the Init annotation this method corresponds to the ejbCreate
// method of the EJB 2.1 bean.
// There is no need to specify this method if it is empty as here.
}
@PreDestroy
public void ejbRemove() {
// Due to the PreDestroy annotation this method corresponds to the
// ejbRemove method of the EJB 2.1 bean.
// There is no need to specify this method if it is empty as here.
}
@PostActivate
public void ejbActivate() {
// Due to the PostActivate annotation this method corresponds to the
// ejbActive method of the EJB 2.1 stateful bean.
// There is no need to specify this method if it is empty as here.
}
@PrePassivate
public void ejbPassivate() {
// Due to the PrePassivate annotation this method corresponds to the
// ejbPassivate method of the EJB 2.1 stateful bean.
// There is no need to specify this method if it is empty as here.
}
}
------------ the EJB 3.0 interface --------
@Remote
public interface Ejb21HelloWorld {
public void hello(String name);
}
----------- the EJB 2.1 remote business interface --------
public interface Ejb21HelloWorldBI extends javax.ejb.EJBObject
{
public void hello(String name) throws RemoteException;
}
---------- the EJB 2.1 remote home interface ---------
public interface Ejb21HelloWorldHome
extends javax.ejb.EJBHome
{
public dk.tdc.sctexample.ejb.Ejb21HelloWorldBI create()
throws javax.ejb.CreateException,java.rmi.RemoteException;
}