Friday, July 20, 2012

SMTP local server in windows 7? (running IIS7)

This response is a little late, but might help the next person...
No, Windows 7 does not come with an SMTP server. Supposedly Remote Server Administration tools includes an SMTP server, but according to this link, it does not work.
Some options for sending email from a Windows 7 machine are:
For development purposes, I like smtp4dev http://smtp4dev.codeplex.com/. It is open source and emulates a SMTP server. However instead of actually sending the email, it keeps in in an app on the system tray. Great for making sure you don't accidentally SPAM your users.
If you are planning to send emails out for real, I would advise using a SMTP server with a static IP address as most spam filters dislike dynamic addresses and will block the email.
I have not used it, but if you must send email from your local Windows machine and am not worried about SPAM filters, Free SMTP Server from www.softstack.com seems pretty popular.

http://stackoverflow.com/questions/8041856/smtp-local-server-in-windows-7-running-iis7

Wednesday, July 18, 2012

How do you refresh maven dependencies from eclipse?

You generate the special eclipse files with mvn eclipse:eclipse, but once you've done that, you should let a plugin handle the dependencies while inside eclipse.
That's how we do it at my work place, and it generally works well.

http://stackoverflow.com/questions/136308/how-do-you-refresh-maven-dependencies-from-eclipse

Monday, July 16, 2012

class file has wrong version 50.0, should be 49.0″ by Maven

If this error occurs when you’re compiling your Maven project, there’s a good chance that you’ve included a Maven Dependency that was compiled using Java 1.6 and your Maven installation is running on a Java 1.5 JRE.
The good news is that Maven will tell you which Dependency is causing that. For instance, in my case it was java-web-api as shown in the error message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project hTask-web: Compilation failure
[ERROR] /Users/hordine/projects/hTask/hTask-web/src/main/java/com/hordine/htask/web/control/TaskController.java:[3,-1] cannot access javax.servlet.http.HttpServletRequest
[ERROR] bad class file: /Users/hordine/.m2/repository/javax/javaee-web-api/6.0/javaee-web-api-6.0.jar(javax/servlet/http/HttpServletRequest.class)
[ERROR] class file has wrong version 50.0, should be 49.0
This makes perfect sense, since if you use features of a later java version, i.e. 1.6, to build your application, then those features won’t be understood by an earlier Java JRE, i.e. 1.5, since they didn’t know what was coming in Java 1.6 yet. Yeah right.
But anyway, there are 2 quick ways to fix this. One is to find an earlier version of your Dependency, which was compiled using Java 1.5, and the other is to install a Java 1.6 JRE and get Maven to use that one. The later can be as simple as setting the JAVA_HOME environment variable to your Java 1.6 installation.
That’s it for this post.

http://hordine.wordpress.com/2012/05/02/class-file-has-wrong-version-50-0-should-be-49-0-by-maven/

JBoss debugging in Eclipse

You mean remote debug JBoss from Eclipse ?
From Configuring Eclipse for Remote Debugging:
Set the JAVA_OPTS variable as follows:
set JAVA_OPTS= -Xdebug -Xnoagent 
   -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%
or:
JAVA_OPTS=”-Xdebug -Xnoagent 
  -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n $JAVA_OPTS
In the Debug frame, select the Remote Java Application node.
In the Connection Properties, specify localhost as the Host and specify the Port as the port that was specified in the run batch script of the JBoss server, 8787.

http://stackoverflow.com/questions/516196/jboss-debugging-in-eclipse

Multiple testsuites in Cactus

http://mail-archives.apache.org/mod_mbox/jakarta-cactus-user/200304.mbox/%3COFA7163D45.FAD487C5-ON85256D11.00528FAD@ny.jpmorgan.com%3E

Tuesday, July 10, 2012

Java - How to set timezone of a java.util.Date

Use DateFormat. For example,
    SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    isoFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date = isoFormat.parse("2010-05-23T09:01:02");
 
Be aware that java.util.Date objects do not contain any timezone information by themselves - you cannot set the timezone on a Date object. The only thing that a Date object contains is a number of milliseconds since the "epoch" - 1 January 1970, 00:00:00 UTC.
As ZZ Coder shows, you set the timezone on the DateFormat object, to tell it in which timezone you want to display the date and time.

http://stackoverflow.com/questions/2891361/java-how-to-set-timezone-of-a-java-util-date
 

Thursday, July 5, 2012

SQL Server: how to search for a table name or a column name or a given stored procedure name

This article demonstrates how the Microsoft SQL Server database can be queried to perform the following tasks:
1. fetch a list of tables.
2. fetch a list of Columns.
3. fetch a list of Stored Procedures
The results can refined further by including other search criteria in the where clause of each query.

--Query to fetch the list of table that match a pattern
select * from information_schema.tables where table_name like '%Employee%'

--Query to fetch the list of Columns (with table info) that match a pattern.
select * from information_schema.columns where column_name like '%EmpId%'

--Query to fetch the list of Stored Procedures that match a pattern.
select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_DEFINITION from INFORMATION_SCHEMA.ROUTINES
where ROUTINE_TYPE='PROCEDURE' and routine_name like '%MyProc%' 
http://cavemansblog.wordpress.com/2009/02/26/sql-how-to-2/