You are on page 1of 6

Weblogic EJB 1.

Ejb 2
package com.dc.portal.ejb3; import javax.ejb.EJBHome; public interface MyEjbHome extends EJBHome { public MyEjbRemote create() throws Exception; } package com.dc.portal.ejb3; import javax.ejb.EJBObject; public interface MyEjbRemote extends EJBObject { public String say(String args) throws Exception; } package com.dc.portal.ejb3; import java.rmi.RemoteException; import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; public class MyEjbSessionBean implements SessionBean { @Override public void ejbActivate() throws EJBException, RemoteException { // TODO Auto-generated method stub } @Override public void ejbPassivate() throws EJBException, RemoteException { } @Override public void ejbRemove() throws EJBException, RemoteException { // TODO Auto-generated method stub } @Override public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException { // TODO Auto-generated method stub } //ejbCreate()weblogic public void ejbCreate() throws EJBException,RemoteException { // TODO Auto-generated method stub

} public String say(String args) throws Exception{ return ""+args; } }

ejb-jar.xml <?xml version="1.0"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems Inc.//DTD Enterprise JavaBeans 1.2//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_2.dtd"> <ejb-jar> <enterprise-beans> <session> <ejb-name>myejb</ejb-name> <home>com.dc.portal.ejb3.MyEjbHome</home> <remote>com.dc.portal.ejb3.MyEjbRemote</remote> <ejb-class>com.dc.portal.ejb3.MyEjbSessionBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> </ejb-jar> xmlweblogic-ejb-jar.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN" "http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd"> <weblogic-ejb-jar> <description><![CDATA[Generated by XDoclet]]></description> <weblogic-enterprise-bean> <ejb-name>myejb</ejb-name> <stateless-session-descriptor> </stateless-session-descriptor> <reference-descriptor> </reference-descriptor> <jndi-name>myejb</jndi-name> </weblogic-enterprise-bean> </weblogic-ejb-jar>

jar classes META-INF

META-INF 2 ejb-jar.xml weblogic-ejb-jar.xml

jar webloic10 ->-> jar ->->->


package com.dc.portal.ejb3.client; import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import com.dc.portal.ejb3.MyEjbHome; import com.dc.portal.ejb3.MyEjbRemote; //import java.rmi.RmoteException; /** * @author Copyright c 2000 by Apusic, Inc. All Rights Reserved. */ public class MyClient { public static void main(String args[]){ String url = "t3://localhost:7001"; Context initCtx = null; // MyEjbHome hellohome = null; try { Hashtable env = new Hashtable(); // env.put(Context.INITIAL_CONTEXT_FACTORY,"com.apusic.jndi.InitialConte xtFactory"); env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialConte xtFactory"); env.put(Context.PROVIDER_URL, url); initCtx = new InitialContext(env); } catch(Exception e){

System.out.println("Cannot get initial context: " + e.getMessage()); System.exit(1); } try { Object obj=initCtx.lookup("myejb"); MyEjbHome home=(MyEjbHome)PortableRemoteObject.narrow(obj,MyEjbHome.class); MyEjbRemote myRemote = home.create(); String s = myRemote.say("EJB"); System.out.println(s); }catch(Exception e){ System.out.println(e.getMessage()); System.exit(1); } } }

weblogic , , Exception preparing module: EJBModule(myejb) Unable to deploy EJB: myejb.jar from myejb.jar: There are 1 nested errors: weblogic.ejb.container.compliance.ComplianceException: In EJB myejb, the stateless session bean class must define a single ejbCreate method that takes no parameters. at weblogic.ejb.container.compliance.SessionBeanClassChecker.checkStatelessEjbCreate(SessionBea nClassChecker.java:115) 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:597) at weblogic.ejb.container.compliance.EJBComplianceChecker.check(EJBComplianceChecker.java:331) at weblogic.ejb.container.compliance.EJBComplianceChecker.checkDeploymentInfo(EJBCompliance Checker.java:280) at weblogic.ejb.container.ejbc.EJBCompiler.checkCompliance(EJBCompiler.java:789) at weblogic.ejb.container.ejbc.EJBCompiler.doCompile(EJBCompiler.java:222) at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:461) at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:428) at weblogic.ejb.container.deployer.EJBDeployer.runEJBC(EJBDeployer.java:439) at weblogic.ejb.container.deployer.EJBDeployer.compileJar(EJBDeployer.java:779) at

weblogic.ejb.container.deployer.EJBDeployer.compileIfNecessary(EJBDeployer.java:679) at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:1238) at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:442) at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:19 9) at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.jav a:517) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.jav a:159) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.jav a:45) at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184) at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:4 3) at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:15 4) at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer( ActivateOperation.java:207) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation .java:98) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.j ava:217) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(Deployme ntManager.java:747) at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(Deployment Manager.java:1216) at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.j ava:250) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentService Dispatcher.java:159) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCal lback(DeploymentReceiverCallbackDeliverer.java:171) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000( DeploymentReceiverCallbackDeliverer.java:13) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(Deplo ymentReceiverCallbackDeliverer.java:46) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl .java:528) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207) at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)

sessionBean ejbCreate