xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Git error after Mac OS upgrade

After upgrading from macOS Sierra to macOS High Sierra, I tried to run git from the terminal but it kept giving me the following error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

After some research, I found that I need to install xcode

Open Terminal, and run the following:

xcode-select --install

This fix the problem for me. If it still didn’t (as some users reported on a thread, you can try to run the following SUDO command

sudo xcodebuild -license

You should be get going now.

Unbound classpath container in Eclipse

The Problem:
============
I have checked out a project using Subversive for Eclipse and I am getting the following errors:
The project cannot be built until build path errors are resolved Unbound classpath container: ‘JRE System Library[jdk1.6.0_22]’

The Solution:
=============
Go to Eclipse -> Preferences, under Java select “Installed JREs” and check one of the boxes to specify a default JRE. Click OK and then go back to your project’s properties. Go to the “Java Build Path” section and choose the “Libraries” tab. Remove the unbound System Default library, then click the “Add Library” button. Select “JRE System Library” and you should be good to go!

Some common java problem in eclipse,ant or hibernate

There are few things which we have faced in last few days. I am finding myself short of time in writing the description as such. So I am just mentioning the subject of the error and some useful link which, if didn’t give you solution, can help you in reaching to the solution.

1)      Ant build problem in eclipse

[javac] BUILD FAILED: file:D:/JavaProject/ACS/testAnt.xml:18: Unable to find a javac compiler;

Link: http://forums.sun.com/thread.jspa?threadID=440539&messageID=2519548

2)      Error: no ‘server’ JVM at ‘C:\Program Files\Java\jre1.5.0_06\bin\server\jvm.dll’.

Link:  http://forums.sun.com/thread.jspa?threadID=735764

3)      Debugging Tools and Techniques – Source not found error in Eclipse

Source not found

Link: http://forums.sun.com/thread.jspa?threadID=5114255

4)      Hibernate and Eclipse Integration

Link: http://community.jboss.org/wiki/HibernateandEclipseIntegration

A scenario when ‘Brake’ and ‘Continue’ work equally

If you put a switch-case block inside a while loop, both brake and continue will work and the output will be same. E.g.

Int i=0;

while (i<6){

switch (i){

case 1:

system.out.println(“Inside case 1”);

i++;

continue;

case 2:

system.out.println(“Inside case 2”);

i++;

brake;

case 3:

system.out.println(“Inside case 3”);

i++;

continue;

case 4:

system.out.println(“Inside case 4”);

i++;

brake;

default:

system.out.println(“Inside Default”);

}

}

Any comments?

How to put logger in java?

One of the most important things in java is to put a logger. Very simple process for those who know how to do it but for the new users of java, it a bit tricky, as I have observed when working with some of fresher’s in my organization. This post is for them only or even some time for those who do occasional development of new product. In those cases as well I see people forget how we have done it in last project. So we’ll do it step wise.

Step 1: You need to import log4j-1.2.14.jar file in your libraries. Don’t ask me where you can find it. If it’s not on your machine, then search Google.

Step 2: put a log4j.properties file along with your other properties file. If you don’t have one, you can put it in your ‘src’ folder. The content of the properties file should be

# For the general syntax of property based configuration files see the

# documenation of org.apache.log4j.PropertyConfigurator.

log4j.rootLogger=DEBUG, FILE, CONSOLE

#log4j.appender.ROOT.File=C:/Program Files/Apache Software Foundation/Apache Tomcat 6.0.14/logs/ProfileServices.log

log4j.appender.FILE=org.apache.log4j.FileAppender

log4j.appender.FILE.file=/idm/bea/logs/ProfileServices.log

log4j.appender.FILE.layout=org.apache.log4j.PatternLayout

log4j.appender.FILE.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] %-5p (%F:%L) – %m%n

log4j.appender.FILE.append=false

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout

log4j.appender.CONSOLE.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] %-5p (%F:%L) – %m%n

 

This file can be modified according to your requirement. You can add or delete the content you want to.

