Posts

WARN - enoent ENOENT: no such file or directory, open Nodejs

This happened to me when i was trying to install express using NPM. and i did the below and the warning went away global package --> running  npm -g uninstall <package> ; npm -g install <package> This basically does a clean uninstall and a clean install.

The matching wildcard is strict, but no declaration can be found for element 'jaxrs:client'.

The Answer is in the Migration Guide 3.0 Migration Guide JAX-RS JAX-RS 2.0 has been completely implemented. JAX-RS WADL auto-generation code has been moved to a new cxf-rt-rs-service-description module. JAX-RS 2.0 Client API and CXF specific WebClient and Proxy client code is now available in a new cxf-rt-rs-client module. Important: the namespace for jaxrs:client elements has changed from "http://cxf.apache.org/jaxrs" to "http://cxf.apache.org/jaxrs-client " CXF RequestHandler and ResponseHandler filters have been removed, please use JAX-RS 2.0 ContainerRequestFilter and ContainerResponseFilter and also WriterInterceptor and ReaderInterceptor when needed. CXF JAX-RS Form extension has been dropped, please use JAX-RS 2.0 Form. CXF JAX-RS ParameterHandler has been dropped, please use JAX-RS 2.0 ParamConverterProvider. javax.annotation.Resource annotation can no longer be used to annotate JAX-RS context properties. Only javax.ws.rs.core.Context annotat...

Generating a Self Signed Certificate and Keystore And TrustStore

keytool -genkey -alias mykey -keyalg RSA -keysize 2048 -sigalg SHA256withRSA -validity 365 -keypass password-keystore Keystore.jks -storepass password keytool  -export -alias mykey -file root.cer -keystore Keystore.jks -storepass password keytool -import -alias mykey -file root.cer -keystore Trustore.jks -storepass password

RSA Assymmetric Key Encryption

In addition to the standard X509 *.cer certificates there are also certificate files ending with *.PFX or *.P12. The later ones are X509 certs as well, but may in addition contain a private key, too.   PFX was a Microsoft extension, while P12 was the Netscape one. Generating from Scratch using OpenSSL 1. Generate a 2048-bit RSA private key $ openssl genrsa -out private_key.pem 2048 This will generate a key file in traditional key format also called ssLeay private key format. 2. Convert private Key to PKCS#8 format (so Java can read it) $ openssl pkcs8 -topk8 -inform PEM -outform DER -in private_key.pem -out private_key.der -nocrypt 3. Output public key portion in DER format (so Java can read it) $ openssl rsa -in private_key.pem -pubout -outform DER -out public_key.der Generating from the .p12 File Private key: openssl pkcs12 -in   yourP12File.pfx   -nocerts -out   privateKey.pem This will generate the private key alone...

java.security.spec.InvalidKeySpecException: Only RSAPrivate(Crt)KeySpec and PKCS8EncodedKeySpec supported for RSA private keys

public PrivateKey getPrivateKey(String fileName) throws IOException, InvalidKeySpecException, NoSuchAlgorithmException { byte[] keyFileBytes = readKeyFile(fileName); X509EncodedKeySpec spec = new X509EncodedKeySpec(keyFileBytes); KeyFactory kf = KeyFactory.getInstance("RSA"); return kf.generatePrivate(spec); } The reason is this line, This is used to read public key spec and not private key. The private key is read via PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec ( keyBytes ); So as the error says it needs to be in PKCS8 spec format for java to understand.

java.lang.annotation.IncompleteAnnotationException: javax.xml.bind.annotation.XmlSchemaType missing element name

Hi The use case happened when i was trying to generate the java files from the wsdl using the CXF codegen maven plugin. The generated code  started failing with the above exception when tried to invoke via Eclipse. Note : the same wsdl worked in Soap UI. The generated code in SOAP UI using the WSIMPORT tool also worked. So the issue i figures out is related to the Jaxb in the project. So what i did is upgraded the Jaxb to this version                  <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.2</version> </dependency> It all started working. So this has something to do with the internal element generation of Jaxb and what happens is when a latest version is not found falls back to the jaxb version embedded in SDK leading to that error. Now i dont have a proof for that just an educated guess. :)

Field or property 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - Spring Batch

This Error happens when you are trying to retrieve a Job Execution parameter and inject it into a Bean. The bean can be anything a Task let, or a StatmentSetter the error can happen. E.g Implementation <bean id = "flatFileItemReader" scope="step" class="org.springframework.batch.item.file.FlatFileItemReader"> <property name = "resource" value = "#{jobParameters[input.file.name]}" /> </bean> The error is because of the Scope parameter missing Using a scope of  Step  is required in order to use late binding since the bean cannot actually be instantiated until the  Step  starts, which allows the attributes to be found. Because it is not part of the Spring container by default, the scope must be added explicitly. Check out the Documentation here ..  http://docs.spring.io/spring-batch/reference/html/configureStep.html#step-scope