0

I have a interface like this:

public interface GenericWSEndpoint<T1,T2> {

    public void call(String url,String operationName, T1 requestObject, T2 responseObject,long timeout) throws Exception;

}

When I try to define an object with this, it gives

org.apache.maven.BuildFailureException: Compilation failure : incompatible types

Object definition:

private static GenericWSEndpoint<BulkCheckBlockageRequest,BulkCheckBlockageResponse> endpoint=GenericWsEndpointFactory.createSpecificEndpoint(WSTypes.CXF);

And factory code:

public class GenericWsEndpointFactory{

    public static <T1,T2> GenericWSEndpoint createSpecificEndpoint(WSTypes type){
        switch (type) {
        case CXF:

            return new CXFWsEndPoint<T1,T2>();
        }

        return null;
    }

}

and the CXFWsEndPoint(no constructors defined specificly):

public class CXFWsEndPoint<T1,T2> implements GenericWSEndpoint<T1, T2>{
.
.
}

I have checked the answers about this problem but they are related with definitions like recursive generics

Any ideas?

EDIT: Exception:

[INFO] Compilation failure ResponseManager\src\main\java\com\x\resman\util\WebServiceUtil.java:[57,142] incompatible types; no instance(s) of type variable(s) T1,T2 exist so that com.x.rbm.ws.service.GenericWSEndpoint conforms to com.x.rbm.ws.service.GenericWSEndpoint found : com.x.rbm.ws.service.GenericWSEndpoint required:

com.x.rbm.ws.service.GenericWSEndpointequest,com.x.resman.model.checkblockage.BulkCheckBlockageResponse>

4
  • Is there any more information on the exception? Commented Jul 8, 2013 at 8:24
  • This interface is fine. Error must be some where else Commented Jul 8, 2013 at 8:29
  • Check your right-hand side type, of what type is GenericWsEndpointFactory.createSpecificEndpoint(WSTypes.CXF); ? Commented Jul 8, 2013 at 8:31
  • Show us the CXFWsEndPoint declaration Commented Jul 8, 2013 at 8:43

2 Answers 2

2

Try with the following code:

  public static <T1, T2> GenericWSEndpoint<T1, T2> createSpecificEndpoint() {

instead of

  public static <T1, T2> GenericWSEndpoint createSpecificEndpoint() {
Sign up to request clarification or add additional context in comments.

4 Comments

Which IDE are you using (if any) ?
You should get a warning on that line for this kind of problem (maybe it is an optional one).
yes but it should not be a warning if it is gonna give a compiler error.
Maybe Eclipse is badly configured and should show it as an error (can be configured). Let me know if you figure this out.
0

Are you specifying the Java source version in your Maven POM file? Currently, by default Maven uses 1.5. You probably need something more recent. What version are you using in our IDE?

The relevant Maven configuration is:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
</plugin>

Hope this helps.

1 Comment

I have 1.6 version in maven and it is compatible with generics. It is not a maven problem also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.