将计划的 EJB 部署到 Glassfish 服务器时出现问题
我想将 EJB 部署到 Glassfish 3.1 应用程序服务器,但遇到了一个奇怪的(?)问题。
我有这个 bean,它应该使用 @Schedule
注释在 Glassfish 中连续执行。这对我来说效果很好,直到我向 EJB 访问数据库添加了一些代码。
@Stateless
public class MyBean implements MyBeanLocal {
@Schedule(second = "*", minute = "*", hour = "*")
public void initiateProcess() {
MyCoordinator mc = new MyCoordinatorImpl();
List<Entity> entities = mc.methodAccessingDB();
}
}
这是我的 EJB,每秒执行一次。正如我上面所说,如果我不调用ac.methodAccessingDB()
,我可以部署此EJB并且它成功执行。 这意味着我什至无法将其部署到 Glassfish。玻璃鱼告诉我
无效的 ejb jar [...]:它包含零个 ejb。注意:1.一个有效的ejb jar 需要至少一个会话、实体(1.x/2.x 样式)或 消息驱动的bean。 2. EJB3+ 实体 bean (@Entity) 是 POJO, 请将它们打包为库 jar。 3. 如果jar文件包含有效的 使用 EJB 组件级注释进行注释的 EJB (@Stateless、@Stateful、@MessageDriven、@Singleton),请检查 server.log 查看注释是否被正确处理。 请参阅 server.log 了解更多详细信息。
如果我只写 List
而不是 List
我可以部署它并且运行良好。
I have a weird (?) problem with an EJB I want to deploy to my Glassfish 3.1 application server.
I have this bean, which should be executed continuously in Glassfish using the @Schedule
annotation. This worked fine for me until I added some code to the EJB accessing a database.
@Stateless
public class MyBean implements MyBeanLocal {
@Schedule(second = "*", minute = "*", hour = "*")
public void initiateProcess() {
MyCoordinator mc = new MyCoordinatorImpl();
List<Entity> entities = mc.methodAccessingDB();
}
}
This is my EJB, which is executed every second. How I said above, I can deploy this EJB and it executed successfully, if I don't call ac.methodAccessingDB()
.
This means, that I can't even deploy it to Glassfish. Glassfish tells me
Invalid ejb jar [...]: it contains zero ejb. Note: 1. A valid ejb jar
requires at least one session, entity (1.x/2.x style), or
message-driven bean. 2. EJB3+ entity beans (@Entity) are POJOs and
please package them as library jar. 3. If the jar file contains valid
EJBs which are annotated with EJB component level annotations
(@Stateless, @Stateful, @MessageDriven, @Singleton), please check
server.log to see whether the annotations were processed properly..
Please see server.log for more details.
If I just write List<Entity> entities = null;
instead of List<Entity> entities = ac.methodAccessingDB();
I can deploy it and it runs fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,现在我已经找到了这个问题的解决方案。 EJB 在已部署版本上找不到类。解决方案是将所有内容打包到一个 ear 项目中。我使用的是maven,所以我最后创建了3个项目。
。然后我将封装好的耳朵部署到 Glassfish 上,计时器启动,一切都在那里。
OK, now I have found the solution for this problem. The EJB couldn't find the classes on the deployed version. The solution was to pack everything into an ear project. I am using maven, so I created in the end 3 projects.
<packaging>ejb</packaging>
<packaging>ear</packaging>
<module>
.I then deployed the packed ear to Glassfish and the timer started and everything was there.