NoEndPointException with direct instantiation but not with Autowired

28 Views Asked by At

I have a Java class in my Spring Boot application that autowires ScheduleFacadeBindingStub as follows:

@Autowired private ScheduleFacadeBindingStub scheduleFacadeBindingStub;

This is then used in a method:

schedule = scheduleFacadeBindingStub.getSchedule(request);

I want to change this to use a new instance of ScheduleFacadeBindingStub for each call so I removed @Autowired private ScheduleFacadeBindingStub scheduleFacadeBindingStub; and now have this in my method:

ScheduleFacadeBindingStub scheduleFacadeBindingStub= new ScheduleFacadeBindingStub ();
schedule = scheduleFacadeBindingStub.getSchedule(request);

Unfortunately when I run my application with this I get:

ERROR p.t.m.c.integration.ScheduleClient – Unable to retrieve schedule org.apache.axis.NoEndPointException: No endpoint at ScheduleWSFacade.ScheduleWSFacadeBindingStub.generateSchedule(ScheduleWSFacadeBindingStub.java:703) at path.to.my.application.integration.ScheduleClient.getSchedule(ScheduleClient.java:85) at path.to.my.application.service.ScheduleServiceImpl.getSchedule(ScheduleServiceImpl.java:495) at path.to.my.application.service.ScheduleServiceImpl.getEstimateScheduleFull(ScheduleServiceImpl.java:129) at path.to.my.application.service.ScheduleServiceImpl.lambda$futureComp$2(ScheduleServiceImpl.java:220) at path.to.my.application.concurrent.EstimateSupplier.get(EstimateSupplier.java:33) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1700) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) 07:32:26.114 ERROR [service.name:EstimateCalculator,,,3c9219472f7fd7c8a03708c9974f42d0,1e497688c749dba1,,] [-]-[5506764239]-[5506764239]-[]-[]-[] [ForkJoinPool.commonPool-worker-23] ERROR p.t.m.c.integration.ScheduleClient – Unable to retrieve schedule org.apache.axis.NoEndPointException: No endpoint

I'm trying to understand how autowired can get the endpoint but direct instantiation doesn't. Is there anything I should be doing differently to resolve this?

BTW ScheduleFacadeBindingStub has two constructors. One takes a URL so I assume that's the one Autowired uses but I'm not sure how it knows to use that one.

public ScheduleFacadeBindingStub () throws org.apache.axis.AxisFault {
         this(null);
}

public ScheduleFacadeBindingStub (java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {
     this(service);
     super.cachedEndpoint = endpointURL;
}

When I add the below URL and and service:

URL url = new URL("https://my/url");
Service service = new Service() {
  @Override
  public Remote getPort(QName qName, Class aClass) throws ServiceException {
    return null;
  }

  @Override
  public Remote getPort(Class aClass) throws ServiceException {
    return null;
  }

  @Override
  public Call[] getCalls(QName qName) throws ServiceException {
    return new Call[0];
  }

  @Override
  public Call createCall(QName qName) throws ServiceException {
    return null;
  }

  @Override
  public Call createCall(QName qName, QName qName1) throws ServiceException {
    return null;
  }

  @Override
  public Call createCall(QName qName, String s) throws ServiceException {
    return null;
  }

  @Override
  public Call createCall() throws ServiceException {
    return null;
  }

  @Override
  public QName getServiceName() {
    return null;
  }

  @Override
  public Iterator getPorts() throws ServiceException {
    return null;
  }

  @Override
  public URL getWSDLDocumentLocation() {
    return null;
  }

  @Override
  public TypeMappingRegistry getTypeMappingRegistry() {
    return null;
  }

  @Override
  public HandlerRegistry getHandlerRegistry() {
    return null;
  }
};
ServiceWSFacadeBindingStub serviceFacadeBindingStub = new ServiceWSFacadeBindingStub(url, service);

I get this:

Problems getting Schedule values java.lang.ClassCastException: class path.to.my.application.integration.ScheduleClient$1 cannot be cast to class org.apache.axis.client.Service (path.to.my.application.integration.ScheduleClient$1 is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @442e5474; org.apache.axis.client.Service is in unnamed module of loader 'app') at ScheduleWSFacade.ScheduleWSFacadeBindingStub.(ScheduleWSFacadeBindingStub.java:333) at ScheduleWSFacade.ScheduleWSFacadeBindingStub.(ScheduleWSFacadeBindingStub.java:323) at path.to.my.application.integration.ScheduleClient.getSchedule(ScheduleClient.java:157) at path.to.my.application.service.ScheduleServiceImpl.getSchedule(ScheduleServiceImpl.java:494) at path.to.my.application.service.ScheduleServiceImpl.getEstimateScheduleFull(ScheduleServiceImpl.java:128) at path.to.my.application.service.ScheduleServiceImpl.lambda$futureTpft$3(ScheduleServiceImpl.java:237) at path.to.my.application.concurrent.EstimateSupplier.get(EstimateSupplier.java:33) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1700) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

0

There are 0 best solutions below