Friday, December 28, 2012

Configuring Jetty, Maven, and Eclipse together


Environment Information:
JDK 1.5+
Eclipse 3.4.0
maven 2.0.10
m2eclipse 0.9.7 (maven plugin for eclipse)
Jetty 6.1.10
Spring
JPA,Hibernate
Maven Jetty Configuration:
In your maven project's pomx.xml, in your <build> section, add the jetty plugin.  An example can be found at the Jetty website here:
It is very important to keep <scanIntervalSeconds> set to zero.  This setting tells Jetty how often (in seconds) to scan the webapp for changes and if changes are found, it re-cycles the web container.  You don't want to do this and setting it to zero will disable it.
Configuring Jetty to start within Eclipse:
Next, create an easy way to launch your jetty server.  I'm using Jetty through Maven and Eclipse.  Here is how I setup an Eclipse External Tool to launch my Jetty server:
To make sure it is listening for a debugger, make sure that a MAVEN_OPTS environment variable is set with the following options:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n
The address parameter is what port the jetty server will be listening on for the remote debugger.
Click 'Run' and your jetty server should start running in Eclipse's console window.  It should look something like this (depending on your log4j config):
Listening for transport dt_socket at address: 4000
  [INFO] Scanning for projects...  [INFO] Searching repository for plugin with prefix: 'jetty'.  [INFO] ------------------------------------------------------------------------  [INFO] Building myProject  [INFO]    task-segment: [jetty:run]  [INFO] ------------------------------------------------------------------------  [INFO] Preparing jetty:run  2010-05-27 15:39:25.733::INFO:  Started SelectChannelConnector@0.0.0.0:8080  [INFO] Started Jetty Server
Attaching the Debugger:
Next, setup a debugger.  In Eclipse open 'Debug Configurations', and create a new 'Remote Java Debugger'.   Select your eclipse project, set the host to localhost, and set the port to 4000, or whatever you defined earlier.
Press the Debug Button and the remote debugger should attach to your jetty server.
Finally, make sure Build Automatically is enabled in eclipse (Project->Build Automatically).
At this point your environment is enabled for debugging code on your Jetty server through Eclipse.  Breakpoints, watch variables, you name it.
Hot deploy is also enabled.  If you modify some java code, the automatic builder should compile the .java file to a .class file.  The remote debugger will see it and use it, all without restarting your jetty server or its web container.  This will not work for things like adding static variables, new domain classes, or new injectable service methods that require the application to acknowledge them on startup.

Configuring Jetty, Maven, and Eclipse together


 external tool:
Dirigirse a External Tools Configuration y crear una nueva configuración, especificando la ruta hacia la instalación de maven local, el working directory y como arguments jetty:run.
Luego dirigirse a la pestaña Environment, y agregar la variable MAVEN_OPTS y asignarle el valor: -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y
Luego se debe crear un Debug Configuration:
Para crear esta configuración de Debug se debe ir a Debug Configurations, especificar el proyecto que se depurará y el mismo puerto que se estableció en la variable de entorno MAVEN_OPTS
Después de esto se deberán ejecutar los dos de forma consecutiva (uno depende el otro).
Primero se ejecutará la configuración de External Tools, con lo cual en la consola se podrá ver un mensaje como el siguiente en la consola.
Y solo después de ejecutar el Debug Configuration la aplicación comenzará a correr, y estaremos listos para hacer el debugging.

Sunday, December 23, 2012

ORA-28002: the password will expire within 7 days


Cause: The user's account is about to about to expire and the password needs 
to be changed.
Action: Change the password or contact the database administrator.

Reference: Oracle Documentation 

Solutions:

1) Simply change the password to avoid it temporary

  [oracle@lnxsvr ~]$ sqlplus scott/tiger

  SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 20 14:08:01 2012

  Copyright (c) 1982, 2009, Oracle.  All rights reserved.

  ERROR:
  ORA-28002: the password will expire within 7 days

  Connected to:
  Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

  SQL> PASSWORD
  Changing password for SCOTT
  Old password:
  New password:
  Retype new password:
  Password changed


2) Set PASSWORD_LIFE_TIME of the profile assigned user to UNLIMITED 
   then change the password to avoid it permanently
   
  [oracle@lnxsvr ~]$ sqlplus scott/tiger

  SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 20 14:08:01 2012

  Copyright (c) 1982, 2009, Oracle.  All rights reserved.

  ERROR:
  ORA-28002: the password will expire within 7 days

  Connected to:
  Oracle Database 11g Release 11.2.0.1.0 - 64bit Production   

  SQL> SELECT PROFILE FROM dba_users WHERE username = 'SCOTT';

  PROFILE
  ------------------------------
  DEFAULT

  SQL> SELECT  LIMIT FROM DBA_PROFILES WHERE PROFILE='DEFAULT' 
  AND RESOURCE_NAME='PASSWORD_LIFE_TIME';

  LIMIT
  ----------------------------------------
  60

  SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

  Profile altered.

  SQL> SELECT ACCOUNT_STATUS FROM DBA_USERS WHERE USERNAME='SCOTT';

  ACCOUNT_STATUS
  --------------------------------
  EXPIRED(GRACE)

  SQL> PASSWORD
  Changing password for SCOTT
  Old password:
  New password:
  Retype new password:
  Password changed


