Saturday, October 19, 2013
Friday, October 18, 2013
Error - 'Project facet Java version 1.7 is not supported in eclipse'
It can be that java 1.7 is not installed in your system then you can use java version that is already installed in your system.
Following Steps could resolve this error by setting up current version in project facet
Step 1: Right Click over your Project on Project Explorer and click on Properties. Step 2: Goto java build path->Libraries
Check JRE System Library Jars and also check it is JDK 1.6 or 1.7 Step 3:Go to "Project Facet" and select your current java version available.
click apply then ok.
Sunday, October 6, 2013
Hibernate Error: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
save method:- it is used to insert the newly created object in datastore.(Basically identifier value will be 0 for this). Like i create a new customer and call save operation , it will persist it in datastore and generate the identifier.
So calling save again will result in another row in the db.
update method:- it is used to update the already persistent object in datastore.(Basically identifier value will be some non zero value for this). Like i load a new customer and call update operation after update of some field value, it will update it in datastore .As per my understanding it should fail with some exception because as per api update is for detached object.
update updates an object in the session. So if the object
is in the session it will update. If the object is not in the session,
you should call merge. I believe calling update for a detached instance will result in an exception.saveorupdate method:- it will call either of above based on unsaved-value checks. so if we have persistent customer object . Now if we update last name of his and create a new account also, then saveorupdate will take care of it.
Merge method :- it will like update but here if persistent object with the same identifier is already there in session it will update the detached object values in persistent object and save it. Right? But if If there is no persistent instance currently associated with the session, this will load the persistent object from datastore and then update the value of detached object in loaded persistent object and then update it.
above chek again pls
http://stackoverflow.com/questions/7475363/differences-among-save-update-saveorupdate-merge-method-in-session-object
Rather than sing update if we use, merge this can be solved.
How to apply atheme to Struts2 Forms
Sometimes even if we try to align 2 components in UI of struts form, they will not get aligned.For eg: I needed to have two text boxes in one row.So in such a situation I can do below.
For eg: When you use a Struts 2 tag such as s:select in your web page, the Struts 2 framework generates HTML that styles the appearance and controls the layout of the select control. The style and layout is determined by which Struts 2 theme is set for the tag. Struts 2 comes with three built-in themes: simple, xhtml, and css_xhtml. If you don’t specify a theme, then Struts 2 will use the xhtml theme by default.
I can either change struts.xml as below.Then it will apply all pages.
<struts>
<constant name="struts.ui.theme" value="simple" />
......................
</struts>
xhtml layout
The xhtml theme renders out a two-column table. If a different layout is needed, do not write your own HTML. Create a new theme or utilize the simple theme.
If we get the issue of labels of text fields missing we can have like below.
<table>
<tr>
<td><label for="a" class="label" theme="simple">Firstname:</label></td>
<td><s:textfield id="a" name="username" label="Username" size="20" theme="simple"/></td>
<td><label for="b" class="label" theme="simple">LastName:</label></td>
<td><s:textfield id="b" name="lastName" label="lastName" size="20" theme="simple"/></td>
</tr>
<tr><s:submit method="execute" label="login" align="center" /></tr>
</table>
It will show components in one row.
Sometimes even if we try to align 2 components in UI of struts form, they will not get aligned.For eg: I needed to have two text boxes in one row.So in such a situation I can do below.
For eg: When you use a Struts 2 tag such as s:select in your web page, the Struts 2 framework generates HTML that styles the appearance and controls the layout of the select control. The style and layout is determined by which Struts 2 theme is set for the tag. Struts 2 comes with three built-in themes: simple, xhtml, and css_xhtml. If you don’t specify a theme, then Struts 2 will use the xhtml theme by default.
I can either change struts.xml as below.Then it will apply all pages.
<struts>
<constant name="struts.ui.theme" value="simple" />
......................
</struts>
xhtml layout
The xhtml theme renders out a two-column table. If a different layout is needed, do not write your own HTML. Create a new theme or utilize the simple theme.
If we get the issue of labels of text fields missing we can have like below.
<table>
<tr>
<td><label for="a" class="label" theme="simple">Firstname:</label></td>
<td><s:textfield id="a" name="username" label="Username" size="20" theme="simple"/></td>
<td><label for="b" class="label" theme="simple">LastName:</label></td>
<td><s:textfield id="b" name="lastName" label="lastName" size="20" theme="simple"/></td>
</tr>
<tr><s:submit method="execute" label="login" align="center" /></tr>
</table>
It will show components in one row.
How To Handle Multiple Submit Buttons in Struts 2
JSP File:
`
Often, we have multiple submit buttons within a single form. The below is just a simple way of identifying which button was clicked, and which actions to take.
There are, of course, many ways of doing this, including the use of JavaScript to identify the actions, etc... You're welcome to pick and choose whichever method you find most useful. Struts 2 is flexible enough.
In this case, the properties are boolean, therefore the values set would be boolean.
There is another method, using String properties, described below...
I don't really like this method, as it ties in the Action to the Form. (What happens if you want different text to show up on the button ? You would have to change both the form as well as the corresponding action.)
The more elegant solution is probably by using multiple mappings for same Action. This way you don't need to set "struts.enable.DynamicMethodInvocation" to "true".
In JSP
In struts.xml
Then in MyAction class
For best practice, if you have common data loaded / managed by your actions (submit & clear), then for example, you can define a MyBaseAction class, extended by MySubmitAction and MyClearAction class. Then this is how they looks like:
In struts.xml
You don't need to specify a method name anymore, that means we will use the default execute() method.
Then in the MyAction, MySubmitAction and MyClearAction class
JSP File:
<s:form name="inquiryForm" method="post" theme="simple" >
Select roll no :
<s:select style="width: 200px;"
list="#{'1':'Student 01', '2':'Student 02', '3':'Student 03', '4':'Student 04'}"
id="projectName"
name="studentRollNo"
readonly="false"
headerKey="-1"
headerValue="--- Select ---"
/>
<s:submit cssClass="page" action="academics" value="academics" />
<s:submit cssClass="page" name="sports" value="sports" />
<s:submit cssClass="page" name="library" value="library" />
</s:form>
struts.xml:`
<package name="default" extends="struts-default">
<action name="academics" class="ViewAcademics" >
<result name="success">pages/ViewAcademics.jsp</result>
</action>
<action name="sports" class="ViewSports" >
<result name="success">pages/ViewSports.jsp</result>
</action>
<action name="library" class="ViewLibrary" >
<result name="success">pages/ViewLibrary.jsp</result>
</action>
</package>----------------------------------------------------------Often, we have multiple submit buttons within a single form. The below is just a simple way of identifying which button was clicked, and which actions to take.
There are, of course, many ways of doing this, including the use of JavaScript to identify the actions, etc... You're welcome to pick and choose whichever method you find most useful. Struts 2 is flexible enough.
Form
<button type="submit" value="Submit" name="submit"><button type="submit" value="Clear" name="clear"> |
Action with boolean properties
class MyAction extends ActionSupport { private boolean submit; private boolean clear; public void setSubmit(boolean submit) { this.submit = submit; } public void setClear(boolean clear) { this.clear = clear; } public String execute() { if (submit) { doSubmit(); return "submitResult"; } if (clear) { doClear(); return "clearResult"; } return super.execute(); }} |
Explanation
The boolean properties 'submit' and 'clear' will be set to 'true' or 'false' according weather the submit or clear form element is present in the submitted form.In this case, the properties are boolean, therefore the values set would be boolean.
There is another method, using String properties, described below...
Form
<button type="submit" value="Submit" name="buttonName"><button type="submit" value="Clear" name="buttonName"> |
Action with String properties
class MyAction extends ActionSupport { private String buttonName; public void setButtonName(String buttonName) { this.buttonName = buttonName; } public String execute() { if ("Submit".equals(buttonName)) { doSubmit(); return "submitResult"; } if ("Clear".equals(buttonName)) { doClear(); return "clearResult"; } return super.execute(); }} |
Explanation
In this case, the properties are String, therefore the values set are also String in nature.I don't really like this method, as it ties in the Action to the Form. (What happens if you want different text to show up on the button ? You would have to change both the form as well as the corresponding action.)
There are other ways to achieve the same functionality. There are pros and cons to each methods.
The more elegant solution is probably by using multiple mappings for same Action. This way you don't need to set "struts.enable.DynamicMethodInvocation" to "true".
In JSP
<s:form method="post" action="mySubmitAction"> <s:submit value="Submit"/> <s:submit value="Clear" action="myClearAction"/></form> |
<action name="mySubmitAction" class="MyAction" method="submit"> <result>submit.jsp</result></action><action name="myClearAction" class="MyAction" method="clear"> <result>submit.jsp</result></action> |
public String submit() throws Exception { // submit button logic here return SUCCESS;}public String clear() throws Exception { // clear button logic here return SUCCESS;} |
For best practice, if you have common data loaded / managed by your actions (submit & clear), then for example, you can define a MyBaseAction class, extended by MySubmitAction and MyClearAction class. Then this is how they looks like:
In struts.xml
<action name="mySubmitAction" class="MySubmitAction"> <result>submit.jsp</result></action><action name="myClearAction" class="MyClearAction"> <result>submit.jsp</result></action> |
Then in the MyAction, MySubmitAction and MyClearAction class
MyAction.java
public class MyAction extends ActionSupport { // common data or logic here} |
MySubmitAction.java
public class MySubmitAction extends MyAction { public String execute() throws Exception { // submit button logic here return SUCCESS; }} |
MyClearAction.java
public class MyClearAction extends MyAction { public String execute() throws Exception { // clear button logic here return SUCCESS; }}
How to redirect to another action within Struts.xml file - Struts2
<action name="contact-form"
class="net.viralpatel.contact.view.ContactAction" method="search">
<result name="success" type="tiles">/contactCrud.tiles</result>
</action>
<action name="delete"
class="net.viralpatel.contact.view.ContactAction" method="delete">
<result name="success" type="chain">contact-form</result>
</action>
Above is taken from the struts.xml
when we delete, it redirects to 'contact-form' action and does whatever within that action.
Saturday, October 5, 2013
Hibernate Error : org.hibernate.PropertyValueException: not-null property references a null or transient value
This occured when DB id column is not null and auto generated and my hbm has defined the id column as
<generator class="native" />
org.hibernate.PropertyValueException: not-null property references a null or transient value: net.viralpatel.contact.model.Contact.created
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:95)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:313)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:562)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:550)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:546)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:342)
at $Proxy6.save(Unknown Source)
at net.viralpatel.contact.controller.ContactManager.add(ContactManager.java:27)
at net.viralpatel.contact.view.ContactAction.add(ContactAction.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:453)...
Solution:
This occured when DB id column is not null and auto generated and my hbm has defined the id column as
<generator class="native" />
org.hibernate.PropertyValueException: not-null property references a null or transient value: net.viralpatel.contact.model.Contact.created
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:95)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:313)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:562)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:550)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:546)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:342)
at $Proxy6.save(Unknown Source)
at net.viralpatel.contact.controller.ContactManager.add(ContactManager.java:27)
at net.viralpatel.contact.view.ContactAction.add(ContactAction.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:453)...
Solution:
Hibernate Error : failed.org.hibernate.PropertyNotFoundException: Could not find a getter
for firstname in class net.viralpatel.contact.model.Contact
I get below error in a struts 2 + hibernate 3 project and below is mapping file.
<property name="firstname" type="string" not-null="false" length="30" column="firstName" />
And below is how the domain class property is named.
private String firstName;
Below is how column in DB is named.
firstName VARCHAR(30)
when execute the add action from jsp page i get below error.
failed.org.hibernate.PropertyNotFoundException: Could not find a getter for firstname in class net.viralpatel.contact.model.Contact
Oct 6, 2013 11:51:32 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
org.hibernate.PropertyNotFoundException: Could not find a getter for firstname in class net.viralpatel.contact.model.Contact
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:306)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:299)
at org.hibernate.mapping.Property.getGetter(Property.java:294)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:268)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:148)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:76)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:80)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:325)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:457)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:261)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at net.viralpatel.contact.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:14)
at net.viralpatel.contact.util.HibernateUtil.<clinit>(HibernateUtil.java:8)
at net.viralpatel.contact.view.ContactAction.<init>(ContactAction.java:21)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:130)......................
Solution :
Property in hbm and pojo class are different.
They should be the same.
I get below error in a struts 2 + hibernate 3 project and below is mapping file.
<property name="firstname" type="string" not-null="false" length="30" column="firstName" />
And below is how the domain class property is named.
private String firstName;
Below is how column in DB is named.
firstName VARCHAR(30)
when execute the add action from jsp page i get below error.
failed.org.hibernate.PropertyNotFoundException: Could not find a getter for firstname in class net.viralpatel.contact.model.Contact
Oct 6, 2013 11:51:32 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
org.hibernate.PropertyNotFoundException: Could not find a getter for firstname in class net.viralpatel.contact.model.Contact
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:306)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:299)
at org.hibernate.mapping.Property.getGetter(Property.java:294)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:268)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:148)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:76)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:80)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:325)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:457)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:261)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at net.viralpatel.contact.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:14)
at net.viralpatel.contact.util.HibernateUtil.<clinit>(HibernateUtil.java:8)
at net.viralpatel.contact.view.ContactAction.<init>(ContactAction.java:21)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:130)......................
Solution :
Property in hbm and pojo class are different.
They should be the same.
Hibernate Error : org.hibernate.PropertyNotFoundException: Could not find a getter for cell_no in class net.viralpatel.contact.model.Contact
My hbm has below property.
Initial SessionFactory creation failed.org.hibernate.PropertyNotFoundException: Could not find a getter for cell_no in class net.viralpatel.contact.model.Contact
Oct 5, 2013 11:53:46 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
org.hibernate.PropertyNotFoundException: Could not find a getter for cell_no in class net.viralpatel.contact.model.Contact
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:306)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:299)
at org.hibernate.mapping.Property.getGetter(Property.java:294)
My hbm has below property.
Initial SessionFactory creation failed.org.hibernate.PropertyNotFoundException: Could not find a getter for cell_no in class net.viralpatel.contact.model.Contact
Oct 5, 2013 11:53:46 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
org.hibernate.PropertyNotFoundException: Could not find a getter for cell_no in class net.viralpatel.contact.model.Contact
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:306)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:299)
at org.hibernate.mapping.Property.getGetter(Property.java:294)
Hibernate Error – java.lang.NoClassDefFoundError:javax/transaction/Synchronization
This is caused by missing of the “jta.jar“, usually happened in Hibernate transaction development.java.lang.NoClassDefFoundError: javax/transaction/Synchronization at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:213) at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:473) at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:497) at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:505) at com.mkyong.common.App.main(App.java:13) Caused by: java.lang.ClassNotFoundException: javax.transaction.Synchronization at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 5 more
Solution
You can download “jta.jar” from default Maven central, JBoss or Java.net repositories.Thursday, November 15, 2012
How to FTP
- In a terminal type below and get gftp installed.
- Once it is installed, type gftp and press enter and you will get below window.
- Mention the host u want to transfer the file in to, user name and password you will use to log in to that server.Then from left side select the file you need to transfer by giving location and selecting file.Then click arrow to transfer it.
Monday, October 15, 2012
How to Debug In Eclipse
neststat -a |grep http
eg:netstat - nap|grep "127.0.0.1"
Any port which is not used above, can be set at debug port.
In Tomcat -> bin , we have the catalina.sh file. Paste the below lines to that file.Port specified should be the debug port.
# Debug settings
export JAVA_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5013 $JAVA_OPTS"
Then in eclipse, right click on project and then go to Debug As -> Debug Configurations --> Remote Java Application --> (Rightclick on this) --> New and we get the below wizard.
Port in above window should be the debug port we have mentioned earlier.
We can hav below in build.xml file.This is a task which will help start tomcat in debug mode.
<target name="tomcat-start-debug">
<echo message="##############################################################" />
<echo message="# Debugging Tomcat #" />
<echo message="##############################################################" />
<java jar="/home/ishara/Development/Tomcat/apache-tomcat-6.0.35/bin/bootstrap.jar" fork="true">
<jvmarg value="-Dcatalina.home=/home/ishara/Development/Tomcat/apache-tomcat-6.0.35"/>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=5013,server=y,suspend=n"/>
</java>
</target>
<echo message="##############################################################" />
<echo message="# Debugging Tomcat #" />
<echo message="##############################################################" />
<java jar="/home/ishara/Development/Tomcat/apache-tomcat-6.0.35/bin/bootstrap.jar" fork="true">
<jvmarg value="-Dcatalina.home=/home/ishara/Development/Tomcat/apache-tomcat-6.0.35"/>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=5013,server=y,suspend=n"/>
</java>
</target>
run the task as below.
ant tomcat-start-debug
once tomcat is up, go to eclipse and debug --> debug configuration --> select saved remote java application and click on 'Debug' button.
Keep a breakpoint where necessary.
Thursday, June 21, 2012
MySQL Issues In Ubuntu
sudo apt-get install mysql-server
2) If you need to check whether the MySQL server is running in your machine, run the following command from a terminal prompt.
sudo netstat -tap | grep mysql
If you get the following reply, it is running.
tcp 0 0 localhost.localdomain:mysql *:* LISTEN -
To start the server type below.
sudo /etc/init.d/mysql restart
3) To stop the server type below.
sudo /etc/init.d/mysql stop
4) How to log in to MySQL
mysql -u root -p;
5) How to retrieve users list in mysql
select User from mysql.user;
6) How to create new user account
CREATE USER Ish IDENTIFIED BY PASSWORD 'ish';
7) How to check existing databases
show databases;
8) How to grant all privileges to a user
GRANT ALL ON TEST.* TO 'Ish'@'localhost';
8) How to grant specific privileges to a user
GRANT SELECT,INSERT,UPDATE,DELETE ON TEST.* TO 'Ish'@'localhost';
9) How to log in as a different user
mysql -u USERNAME -p;
(here it will prompt for the password)
Monday, June 4, 2012
Alt+Tab Switcher effect Not Working In Ubuntu
Recently I was met with an issue after taking usual updates in Ubuntu.Normal Alt+Tab behavior would not work as it used to and that made my laptop completely unusable.
After looking through so many forums, I realized many people have faced the same issue.
If you face the same issue, below is how to get rid of it, temporarily.
1)Install Gnome shell in ubuntu 11.10 as below.
sudo apt-get install gnome-shell
2) Logout from the existing session & select GNOME from the login Screen as below.
4) It will have some nice user friendly environments as below.
Thursday, May 31, 2012
How To Install NS2 On Ubuntu
1. Download a copy of ns-allinone-2.31.tar.gz and paste on your home directory (eg,
/home/myusername/)
2. Then from the command prompt there, execute the following:
1. Download a copy of ns-allinone-2.31.tar.gz and paste on your home directory (eg,
/home/myusername/)
2. Then from the command prompt there, execute the following:
- tar -xzf ns-allinone-2.31.tar.gz
- cd ns-allinone-2.31
- ./install
Subscribe to:
Posts (Atom)