Step 3:  In you java file, where you want to put the logger, import log4j.Logger in your import section, as shown below

Import  org.apache.log4j.Logger;

Step 4: In the variable deceleration section of your class, decelare the logger as shown below

private static Logger logger = Logger.getLogger(className.class);

Note:  *className = Name of your class in which you are using this logger.

Step 5:  And you are done with all the base preparation. All you have to do now is to just use logger in your code as shown below in example

try {

                userProfileAL = ldapSerachBO.getUserProfiles(userName, url, baseDN);

                userProfile = new UserProfileData[userProfileAL.size()];

                logger.debug(“LdapSearchServiceImpl:getUserProfile userProfileAL Size ” + userProfileAL.size());

                for (int i = 0; i < userProfileAL.size(); i++) {

                                userProfile[i] = (UserProfileData) userProfileAL.get(i);

                                logger.debug(“LdapSearchServiceImpl:getUserProfile getKey()>” + userProfile[i].getKey());

                                logger.debug(“LdapSearchServiceImpl:getUserProfile getValue()>” + userProfile[i].getValue());

                }

 

You can use logger for debug as shown above in the example or for error or for info whatever your requirement is.

Just drop me a message if you want to know anything else in this.

 

–Vikas

java.security.InvalidKeyException: Public key presented not for certificate signature

After resolving the below mention problem, I start getting the exception given below.

Exception : [ERROR] Exception at line 122, column 68 of oxf:/ops/pfc/xforms-epilogue.xpl (re

ading processor output: name=’document’, id=’xhtml-data’)

java.security.InvalidKeyException: Public key presented not for certificate sign

ature

        at org.bouncycastle.jce.provider.X509CertificateObject.checkSignature(Un

known Source)

        at org.bouncycastle.jce.provider.X509CertificateObject.verify(Unknown So

urce)

        at javax.crypto.SunJCE_b.d(DashoA12275)

        at javax.crypto.SunJCE_b.c(DashoA12275)

        at javax.crypto.SunJCE_r.run(DashoA12275)

        at java.security.AccessController.doPrivileged(Native Method)

        at javax.crypto.SunJCE_b.<clinit>(DashoA12275)

        at javax.crypto.Cipher.getInstance(DashoA12275)

        at org.orbeon.oxf.util.SecureUtils.encrypt(SecureUtils.java:135)

        at org.orbeon.oxf.xforms.XFormsUtils.encodeBytes(XFormsUtils.java:184)

        at org.orbeon.oxf.xforms.XFormsUtils.encodeXML(XFormsUtils.java:157)

        at org.orbeon.oxf.xforms.XFormsStaticState.getEncodedStaticState(XFormsS

taticState.java:220)

The resolution to this problem was probably the last nail in the coffin of my problems which I was facing since last 13-14 days. I have found the resolution on this link. Though you can find the steps of resolution of this problem on the link (And infect they are original) I am writing them again (copying infect) in case this link stop working tomorrow.

1. Suppose you are using jdk15. Go to http://java.sun.com/javase/downloads/index_jdk5.jsp

2. Go to the Other Downloads section and click on download link next to “Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 5.0”

3. Download jce_policy-1_5_0.zip and extract it in to a directory.

4. You will find local_policy.jar and US_export_policy.jar files there in the extracted directory. Copy these two files to $JAVA_HOME/jre/lib/security directory. (These files will already be there. you may replace them)

5. Restart WSO2 WSAS and invoke your secured service again. You will not encounter the “invalidkeyException” any more.

I would like to say thanks to Charitha to help me out in resolving this issue in the same way as Yuvi is doing to Kumar Sangakara and M. Jaya to help him in winning a match or two for KIP.

No class def found error at java.lang.NoClassDefFoundError: javax/crypto/SunJCE_b:

Exception – InitUtils.runProcessor(110) | Exception at line 122, column 68 of oxf:/o

ps/pfc/xforms-epilogue.xpl (reading processor output: name=’document’, id=’xhtml

-data’)

java.lang.NoClassDefFoundError: javax/crypto/SunJCE_b

        at javax.crypto.Cipher.getInstance(DashoA12275)

        at org.orbeon.oxf.util.SecureUtils.encrypt(SecureUtils.java:135)

        at org.orbeon.oxf.xforms.XFormsUtils.encodeBytes(XFormsUtils.java:184)

        at org.orbeon.oxf.xforms.XFormsUtils.encodeXML(XFormsUtils.java:157)

        at org.orbeon.oxf.xforms.XFormsStaticState.getEncodedStaticState(XFormsS

taticState.java:220)

        at org.orbeon.oxf.xforms.processor.XFormsToXHTML.createCacheContainingDo

cument(XFormsToXHTML.java:328)

        at org.orbeon.oxf.xforms.processor.XFormsToXHTML.access$200(XFormsToXHTM

L.java:51)

The solution for this problem was quit tricky and taken out a hell out of us. While trying to up WSI along with ODE and Axis2 on WL, whenever we start WSI before rest of the services, it was working fine. But when we started or used WSI after other two services, we were getting this exception. Thanks to efforts of Sri, that in the end we come through to this.

Solution: Put bcprov-jdk15-143.jar in bea\jdk150_12\jre\lib\ext folder. This jar can be downloaded from http://www.bouncycastle.org/latest_releases.html. Also put the line ‘security.provider.2=org.bouncycastle.jce.provider.BouncyCastleProvider’ in bea\jdk150_12\jre\lib\security\java.security. Make sure this line is at number two only. Change the sequence of others.

Important Links:

1) http://mail-archives.apache.org/mod_mbox/ws-axis-user/200606.mbox/<OF2E2E121C.A4B12874-ON85257184.00457BAE-85257184.00461B2C@mro.com>

2) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6567947

3) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6647104

ODE Qname NameSpace Exception

After resolving previously mentioned issue, something more interesting was waiting for me on the way to my journey to deploy ODE on weblogic. Here is a small stack trace for the same.

 java.rmi.ServerException: RemoteException occurred in server thread; nested exce

ption is:

        java.rmi.UnmarshalException: error unmarshalling arguments; nested excep

tion is:

        java.io.InvalidClassException: javax.xml.namespace.QName; local class in

compatible: stream classdesc serialVersionUID = 4418622981026545151, local class

 serialVersionUID = -711357515002332258

 This issue was reported as a bug with java and you can check its description and some more information about it at this link. Below are some of the solutions which are given at above mentioned link.

 Submitted On 04-MAY-2007
chris-j-01

I had the same problem as the last person who submitted
On 08-MAR-2007. I was using 1.5.0_10 with weblogic 9.2.
I downgraded to 1.5.0_06 and it works.

Submitted On 22-JUN-2007
mdepot

Look into adding the following option to java as a workaround for this issue:
 
-Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0
 

Submitted On 24-JUL-2008
Titto 
Even I solved this error by pointing the jdk for weblogic to
BEA JRockit(R) JDK 5.0 Update 4 (R26.0.0-189_CR269406)

 I have tried almost all of them but nothing has worked for yours truly. Workaround ‘-Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0’ has been suggested by many of other links and I’ll suggest you to use this solution first. Below are some of the links I have gone through during my voyage of resolving this issue.

 http://mattfleming.com/node/264

http://jira.codehaus.org/browse/MOJO-1223

http://objectmix.com/weblogic/519553-javax-xml-namespace-qname-incompatible-4.html

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267224

 http://forums.terracotta.org/forums/posts/list/204.page

 Some of these links can prove beneficial for you if you are struggling with this kind of exception.

 Solution: The solution which worked for us can’t be suggested at first go. But we were not able to move forward and the delivery deadlines were about to crush us, we were left with no more RnD time and have implemented it. And the solution is to change QName.class in stax-api-1.0.1.jar in ODE libs with one in C:\bea\jdk150_12\jre\lib\rt.jar. Ummm, the solution looks tricky but it is just like that.