无法将战争部署到 Weblogic——服务器无法解析不属于我的类路径 ejb-refs
我有一个 Maven 应用程序 .war
,我正在使用 Weblogic Maven插件(很棒的插件,顺便说一句),我正在将它部署到 Weblogic 服务器(当然)。不幸的是,我不断收到部署失败消息:
weblogic.deployment.EnvironmentException: [J2EE:160200]Error resolving ejb-ref 'com.vendor.thing.UsingHelloWorldEJB/h' from module 'myapp.war' of application ' myapp'。 ejb-ref 没有 ejb-link,并且尚未指定目标 bean 的 JNDI 名称。尝试自动将 ejb-ref 链接到其目标 bean 失败,因为在应用程序中找不到实现“com.vendor.thing.HelloWorld”接口的 EJB。请将此 ejb-ref 链接或映射到其目标 EJB,并确保 ejb-ref 中声明的接口正确。
嗯?
这个 HelloWorld
EJB 不是我的应用程序的一部分,而且我知道该类存在的唯一位置(Weblogic 甚至可以引用它)是在我在 .war 中使用的类路径 jar 中。这是一个供应商 .jar
,因此他们可能有一些我不使用或不了解的类是有道理的。在本例中,他们似乎将 EJB 类捆绑到我无法删除的 .jar
中。
为什么?
我不是 Weblogic 专家,所以这种行为对我来说很奇怪。此标准 servlet 行为是否尝试链接,然后基于某些不直接属于我的 .war 的任意类 EJB(除了类路径中的 API .jar)而使 .war 部署失败?
如何修复?
如何将我的 .war
部署到 Weblogic 服务器?我对这个ejb-ref
一无所知,它似乎也不影响我的应用程序在本地运行时的工作方式码头。有没有办法告诉 Weblogic 忽略此 .jar
或包范围中的所有类?
编辑 1
每 mhaller的回答,我又做了一些调查,发现:
- weblogic-maven-plugin使用了maven-war-plugin生成的.war,因此不会干扰war的生成。
- 除了我的 web.xml 之外,没有其他部署描述符(没有
weblogic.xml
或类似文件)。 - 手动部署
.war
的行为与使用 maven 插件没有什么不同(所以我认为 weblogic-maven-plugin 不会导致错误)
我的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.mypacakages.ws</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<!-- All web services will be under http://localhost:{port}/{context}/ws/ -->
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
</web-app>
I have a Maven application .war
that I am using the Weblogic Maven Plugin for (great plugin, btw), and I am deploying it to a Weblogic server (of course). Unfortunately, I keep getting a deploy failure message:
weblogic.deployment.EnvironmentException: [J2EE:160200]Error resolving ejb-ref 'com.vendor.thing.UsingHelloWorldEJB/h' from module 'myapp.war' of application 'myapp'. The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because no EJBs in the application were found to implement the 'com.vendor.thing.HelloWorld' interface. Please link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.
Huh?
This HelloWorld
EJB isn't part of my application, and the only place that I know this class exists for Weblogic to even reference it is in a classpath jar that I use within the .war. This is a vendor .jar
, so it makes sense that they might have some classes that I don't use or know about. In this case, it appears they bundled an EJB class into the .jar
that I can't remove.
Why?
I'm not a Weblogic expert, so this behavior is odd to me. Is this standard servlet behavior to try to link and then fail a .war deploy based on some arbitrary class EJB's that aren't directly a part of my .war (other than as an API .jar in the classpath)?
How to fix?
How can I get my .war
deployed to the Weblogic server? I don't know anything about this ejb-ref
, nor does it seem to affect anything in how my app works when running locally with Jetty. Is there a way to tell Weblogic to ignore all classes in this .jar
or package scope?
EDIT 1
Per mhaller's answer, I did some more investigation and found that:
- weblogic-maven-plugin uses the .war generated from the maven-war-plugin, so it doesn't interfere with the generation of the war.
- There are no additional deployment descriptors (no
weblogic.xml
or similar) other than my web.xml. - manually deploying the
.war
behaves no differently than using the maven plugin (so I think the weblogic-maven-plugin isn't causing the fault)
My web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.mypacakages.ws</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<!-- All web services will be under http://localhost:{port}/{context}/ws/ -->
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
</web-app>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
maven-war-plugin
。.war
file contains additional deployment descriptors, which you do not need. I suspect the maven-weblogic-plugin adds custom deployment descriptors.maven-war-plugin
instead.