title: @Inject not working in AttributeConverter
body: <p>I have a simple <code>AttributeConverter</code> implementation in which I try to inject an object which have to provide the conversion logic, but <code>@Inject</code> seem not to work for this case. The converter class looks like this:</p>
  
  <pre><code>@Converter(autoApply=false)
  public class String2ByteArrayConverter implements AttributeConverter&lt;String, byte[]&gt;
  {
      @Inject
      private Crypto crypto;
  
      @Override
      public byte[] convertToDatabaseColumn(String usrReadable) 
      {
          return crypto.pg_encrypt(usrReadable);
      }
  
      @Override
      public String convertToEntityAttribute(byte[] dbType)
      {
          return crypto.pg_decrypt(dbType);
      }
  }
  </code></pre>
  
  <p>When the <code>@Converter</code> is triggered it throws an <code>NullPointerException</code> because the property <code>crypto</code> is not being initialized from the container. Why is that? </p>
  
  <p>I'm using Glassfish 4 and in all other cases <code>@Inject</code> works just fine.</p>
  
  <p>Is it not possible to use CDI on converters?</p>
  
  <p>Any help will be appreciated :)</p>
  
  <hr>
  
  <p>The accent of my question is more the AttributeConverter part. I understand that for the CDI to work a bean must meet the conditions described here <a href="http://docs.oracle.com/javaee/6/tutorial/doc/gjfzi.html" rel="noreferrer">http://docs.oracle.com/javaee/6/tutorial/doc/gjfzi.html</a>.
  I also have tried to force the CDI to work by implementing the following constructor:</p>
  
  <pre><code>@Inject
  public String2ByteArrayConverter(Crypto crypto) 
  {
      this.crypto = crypto;
  }
  </code></pre>
  
  <p>And now I got the following exception which doesn't give me any clue:</p>
  
  <pre><code>2015-07-23T01:03:24.835+0200|Severe: Exception during life cycle processing
  org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
  Exception Description: Deployment of PersistenceUnit [PU_VMA] failed. Close all factories for this PersistenceUnit.
  Internal Exception: Exception [EclipseLink-7172] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
  Exception Description: Error encountered when instantiating the class [class model.converter.String2ByteArrayConverter].
  Internal Exception: java.lang.InstantiationException: model.converter.String2ByteArrayConverter
  at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:820)
  at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:760)
  ...
  </code></pre>
  
  <p>I even tried using @Producer or @Decorator in order to have the CDI working on that place, but I still think there is something specific with the AttributeConverter which doesn't allow CDI. So problem not solved yet.</p>