ORA-28002: the password will expire within 7 days

ORA-28002: the password will expire within 7 days  Cause: The user's account is about to about to expire and the password needs   to be changed.  Action: Change the password or contact the database administrator.    Reference: Oracle Documentation     Solutions:    1) Simply change the password to avoid it temporary      [oracle@lnxsvr ~]$ sqlplus scott/tiger      SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 20 14:08:01 2012      Copyright (c) 1982, 2009, Oracle.  All rights reserved.      ERROR:    ORA-28002: the password will expire within 7 days      Connected to:    Oracle Database 11g Release 11.2.0.1.0 - 64bit Production      SQL> PASSWORD    Changing password for SCOTT    Old password:    New password:    Retype new password:    Password changed      2) Set PASSWORD_LIFE_TIME of the profile assigned user to UNLIMITED      then change the password to avoid it permanently         [oracle@lnxsvr ~]$ sqlplus scott/tiger      SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 20 14:08:01 2012      Copyright (c) 1982, 2009, Oracle.  All rights reserved.      ERROR:    ORA-28002: the password will expire within 7 days      Connected to:    Oracle Database 11g Release 11.2.0.1.0 - 64bit Production         SQL> SELECT PROFILE FROM dba_users WHERE username = 'SCOTT';      PROFILE    ------------------------------    DEFAULT      SQL> SELECT  LIMIT FROM DBA_PROFILES WHERE PROFILE='DEFAULT'     AND RESOURCE_NAME='PASSWORD_LIFE_TIME';      LIMIT    ----------------------------------------    60      SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;      Profile altered.      SQL> SELECT ACCOUNT_STATUS FROM DBA_USERS WHERE USERNAME='SCOTT';      ACCOUNT_STATUS    --------------------------------    EXPIRED(GRACE)      SQL> PASSWORD    Changing password for SCOTT    Old password:    New password:    Retype new password:    Password changed


Wednesday, December 12, 2012

MAVEN Setup


Windows 2000/XP

  1. Unzip the distribution archive, i.e. apache-maven-3.0.4-bin.zip to the directory you wish to install Maven 3.0.4. These instructions assume you chose C:\Program Files\Apache Software Foundation. The subdirectory apache-maven-3.0.4 will be created from the archive.
  2. Add the M2_HOME environment variable by opening up the system properties (WinKey + Pause), selecting the "Advanced" tab, and the "Environment Variables" button, then adding the M2_HOME variable in the user variables with the value C:\Program Files\Apache Software Foundation\apache-maven-3.0.4. Be sure to omit any quotation marks around the path even if it contains spaces. Note: For Maven < 2.0.9, also be sure that the M2_HOME doesn't have a '\' as last character.
  3. In the same dialog, add the M2 environment variable in the user variables with the value %M2_HOME%\bin.
  4. Optional: In the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value -Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.
  5. In the same dialog, update/create the Path environment variable in the user variables and prepend the value %M2% to add Maven available in the command line.
  6. In the same dialog, make sure that JAVA_HOME exists in your user variables or in the system variables and it is set to the location of your JDK, e.g. C:\Program Files\Java\jdk1.5.0_02 and that %JAVA_HOME%\bin is in your Path environment variable.
  7. Open a new command prompt (Winkey + R then type cmd) and run mvn --version to verify that it is correctly installed.

Unix-based Operating Systems (Linux, Solaris and Mac OS X)

  1. Extract the distribution archive, i.e. apache-maven-3.0.4-bin.tar.gz to the directory you wish to install Maven 3.0.4. These instructions assume you chose/usr/local/apache-maven. The subdirectory apache-maven-3.0.4 will be created from the archive.
  2. In a command terminal, add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-3.0.4.
  3. Add the M2 environment variable, e.g. export M2=$M2_HOME/bin.
  4. Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven.
  5. Add M2 environment variable to your path, e.g. export PATH=$M2:$PATH.
  6. Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=/usr/java/jdk1.5.0_02 and that $JAVA_HOME/bin is in your PATH environment variable.
  7. Run mvn --version to verify that it is correctly installed.

Optional configuration

Maven will work for most tasks with the above configuration, however if you have any environmental specific configuration outside of individual projects then you will need to configure settings. The following sections refer to what is available.