MyArchiBook

Unsatisfied Dependency Exception : CDI 1.1 + Bean Validation + GlassFish 4.0 -> requires jersey-gf-cdi.jar upgrade

with one comment

Recently,  I faced Unsatisfied Dependency Exception, when trying to integrate BeanValidation with CDI 1.1 . Independently (without integration) everything worked fine. Looks like, the present Glassfish version 4.0 doesn’t support CDI 1.1 + Bean Validation together.

To be still clearer, Jersey (reference implementation for JAX-RS)  jar related to CDI  i.e., jersey-gf-cdi.jar in GF-4.0 version, is not supporting this integration .

I made the below changes, for Bean Validation integration with CDI 1.1 in Glassfish 4.0 to work.

Applicaiton Server used : Glassfish 4.0

Technology : JEE-7, CDI 1.1

Exception Trace :

org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=Foo,parent=Foo,qualifiers={@foo()}),position=-1,optional=false,self=false,unqualified=null,350112977)

at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:74)
at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:771)
at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:790)
at org.glassfish.jersey.gf.cdi.CdiComponentProvider$1.inject(CdiComponentProvider.java:316)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:158)
at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:69)

………………………….

Solution :

  • Download jersey-gf-cdi-2.0.jar . Download specifically 2.0 version for glassfish4.0. If other higher versions 2.10 are used, incompatibilty with other jars (firstly with jersey-server.jar) will arise.

http://repo1.maven.org/maven2/org/glassfish/jersey/containers/glassfish/jersey-gf-cdi/2.0/jersey-gf-cdi-2.0.jar

  • Rename the jar to jersey-gf-cdi.jar
  • Replace it in glassfish4.0/glassfish/modules/
  • Delete osgi-cache folder -> Path : glassfish4.0/glassfish/domains/domain1/osgi-cache
  • Refresh and restart glassfish. New osgi-cache will be created in domain 1 with the latest jersey-gf-cdi.jar. Problem will be solved 🙂

This issue will be resolved in Glassfish-4.0.1 version (not released yet). We’ll have to do the above till GF-4.0.1 is released.

Have a great day 🙂

Reference :
https://java.net/jira/browse/GLASSFISH-20597

Advertisements

One Response

Subscribe to comments with RSS.

  1. Glassfish has never worked out of the box for me. I got the same error and was wondering what was the missing dependency.
    U r blogs on java stack are worth a read.

    Satyaprakash

    June 17, 2015 at 10:23 PM


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: