当然可以,只是不能使用EJB的所有功能,下面是不可用的功能(应用官方文档原文): ·XA Connection pool is not available yet. ·When embedding into Tomcat, you still require a JBoss specific JNDI implementation. Tomcat's JNDI is read-only. ·You still must use the JBoss transaction manager even when embedding in another app server vendor. This will be remedied in the future when the JBoss AOP/Microcontainer integration is complete. ·Distributed remote communication is not supported yet. ·EJB Timer service not supported ·Even though @Remote interfaces are local, you can only communicate through local connections. ·You cannot access JMS remotely. Only locally. Thus, you have to lookup the "java:/ConnectionFactory". ·JNDI is not available remotely用现在的EJB3的话,如下就可以部署在tomcat中: 1.根据应用的需要,把调用EJB所依赖的Jar 包拷贝到tomcat下的/shared/lib目录或WEB应用的 WEB-INF/lib下,所依赖的Jar 一般在jboss安装目录的client,/server/all/deploy/jboss-aop-jdk50.deployer,/server/all/deploy/ejb3.deployer,/lib/endorsed等文件夹下。 下面的jar 文件是必需的: [jboss安装目录]\client\jbossall-client.jar [jboss安装目录]\server\all\deploy\jboss-aop-jdk50.deployer\jboss-aop-jdk50.jar [jboss安装目录]\server\all\deploy\jboss-aop-jdk50.deployer\jboss-aspect-library-jdk50.jar [jboss安装目录]\server\all\deploy\ejb3.deployer\jboss-ejb3.jar [jboss安装目录]\client\jboss-remoting.jar 2.把调用的EJB接口拷贝到应用的/WEB-INF/classes/目录下 要注意的是:在此环境下不能调用EJB的Local 接口,因为他与JBOSS不在同一个VM中。
tomcat是一个servlet和jsp的容器不是j2ee的容器
·XA Connection pool is not available yet.
·When embedding into Tomcat, you still require a JBoss specific JNDI implementation. Tomcat's
JNDI is read-only.
·You still must use the JBoss transaction manager even when embedding in another app server vendor.
This will be remedied in the future when the JBoss AOP/Microcontainer integration is complete.
·Distributed remote communication is not supported yet.
·EJB Timer service not supported
·Even though @Remote interfaces are local, you can only communicate through local connections.
·You cannot access JMS remotely. Only locally. Thus, you have to lookup the
"java:/ConnectionFactory".
·JNDI is not available remotely用现在的EJB3的话,如下就可以部署在tomcat中:
1.根据应用的需要,把调用EJB所依赖的Jar 包拷贝到tomcat下的/shared/lib目录或WEB应用的
WEB-INF/lib下,所依赖的Jar 一般在jboss安装目录的client,/server/all/deploy/jboss-aop-jdk50.deployer,/server/all/deploy/ejb3.deployer,/lib/endorsed等文件夹下。
下面的jar 文件是必需的:
[jboss安装目录]\client\jbossall-client.jar
[jboss安装目录]\server\all\deploy\jboss-aop-jdk50.deployer\jboss-aop-jdk50.jar
[jboss安装目录]\server\all\deploy\jboss-aop-jdk50.deployer\jboss-aspect-library-jdk50.jar
[jboss安装目录]\server\all\deploy\ejb3.deployer\jboss-ejb3.jar
[jboss安装目录]\client\jboss-remoting.jar
2.把调用的EJB接口拷贝到应用的/WEB-INF/classes/目录下
要注意的是:在此环境下不能调用EJB的Local 接口,因为他与JBOSS不在同一个VM中。