Weld,Tomcat:在META-INF中缺少“beans.xml”。

huangapple 未分类评论47阅读模式
英文:

Weld, Tomcat: missing "beans.xml" in META-INF

问题

我知道许多类似的问题已经被提出过(例如这个这个等),但是它们都不能帮助我,所以我决定再次提出这个问题 - 我已经为此苦苦挣扎了几个小时,真的没有任何思路了。

我有一个Java EE项目,其中包含一个简单的servlet,用于接收来自HTML表单的数据,在外部服务中执行一些查询(使用REST和JAX-RS),并返回结果。我的目标是将它部署在独立的Tomcat服务器上。我尝试实现它的方式是通过导出WAR构件并将其复制到Tomcat的webapps目录中。

在使用JAX-RS发送REST请求的过程中出现问题 - 我总是收到以下错误:

WELD-ENV-000016: 在 META-INF 中缺少 beans.xml 文件

我根本没有使用这个文件,但是根据我的阅读,它必须在那里,即使是空的...所以我尝试将它放在我能想到/了解到的任何位置,包括:

/web/META-INF
/web/WEB-INF
/src/main/webapp/META-INF
/src/main/webapp/WEB-INF
/src/main/resources/META-INF
/src/main/resources/WEB-INF

当我检查生成的 .war 文件或Tomcat部署后创建的目录时,beans.xml 存在于 META-INF 和 WEB-INF 目录中。

在Intellij IDE中的单元测试中初始化Weld并执行这些查询效果很好 - 这里唯一的要求是将包含 WEB-INF 和 META-INF 的目录标记为“Resources Root”。

在我的模块配置中,我将包含 WEB-INF 和 META-INF 的目录标记为“Web Resource Directory”,并且*'Web' 模块资源*包含在我的构件中。

有任何想法吗?我是否基本上有什么误解,这里的Weld是否需要不同的、分开的 META-INF 或其他什么东西?

英文:

I know many similar questions have already been asked (ex. this, this, etc.), but none of them could help me, so I decided to bring it up again - been struggling for hours and I've really run out of ideas.

I have a Java EE project, whith simple servlet that accepts data from HTML form, performs a few queries in external services (with REST and JAX-RS) and returns results. My goal now is to deploy it on standalone Tomcat server. The way I'm trying to achieve it is by exporting WAR artifact and copying it to Tomcat's webapps directory.

It works up to the moment of sending REST request with JAX-RS - then I always get the error:

WELD-ENV-000016: Missing beans.xml file in META-INF

I'm not using this file at all, but as I read, it must be there, even if empty... so I've tried to put it at any location I could think of/read about, including:

/web/META-INF
/web/WEB-INF
/src/main/webapp/META-INF
/src/main/webapp/WEB-INF
/src/main/resources/META-INF
/src/main/resources/WEB-INF

When I check the output .war file or directories created by Tomcat after deployment, beans.xml is present in both META-INF and WEB-INF directories.

Initializing Weld and performing those queries works well in unit tests inside Intellij IDE - the only requirement here was to mark directory containing WEB-INF and META-INF as "Resources Root".

In my facet configuration, I mark directory containing WEB-INF and META-INF as "Web Resource Directory", and *'Web' facet resources' is included in my artifact.

Any ideas? Am I fundamentally misunderstanding something, does this inner Weld here require different, separate META-INF or something?

答案1

得分: 0

因为没有人回答,我至少会分享我的结论 - 最简单的方法是切换到TomEE(如果可行的话)。

英文:

As nobody answered, I'll at least share my conclusion - the simplest way is to switch to TomEE (if that is acceptable).

huangapple
  • 本文由 发表于 2020年4月3日 21:15:17
  • 转载请务必保留本文链接:https://java.coder-hub.com/61012748.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定