0

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?

tyrrr
  • 528
  • 2
  • 11
  • On EE server, you have CDI impl out of the box. When moving to servlet, you need to do some extra work. In this case, it means adding extra JAR for Weld, see [this part of the doc](https://docs.jboss.org/weld/reference/latest/en-US/html_single/#weld-servlet). Have you done that? – Siliarus Apr 06 '20 at 10:13
  • I've tried doing steps listed there (adding dependencies to module and creating/modyfing context.xml and web.xml), sadly error is still there. – tyrrr Apr 07 '20 at 13:55

1 Answers1

0

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

tyrrr
  • 528
  • 2
  • 11