Category: Programming Language
-
Java + HTTPS: Unable to Find Valid Certification Path to Requested Target
PROBLEM When trying to invoke HTTPS-based web service (ex: https://server:1234/myapp/web-service), the following exceptions occurred:- SOLUTION I do not want to take any credits away from @mkyong, but this author wrote a great solution to this problem at http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/ . Kudos to him. The only thing I want to point out here is the link to Read More…
-
Maven: Deploying Java Sources to Nexus
By default, mvn deploy will only package and deploy class JAR to Nexus. To deploy the source code too, we need to add the following plugin into pom.xml:- Now, mvn deploy will deploy both class JAR and source code JAR to Nexus:- In IntelliJ, when jumping into a class from the JAR, we are given Read More…
-
Maven JAR Plugin: Excluding Package(s) from JAR
Let’s assume we want to exclude com.choonchernlim.epicapp.scratch package when we create the JAR file. Add the following in pom.xml:- The key here is to specify the execution ID called default-jar. Read More…
-
Spring Security: Handling 403 Error Page
If you are already using Spring, then you might want to use Spring Security to secure your web resources. To do that, we specify the URI to be secured with <security:intercept-url/> tag:- When users without role ROLE_TOPSECRET access /top-secrets/kfc-secret, they will see this default error page:- This proves that Spring Security is doing its job. Read More…
-
Spring: Set Active Profile Using Existing JNDI
If we are using @Profile, Spring allows us select the active profile by using spring.profiles.active key. Although I can hardcode the active profile in web.xml, I want my active profile to be determined based on a JNDI string defined in the application server. PROBLEM My application servers (DEV, QA and PROD) have an existing JNDI Read More…
-
Spring Web Services: Client Integration Testing with MockWebServiceServer
Spring Web Services provides a great way to perform web service client integration tests. However, the example in the documentation requires the client class to extend org.springframework.ws.client.core.support.WebServiceGatewaySupport, which is rather ugly. Instead, I prefer to have WebServiceTemplate injected into my client class. So, I made a slight tweak to my integration test to work this Read More…