0

I have a problem to deploy EJB and WAR modules at the same time in NetBeans 8.2 on GlassFish 4.1.1. The following message is shown:

[[ Exception Occurred :Error occurred during deployment: Exception while preparing the app : Could not resolve a persistence unit corresponding to the persistence-context-ref-name [ejb.NewMessage/em] in the scope of the module called [TestEJB-ejb]. Please verify your application.. Please see server.log for more details.]]

When I checked server.log file of GlassFish server, I faced with the following erreor message:

[2018-07-28T12:59:45.406+0430] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=427 _ThreadName=admin-listener(7)] [timeMillis: 1532766585406] [levelValue: 1000] [[
  Exception while preparing the app : Could not resolve a persistence unit corresponding to the persistence-context-ref-name [ejb.NewEntityFacade/em] in the scope of the module called [TestEJB-ejb]. Please verify your application.]]

Is there any solution for that?

Thanks for your help.

Mahyar Esteki
  • 189
  • 2
  • 12
  • Have you considered packaging them together in an EAR? And you know that nowadays you can put most code in the WAR (look up EJB Lite) so chances are you do not even have to split up your code? – fvu Jul 28 '18 at 08:44
  • Have a look at https://stackoverflow.com/questions/4167619/fixing-could-not-resolve-a-persistence-unit-errors-when-pu-is-specified-fo . – fvu Jul 28 '18 at 08:47
  • @fvu Thanks for replay. Yes I did. I create an enterprise application which was included both EJB and WAR Modules – Mahyar Esteki Jul 28 '18 at 09:19
  • @fvu Even I created an independent EJB Module but it is not deployed – Mahyar Esteki Jul 28 '18 at 09:38
  • With what you provide it's impossible to really pinpoint the issue, but could it be that you have issues related to where you put the persistence.xml file? [This post](https://stackoverflow.com/questions/4073635/sharing-a-persistence-unit-across-components-in-a-ear-file) goes into detail about where you could put it in order to make it accessible – fvu Jul 28 '18 at 11:02
  • @fvu No it is not because I follow the solution which is presented in this movie https://www.youtube.com/watch?v=qk4qYQG5tvM But is not also worked for me. – Mahyar Esteki Jul 28 '18 at 12:52
  • That's ejb3, I'd strongly suggest you look for an ejb3.1 tutorial as that is what GF4 implements. It does away with lots of the odd stuff in the ee spec, among other things you will almost certainly package your app in just 1 war, doing away with an extra layer of confusion you're facing now. At the same time you may want to have a look at [Payara](https://payara.fish), a greatly improved version of Glassfish. They stopped releasing the 4 series for free, the last versions (that are still far ahead of your current 4.1.1) can be found [here](https://www.payara.fish/previous_releases). – fvu Jul 28 '18 at 23:20

1 Answers1

0

If you did not start to create your app or if you did not choose your programming framework, you can switch to Java Spring with less headache!

Read the first paragraph of the following link: https://en.wikipedia.org/wiki/Spring_Framework

Mahyar Esteki
  • 189
  • 2
  • 12