尝试在此链接{web}下运行Hello World EJB时出现以下错误EJB Hello World
这是Bean文件:
package hello;
import javax.ejb.Stateless;
@Stateless(mappedName = "TestSessionBean")
public class TestSessionBean implements TestSessionBeanRemote,
TestSessionBeanLocal {
public String hello(String name) {
System.out.println("Hello" + name);
return name;
}
}
本地界面:
package hello;
import javax.ejb.Local;
@Local
public interface TestSessionBeanLocal {
}
远程接口:
package hello;
import javax.ejb.Remote;
@Remote
public interface TestSessionBeanRemote {
}
客户档案:
package hello;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class TestClient {
private static String INITIAL_CONTEXT_NAME ="weblogic.jndi.WLInitialContextFactory";
private static String PROVIDER_URL = "t3://localhost:7001";
private static String JNDI_NAME = "TestSesssionBean";
public static void main(String[] args) throws Exception {
Context ctx = getInitialContext();
TestSessionBean testEJB = (TestSessionBean) ctx
.lookup(JNDI_NAME);
System.out.println(testEJB.hello("Amey"));
}
private static Context getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_NAME);
env.put(Context.PROVIDER_URL, PROVIDER_URL);
return new InitialContext(env);
}
}
异常日志:
weblogic.application.ModuleException: Exception preparing module: EJBModule(EJBTEST.jar)
Unable to deploy EJB: EJBTEST.jar from EJBTEST.jar:
There are 1 nested errors:
weblogic.ejb.container.compliance.ComplianceException: No business interface, component interface or web service endpoint interface found for Session Bean TestSessionBean
at weblogic.ejb.container.compliance.SessionBeanClassChecker.checkInterfacesExist(SessionBeanClassChecker.java:177)
at weblogic.ejb.container.compliance.Ejb30SessionBeanClassChecker.checkInterfacesExist(Ejb30SessionBeanClassChecker.java:27)
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:337)
at weblogic.ejb.container.compliance.EJBComplianceChecker.checkDeploymentInfo(EJBComplianceChecker.java:286)
at weblogic.ejb.container.ejbc.EJBCompiler.complianceCheckJar(EJBCompiler.java:952)
at weblogic.ejb.container.ejbc.EJBCompiler.checkCompliance(EJBCompiler.java:920)
at weblogic.ejb.container.ejbc.EJBCompiler.doCompile(EJBCompiler.java:246)
at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:552)
at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:519)
at weblogic.ejb.container.deployer.EJBDeployer.runEJBC(EJBDeployer.java:393)
at weblogic.ejb.container.deployer.EJBDeployer.compileJar(EJBDeployer.java:715)
at weblogic.ejb.container.deployer.EJBDeployer.compileIfNecessary(EJBDeployer.java:618)
at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:1154)
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:425)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:197)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:89)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:723)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1190)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:248)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
java.lang.Exception: Exception received from deployment driver. See Error Log view for more detail.
at oracle.eclipse.tools.weblogic.server.internal.DeploymentProgressListener.watch(DeploymentProgressListener.java:190)
at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper.deploy(WlsJ2EEDeploymentHelper.java:483)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishWeblogicModules(WeblogicServerBehaviour.java:1461)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishToServer(WeblogicServerBehaviour.java:896)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishOnce(WeblogicServerBehaviour.java:677)
at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publish(WeblogicServerBehaviour.java:530)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774)
at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3027)
at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:341)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: weblogic.application.ModuleException: Exception preparing module: EJBModule(EJBTEST.jar)
Unable to deploy EJB: EJBTEST.jar from EJBTEST.jar: