some Eclipse shortcuts for Sublime Text 2

Open "Preferences -> Key Bindings - User" and add these lines:

[
	{ "keys": ["ctrl+space"], "command": "auto_complete" },
	{ "keys": ["ctrl+shift+f"], "command": "reindent", "args": {"single_line": false}},
	{ "keys": ["alt+up"], "command": "swap_line_up" },
 	{ "keys": ["alt+down"], "command": "swap_line_down" },
 	{ "keys": ["ctrl+alt+down"], "command": "duplicate_line" },
 	{ "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
 	{ "keys": ["alt+shift+r"], "command": "find_all_under" },
 	{ "keys": ["ctrl+7"], "command": "toggle_comment", "args": { "block": false } },
 	{ "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": true } }
]
Advertisements

jboss 7.1 change password

if you want to change jboss 7.1 admin console password, first remove the user and add it again.

  1. open “jboss-as-x.x.x.Final\standalone\configuration\mgmt-users.properties” and delete the user (i.e delete the line such as “admin=2c7123264278731425d1f53aeb55da1e”)
  2. open “jboss-as-x.x.x.Final\domain\configuration\mgmt-users.properties” and delete the user (i.e delete the line such as “admin=2c7123264278731425d1f53aeb55da1e”)
  3. run “jboss-as-x.x.x.Final\bin\add-user.bat” and add user

if you get “JBAS015243: The user ‘admin’ already exists in at least one properties file.” error, it means there is a user with the same username and you didnt do first two steps :)

useful mysql queries snippets

– remove duplicate records:
CREATE TEMPORARY TABLE temp_table (column1 VARCHAR(256),column2 VARCHAR(256));
INSERT INTO temp_table (`column1`,`column2`) SELECT DISTINCT `column1`,`column2` FROM table1;
DELETE from table1;
INSERT INTO table1 (`column1`,`column2`) SELECT * FROM temp_table;

– show duplicate records:
SELECT column1, count(*) FROM table1 GROUP BY id HAVING count(*) > 1;
or
select * from table1 i where i.id in
(SELECT id FROM table1 GROUP BY id HAVING count(*) > 1);

– set foreign key:
update table1 a, table2 b set a.fID=b.id where y.column1=i.column1;

– remove column:
alter table table1 drop column1;

– compare two columns to find unmatched records:
select column2 from table1
where column2 not in (select column1 from table1);

Value ‘0000-00-00’ can not be represented as java.sql.Date

If you get "javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Value '0000-00-00' can not be represented as java.sql.Date" error
or just "Value '0000-00-00' can not be represented as java.sql.Date" error,
you have to add "zeroDateTimeBehavior=convertToNull" to your connection URI.
(Source: https://dev.mysql.com/doc/refman/5.0/en/connector-j-installing-upgrading.html)

    Solutions:

  1. In jboss admin console, open “Profile > Connector > Datasources > Properties” and add this property:
    key: zeroDateTimeBehavior – value: convertToNull
    or
    Open “jboss-as-x.x.x.Final\standalone\configuration\standalone.xml” and add

    <connection-property name="zeroDateTimeBehavior">
    	convertToNull
    </connection-property>
  2. You can use this JDBC URL directly in your datasource configuration:
    jdbc:mysql://yourserver:3306/yourdatabase?zeroDateTimeBehavior=convertToNull
  3. Add this to hibernate.cfg.xml:
    <property name="hibernate.connection.zeroDateTimeBehavior">convertToNull</property>
  4. In hibernate.properties:
    hibernate.connection.zeroDateTimeBehavior=convertToNull

glassfish “Unable to start server due following issues: java.lang.NullPointerException” exception

When starting glassfish server, if you get "Unable to start server due following issues: java.lang.NullPointerException" exception, it is probably because of the localization settings of eclipse. To change eclipse’s localization settings:

  • Open eclipse.ini file which is located in your eclipse installation directory (in the same folder with eclipse.exe).
  • Add -Duser.language=en in the bottom of your eclipse.ini.
  • Restart eclipse.

There is a parallel problem for netbeans. If you get: “GlassFish Server Server start failed. Cant create start proccess” in netbeans, consult: https://madvens.wordpress.com/2013/07/05/netbeans-glassfish-problem-solution/

mac related notes, useful links etc

mac os x path environment variable

path mac – http://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/

path linux – http://www.cyberciti.biz/faq/set-environment-variable-linux/


Reset garbled Terminal window on OS X

If your terminal has been shifted into “alternate character set” mode and you want to reset the terminal without closing the window and reopening it type

tput rmacs

at your (garbled) shell prompt. Your typing will appear garbled, too, but it will be back to normal after this command finishes.


Glassfish PermGen space error

Step #1: Increase memory by configuring “domain.xml”

In linux, it is located under /usr/share/glassfish3/glassfish/domains/domain1/config
(in windows C:\glassfish3\glassfish\domains\domain1\config)

There are two configs in domain.xml, server-config and default-config. Search for "-XX:MaxPermSize=" in server-config and set its value to 256m or higher.
(i.e. <jvm-options>-XX:MaxPermSize=256m</jvm-options>)

(Why server-config?
Because, from the Glassfish 3.1.1 doc:
The default-config configuration is a special configuration that acts as a template for creating named configurations. Clusters and instances cannot refer to the default-config configuration. The default-config configuration can only be copied to create configurations.)

 

Step #2: Restart server

Navigate to /usr/share/glassfish3/bin
and run ” ./asadmin restart-domain domain1
or first ” ./asadmin stop-domain domain1 ” then “./asadmin start-domain“.

 

Note:

If the server not responding to these commands, first kill the glassfish process to free the port on which it was running (say 8080).

For linux based os:

– open terminal and type ” -sudo netstat -npl | grep 8080
– this will result in something like ” tcp6 0 0 :::8686 :::* LISTEN 10241/java
– then use ” kill -9 10241 ” to kill that process (10241 in this case)
– Now try to start glassfish, it should start.

For windows:

– To kill the glassfish process: https://madvens.wordpress.com/2012/06/02/how-to-free-a-port-on-windows/
– Now try to start glassfish, it should start.