Getting Persistence Reference returns null

Hello:
I am trying to get the reference of Persistence Class Object through code by using
Persistence persistence=AppBeans.get(Persistence.class)
but it returns the null value. Can you please tell me the reason and How I can get this?

Thank You!

Hello, @saadrasool05

Where are you trying to obtain an instance of the Persistence bean? Moreover, the recommended way is to inject it via @Inject annotation:

@Inject
private Persistence persistence;

Regards,
Daniil.

I have solved the issue.

Thank You!

What was the problem and how did you solve it?