0

I have problem with dependency injection from another .jar module. When I try to inject services from that project, I get error

WELD-001408: Unsatisfied dependencies for type MyService with qualifiers @Default at injection point [BackedAnnotatedField] @Inject private smilecounter.app.windows.MainWindow.service at smilecounter.app.windows.MainWindow.service(MainWindow.java:0)

I have class:

@Singleton
public class MainWindow extends JFrame{
   @Inject private MyService service;
   ...
}

that is injecting MyService defined like this:

@ApplicationScoped
@Singleton
public class MyService{...}

In my desktop application module (Java SE) I've added to pom:

 <!-- CDI -->
 <dependency>
     <groupId>org.jboss.weld.se</groupId>
     <artifactId>weld-se</artifactId>
     <version>${cdi.version}</version>
 </dependency>

while in my services module, I've added:

    <!-- CDI -->
    <dependency>
        <groupId>org.jboss.weld.se</groupId>
        <artifactId>weld-se</artifactId>
        <version>${cdi.version}</version>
    </dependency>
    <!-- JAX-RS -->
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>${jaxrs.version}</version>
    </dependency>
    <!-- RESTEASY -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>${javaee.api.version}</version>
        <scope>provided</scope>
    </dependency>

since those services are using also RESTeasy services.

Is there any way to inject those services in my desktop module without creating proxies that are setting manually dependencies?


EDIT

As requested in comment section, I'm posting my dependency from desktop to core-services:

    <dependency>
        <groupId>myApp</groupId>
        <artifactId>myApp.services</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
deem
  • 1,252
  • 1
  • 19
  • 38
  • Have you declared a dependency on the other jar? – Software Engineer Jul 03 '16 at 23:57
  • What do you mean? I have in `desktop app` pom added entry "depend on core services", do you mean the other way? – deem Jul 04 '16 at 05:55
  • No, but can you show that dependency in your question? – Software Engineer Jul 07 '16 at 12:07
  • @EngineerDollery, done, sir. – deem Jul 07 '16 at 15:18
  • Ok, so what you want to do is odd, given your use of JEE technologies -- which are, more or less, all server side and designed to run in a container. You'd have been better advised to use spring throughout -- it's a /lot/ more popular and would more easily meet your actual requirements. – Software Engineer Jul 08 '16 at 16:48
  • But your actual error is that you appear to have unsatisfied dependencies for 'myApp.services'. If you look in the POM for that module, does it have any system or provided dependencies? If so, this is probably what's breaking things for you, as both scopes are usually considered more or less totally evil. – Software Engineer Jul 08 '16 at 16:50

0 Answers0