I got error, when i called my java service class for creation project in
gitlab using there service url. It's working fine with postman app. But
problem in java. Mycode:-
public static void main(String a[]){
GitLabRSClient gitLabRSClient=new GitLabRSClient();
gitLabRSClient.serviceInvok();
}
private String serviceInvok(){
try {
SslConfigurator sslConfigurator =
SslConfigurator.newInstance().keyStoreType("PRIVATE-TOKEN").trustStorePassword("NDi-gBQrh6Y5T4aGR28z");
SSLContext sslContext = sslConfigurator.createSSLContext();
Client client1 =
ClientBuilder.newBuilder().sslContext(sslContext).build();
String
restURL="https://ec2-59-46-186-29.compute-1.amazonaws.com/api/v4/projects";
log.info("rest url : "+restURL);
WebTarget target1
=client1.target(restURL+"?name=TestJai6&namespace_id=10");
log.info(target1);
Invocation.Builder invocationBuilder =
target1.request(MediaType.APPLICATION_JSON);
Entity<String> entity = Entity.json("");
Response response = invocationBuilder.post(entity);
if (response.getStatus() != 200 && response.getStatus() !=202) {
throw new RuntimeException("Failed : HTTP error code : "+
response.getStatus());
}
String output = response.readEntity(String.class);
log.info("output : "+output);
return output;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Error:- javax.ws.rs.ProcessingException: Already connected at
org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:255) at
org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:667)
at
org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:664)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at
org.glassfish.jersey.internal.Errors.process(Errors.java:297) at
org.glassfish.jersey.internal.Errors.process(Errors.java:228) at
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
at
org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:664)
at
org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:424)
at
org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:333)
at GitLabRSClient.serviceInvok(GitLabRSClient.java:47) at
GitLabRSClient.main(GitLabRSClient.java:34) Caused by:
java.lang.IllegalStateException: Already connected at
sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3013)
at
sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:316)
at
org.glassfish.jersey.client.HttpUrlConnector.setOutboundHeaders(HttpUrlConnector.java:348)
at
org.glassfish.jersey.client.HttpUrlConnector.access$100(HttpUrlConnector.java:87)
at
org.glassfish.jersey.client.HttpUrlConnector$3.getOutputStream(HttpUrlConnector.java:311)
at
org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200)
at
org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:194)
at
org.glassfish.jersey.message.internal.CommittingOutputStream.commit(CommittingOutputStream.java:262)
at
org.glassfish.jersey.message.internal.OutboundMessageContext.commitStream(OutboundMessageContext.java:811)
at
org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:546)
at
org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:315)
at
org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:227)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246)
... 11 more
--
You received this message because you are subscribed to the Google Groups
"GitLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/gitlabhq/2579c173-7d4a-441e-85c7-c862aab7422c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.