Skip to main content

Error injecting persistence unit into CDI managed bean. Can't find a persistence unit named

I experienced this error while adding an EJB jar to a war. The EJB jar had a bean.xml file. Removing this file or turning the discovery mode to 'none' fix this error.

Some few research showed that there is a bug and it was logged but it was closed without the issue being resolved.

Comments

  1. Sometimes it's also problem with location of persistance.xml file, I had it in wrong location - webapp/META-INF instead of resources/META-INF

    ReplyDelete

Post a Comment

Popular posts from this blog

Fix HTTP error code 513 on Wildfly

The Mysterious Case of TIME_WAIT and IDLE Connections Have you ever encountered a network issue where your server is consistently showing a high number of connections in the TIME_WAIT and IDLE states? This phenomenon can be frustrating, especially when it indicates that the connections are not being closed properly by the server or client. In our investigation, we found that the culprit behind this issue was an HTTP error code 513 being sent to clients from servers. This error code indicates that the server is overloaded and cannot handle more requests. Furthermore, the client was logging a socket close event, which meant it was terminating the connection prematurely. To replicate this issue, we used JMeter and found that the max concurrent connection limit was reached, resulting in an HTTP error code 513. The allowed queue was also full, contributing to the problem. So, what are the consequences of this issue? Performance degradation and resource wastage on both servers and clients ca...

Catch persistence java.sql.sqlintegrityconstraintviolationexception

Handling SQL Integrity Constraint Violation Exceptions This tutorial will guide you through handling `SQLIntegrityConstraintViolationException` when persisting objects that violate database constraints. Step 1: Catch the EJB Exception Catch a `javax.ejb.EJBException` which wraps the underlying exception. try {     // persistence transactions } catch (Exception e) {     if (e instanceof javax.ejb.EJBException) {         logger.debug("Exception instance of javax.ejb.EjbException");     } } Step 2: Get the Underlying Exception Get the underlying exception from the `EJBException` using `e.getCause()`. try {     // persistence transactions } catch (Exception e) {     if (e instanceof javax.ejb.EJBException) {         logger.debug("Exception instance of javax.ejb.EjbException");         Throwable cause = e.getCause();         if (cause != null) {     ...

Quick Reminder: Golang subfolder import

Here is a tip for importing into your project. First, you import with the folder path but you use the declared package name in the imported class as the anchor to the methods in the imported class. For example, let's say you have your project in the following structure: example    main.go    pwd/       foldering.go To import foldering.go even if the package name declared in foldering.go is different e.g. secondPwd  into main.go main.go package main import (      "example/pwd" ) func main(){     secondPwd.PrintPWD(); } foldering.go package secondPwd import(      "os"      "fmt"      "log" ) //PrintPWD... func PrintPWD() {     dir, err := os.Getwd()      if err != nil {          log.Fatal(err)      }  ...