在 appclient jar 中包含模型库
我正在将带有 EJB 的耳朵部署到 glassfish 3.1 上,我想使用 appclient 脚本来调用它。 EJB 有一个方法,该方法以模型对象作为参数,该模型对象在单独的库中定义。
如果我想使用 appclient 脚本,我有一个 Main 类,其中包含一个调用 EJB 的 main 方法。 这也被放入一个单独的罐子中,该罐子也被部署到玻璃鱼上。
由于模型对象位于一个单独的库中,因此我需要它在客户端 jar 中,但也需要在 EJB 中。 所以我需要在客户端 jar 中以某种方式引用它。
客户端 jar 是一个 jar(废话),所以我无法添加其他 jar。 Java EE 6 文档说我应该使用库创建一个ear,但如果我这样做,它不会部署,因为ear至少需要一个ejb或web模块,而我的客户端库两者都没有。
我找到的解决方案是使用程序集插件/jar-with-dependencies。该插件创建一个新的 jar,其中包含所有依赖项的所有类。
这个解决方案有效,但我想知道这是否是正确的方法,或者我错过了一些明显的东西,因为我无法想象这是必需的。 EJB 通常将模型对象作为参数,因此这种情况会经常发生。
所以我的问题是:有没有办法告诉 glassfish 引用应用程序客户端 jar 和 ejb jar 之间的共享库。
I'm deploying an ear with an EJB onto glassfish 3.1 which I want to call using the appclient script.
The EJB has a method with as parameter a model object which is defined in a separate library.
If I want to use the appclient script I have a Main class with a main method which calls the EJB.
This is also put into a separate jar which is also deployed onto glassfish.
As the model object is located in a separate library I need it in the client jar but also in the EJB.
So I need to reference it somehow in the client jar.
The client jar is a jar (duh) so I cannot add other jars. The Java EE 6 docs say that I should create an ear with the libs but if I do that it doesn't deploy because an ear needs at least an ejb or web module and my client lib has neither.
The solution I found is using the assembly plugin/jar-with-dependencies. This plugin creates a new jar which contains all classes of all dependencies.
This solution works but I'm wondering if this is the way to go or I'm missing something obvious because I cannot imagine this is required. EJB's usually have model objects as parameters so this situation will happen a lot.
So my question is: is there a way to tell glassfish to reference the shared libraries between the app client jar and the ejb jar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我这样做的方式是这样的:
bundle< 将其定义为 OSGi 包 ;/包装>
。我将此项目称为MyAppInterface
。为需要处理模型的其他元素提供单独的 Maven 项目。就我而言,我有一个包含 EJB、数据库外观、REST servlet 的 Java EE 应用程序;我有一个仅进行测试的集成测试项目; GWT 应用程序;等等...在这些项目中,我指定了对模型的依赖关系:
当将
MyAppInterface
部署到 Glassfish 时,我使用以下语法:asadmin deploy --type osgi --name MyAppInterface /path/to/MyAppInterface-1.0-SNAPSHOT.jar
我让所有这些项目都由中央 jenkins CI 服务器构建,该服务器将工件部署到我们的内部 Maven 存储库。然后,我们在每个项目的
pom.xml
中添加内部存储库。因此,每个人都会自动使用最新的稳定MyAppInterface
,即使他们没有在 NetBeans / Eclipse 中签出代码。如果您需要更多示例,请告诉我。
The way I do this is like this:
<packaging>bundle</packaging>
. I call this projectMyAppInterface
.Separate Maven projects for other elements that need to deal with the model. In my case, I have one Java EE application with EJBs, Database facade, REST servlet; I have an Integration-Test project which only does tests; a GWT application; etc... In those projects I specify the dependency to the model:
When deploying
MyAppInterface
to Glassfish, I use the following syntax:asadmin deploy --type osgi --name MyAppInterface /path/to/MyAppInterface-1.0-SNAPSHOT.jar
I let all these projects be built by a central jenkins CI server, which deploys the artifacts to our internal maven repository. We then add the internal repository in
pom.xml
of each project. As a result, everyone automatically works with the latest stableMyAppInterface
, even if they don't have the code checked out in NetBeans / Eclipse.Let me know if you need more examples.