If your Nexus repository uses certificates signed by your own Root CA, chances are that a JDK doesn't trust them.
Then when you run
mvn package
you get
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target
Go to your JAVA_HOME\jre\lib\security folder, where the cacerts file is located, and issue
keytool -list -v -keystore cacerts
enter "changeit" as password
this shold tell you all your trusted CAs
You should import your own CA certificate to into this keystore.
I have tried also setting:
set MAVEN_OPTS="-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true"
but it disn't work for me.
Monday, May 6, 2019
Panache as a wrapper for Hibernate
https://quarkus.io/guides/hibernate-orm-panache-guide
https://developers.redhat.com/courses/quarkus/effective-data-hibernate-and-panache-quarkus/
The product seems very well conceived, it really streamlines your JPA code.
One more aspect where the Java world has completely screwed up, is the 20 different ways you can implement DB queries....
ah if only ORM had been embedded into the language from the beginning, we would be dealing with a single persistence framework.
https://developers.redhat.com/courses/quarkus/effective-data-hibernate-and-panache-quarkus/
The product seems very well conceived, it really streamlines your JPA code.
One more aspect where the Java world has completely screwed up, is the 20 different ways you can implement DB queries....
ah if only ORM had been embedded into the language from the beginning, we would be dealing with a single persistence framework.
Thursday, May 2, 2019
Enabling Swagger in a Java EE application
This should be enough:
0) add Maven dependencies:
com.wordnik:swagger-jaxrs_2.10:1.3.1
1) with an Application, register the Swagger jaxrs resources:
2) register the Swagger configuration:
3) then you can annotare your services methods:
0) add Maven dependencies:
com.wordnik:swagger-jaxrs_2.10:1.3.1
1) with an Application, register the Swagger jaxrs resources:
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/rest")
public class JaxRsActivator extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new java.util.HashSet<>();
resources.add(com.wordnik.swagger.jaxrs.listing.ApiListingResource.class);
resources.add(com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider.class);
resources.add(com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON.class);
resources.add(com.wordnik.swagger.jaxrs.listing.ResourceListingProvider.class);
// resources.add(BearerTokenFilter.class);
addRestResourceClasses(resources);
return resources;
}
private void addRestResourceClasses(Set<Class<?>> resources) {
resources.add(BlaService.class);
resources.add(MumbleService.class);
}
}
2) register the Swagger configuration:
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import com.wordnik.swagger.config.ConfigFactory;
import com.wordnik.swagger.config.ScannerFactory;
import com.wordnik.swagger.config.SwaggerConfig;
import com.wordnik.swagger.jaxrs.config.DefaultJaxrsScanner;
import com.wordnik.swagger.jaxrs.reader.DefaultJaxrsApiReader;
import com.wordnik.swagger.reader.ClassReaders;
@WebServlet(name = "SwaggerJaxrsConfig", loadOnStartup = 1)
public class SwaggerJaxrsConfig extends HttpServlet {
@Override
public void init(ServletConfig servletConfig) {
try {
super.init(servletConfig);
SwaggerConfig swaggerConfig = new SwaggerConfig();
ConfigFactory.setConfig(swaggerConfig);
swaggerConfig.setBasePath("/rest");
swaggerConfig.setApiVersion("2.1");
ScannerFactory.setScanner(new DefaultJaxrsScanner());
ClassReaders.setReader(new DefaultJaxrsApiReader());
} catch (ServletException e) {
System.out.println(e.getMessage());
}
}
}
3) then you can annotare your services methods:
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
@Path("/pippo")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Api(value = "/pippo", description = "REST service end-points exposed to Pippo")
public class PippoService {
@GET
@Path("/profiles")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "All Pippos", notes = "List all Pippos")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error, check log files") })
public List listPippobyQuery(
@ApiParam(value = "the hostname where Pippo resides") @QueryParam("hostname") String hostName) {
return listPippo(hostName);
}
}
Subscribe to:
Posts (Atom)