Skip to main content

Posts

Resolution for Error: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey

Error: "javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey" I was  trying to implement Hibernate Search functionality on my current project. I faced the above issue and resolved it with some research. Root cause and Solution:   JoinColumn.foreignKey() was introduced with JPA 2.1, which was not implemented by Hibernate 4 until version 4.3. If you're using an older version of Hibernate 4, you will face this issue. Try to upgrade it to hibernate-jpa-2.1-api   and also Hibernate to 4.3.x. If you're already using Hibernate 4.3 then make sure you're also using hibernate-jpa-2.1-api to make sure the API and implementation match up.

Resolved: “org.hibernate.ObjectNotFoundException: No row with the given identifier exists” but it does exists

Error: “org.hibernate.ObjectNotFoundException: No row with the given identifier exists” but it does exists. I was facing this issue with my current project. There might be 2 possible reasons to occur this error. Root Causes: 1. Whene there is relationship between two tables in the database, the main entity may not exists in the database, You can check it with session.get() method whether it is there or not.

If Runnable interface is better than Thread class, then why we are using Thread class?

If Runnable interface is better than Thread class, than why we are using Thread class? What is the need for Thread class? When you  extends Thread class, after that you can’t extend any other class which you needed. (As you know, Java does not allow multiple inheritance.) If your class is Implementing the Runnable interface then you only override the run() .So this instance creates a separate Thread and every individual Thread runs separately but not as a single heavy Thread in your program. Another thing, Since Java does not support multiple inheritance , if you implement the Runnable you'll avoid problems of multiple extending, so if you implement Runnable interface you can extend any class that you are required other than Thread class. However, the main difference is. When you  extends Thread class, each of your thread creates unique object and associate with it. When you  implements Runnable , it shares the same object to multiple threads. ...

How To Solve "Error: Could not find or load main class org.codehaus.classworlds.Launcher while building Maven 3.0.4"

I was trying to solve this error in my Ubuntu. Since I need to build Hue /Spark Application and when run the "make apps" or "mvn --version" command on terminal, I was getting " Error: Could not find or load main class org.codehaus.classworlds.Launcher while building Maven 3.0.4 This error ate all my day almost. Finally found a solution on one website. Just you need to uninstall old maven versions or existing maven. and sudo apt-get purge maven maven2 maven3 sudo apt-add-repository ppa:andrei-pozolotin/maven3 sudo apt-get update sudo apt-get install maven3  Thanks a lot to those guys for a great help.

Solution For Error: " Current configuration of the parser doesn't allow a maxOccurs attribute value to be set greater than the value 5,000."

Currently I am working on a project where I need to transform Excel sheet data to an XML format in compliance with XSD given by my client. When I am trying to parse the XSD using JAXB I got this error when doing mvn clean install. Error: ""Current configuration of the parser doesn't allow a maxOccurs attribute value to be set greater than the value 5,000." I found many solutions and route cause for this issue. You can find some information on Oracle site the route cause for the issue . It is because of the feature enabled for secure XML processing. This feature was enable in JAXP 1.3 which instructs parsers, transformers to behave in a secure fashion. You can find more information here: https://jaxp.java.net/1.4/JAXP-Compatibility.html#JAXP_security. For me 2 solutions worked out: Solution 1: With code change or implemenetation: //Create SchemaFactory using XSD file SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_UR...

How To Change IPAddress of Linux/Ubuntu ?

Recently I needed to change the existing ipaddress of a linux machine. Since we migrated to our machines in to new cloud servers. Just follow the steps defined below: On terminal window type the following command.            sudo vi /etc/network/interfaces                 or             sudo gedit /etc/network/interfaces

Is It Possible To Define All The Methods In An Abstract Class?

It is possible create an abstract class with all concrete methods. But this class can’t be instantiated. Since it is an abstract class.    We may have situations where we don’t want to instantiate a class which is the base class for all the classes in the system or application. This base class may have lot of methods used for different modules in the application and we do not want to instantiate the object of the base class and want to use only the reference of the class.   An abstract class without any abstract methods should be a rare thing and you should always question your application design if this case arises. Normally you should refactor to use a concrete super class in this scenario.   One specific case where abstract class may justifiably have no abstract methods is where it partially implements an interface, with the intention that its subclasses must complete the interface.