简体   繁体   中英

Can't deploy *.war to Glassfish 4

I have an Bean interface, AbstractBean (implements Bean) and SpecificBean (extends AbstractBean). I want to inject SpecificBean by following code snippet:

@Stateless
@Specific
public class SpecificBean extends AbstractBean {..}

@Path("resource")
public class Service {
    @Inject
    @Specific
    private Bean bean;
}

When I trying to deploy this to glassfish, I see next error:

An error has occurred Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [IterableProvider>] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 2 of [BackedAnnotatedConstructor] @Inject org.glassfish.jersey.internal.inject.JerseyClassAnalyzer(@Named ClassAnalyzer, IterableProvider>)].

If delete all annotations (expected @Path) application deploys without any errors.

从 maven pom.xml 中的依赖项列表中删除了 jersey(jersey 已经包含在 glassfish 4 中),现在部署正常。

I found this questions with similar problem and just want to add my "2 cents". In my case, I was using Jersey 2.0 with Jackson in order to transform JSON to objects and object to JSON from my rest interfaces. This means that I had to register JacksonFeature on ResourceConfig like this:

import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.message.GZipEncoder;
import org.glassfish.jersey.server.ResourceConfig;

public class JacksonRestConfiguration extends ResourceConfig {

public JacksonRestConfiguration() {
    register( new GZipEncoder() );
    register( JacksonFeature.class );
}

I also disabled Moxy on my Application extension:

import org.glassfish.jersey.CommonProperties;

@ApplicationPath("services")
public class RestApplication extends Application implements Feature {

    public boolean configure( final FeatureContext context ) {
        String postfix = '.' + context.getConfiguration().getRuntimeType().name().toLowerCase();
        context.property( CommonProperties.MOXY_JSON_FEATURE_DISABLE + postfix, true );    
        return true;
    }
}

Both classes above required me to keep jersey as provided in my pom.xml in order to generate the war file correctly:

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>2.13</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>2.13</version>
        <scope>provided</scope>
    </dependency>

Here are some steps which helped me to solve this problem:

  1. Open a command window (preferably as an administrator). Click on Start -> type cmd and press ENTER.

  2. Go to the path where you have install GlassFish, for example: C:\\AppServers\\glassfish5\\glassfish\\bin.

    Run these commands:

     asadmin start-domain asadmin set configs.config.server-config.cdi-service.enable-implicit-cdi=false
  3. Restart GlassFish and try to deploy you application.

Thanks to Stuart Mcculloch for the support on this forum: https://www.eclipse.org/forums/index.php?t=msg&th=490794&goto=1068764&#msg_1068764

Exception Occurred :Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Injector with qualifiers @Default

Solve problem to deploy de aplicacion en GlassFish

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM