0

I'be been struggling for about 20 hours and also working in the weekend as you can see and I can't make this work. I think I have exhausted all the online options

I have copied the example here https://rieckpil.de/howto-simple-form-based-authentication-for-jsf-2-3-with-java-ee-8-security-api/ in a new Dynamic web project in Eclipse for Java Enterprise Developers. I activated JSF 2.3 in the project facets (since I know that TomEE can use them) I copied the classes, I set the web.xml to be the same. My project runtime is TomEE8 (which is basically Tomcat9 with CDI and other stuff)

When I try to run the project on TomEE, I get this error:

javax.enterprise.inject.UnsatisfiedResolutionException: Api type [javax.security.enterprise.SecurityContext] is not found with the qualifiers Qualifiers: [@javax.enterprise.inject.Default()] for injection into Field Injection Point, field name : securityContext, Bean Owner : [LoginBacking, WebBeansType:MANAGED, Name:loginBacking, API Types:[java.lang.Object,LoginBacking], Qualifiers:[javax.inject.Named,javax.enterprise.inject.Default,javax.enterprise.inject.Any]]

I have tried creating the beans.xml file in my WEB-INF folder I have created another bean with this annotation:

@FacesConfig(
    // Activates CDI build-in beans
    version = JSF_2_3 
)

I have tried not using TomEE and using Tomcat 9 with weld, same problem.

I have no idea how to make this work. The thing is I need to add user login to my main application, but if this simple example won't work I don't think I can do this and I'm feeling very down. If anyone can help me see the light, I'd be appreciative. I am also open to using the old method (ManagedBean and ManagedProperty I guess), but I'm not sure if it has the same effect. Thanks!

  • As an update, I think my application has a problem with the @Inject annotation. I implemented the database store from this example https://github.com/eugenp/tutorials/blob/master/java-ee-8-security-api/app-auth-basic-store-db/src/main/java/com/baeldung/javaee/security/DatabaseSetupServlet.java and I am getting this error on the injected class: I had javax.enterprise.inject.UnsatisfiedResolutionException: Api type [javax.security.enterprise.identitystore.Pbkdf2PasswordHash] is not found with the qualifiers – Radu Cristian Neagoe Jul 19 '20 at 08:13
  • Another update, I have tested https://www.youtube.com/watch?v=mGrDrZ1JZi0 Using CDI with an implementation of an interface injected and it works. However it does not work with these JEE specific interfaces like SecurityContext.. – Radu Cristian Neagoe Jul 19 '20 at 08:54
  • Which TomEE 8 did you download? There are many – Kukeltje Jul 20 '20 at 15:10
  • Hello, I had downloaded this version: TomEE plus 8.0.3 – Radu Cristian Neagoe Jul 21 '20 at 08:33

1 Answers1

0

Time for an answer. It seems like TomEE does not provide an implementation for javaee-web-api. I had to add my own. I have added the Soteria implementation to my lib file https://search.maven.org/classic/#search%7Cga%7C1%7Ca%3A%22javax.security.enterprise%22 Now all seems well (at least the app is running). Good luck!

  • Related? https://stackoverflow.com/questions/53629488/illegalargumentexception-no-handler-can-be-found-for-the-key-javax-security-au – Kukeltje Jul 20 '20 at 15:23
  • Thank you for the link, yes it seems to be related, however I had not found that one in my searches. That would have definitely helped. Ultimately I have emailed the people at Baeldung to ask for help and they told me about the implementation options. I guess if I paid more attention to the tutorial, I would have seen it. Have a good day! – Radu Cristian Neagoe Jul 21 '20 at 08:34