• Eclipse/maven-jetty plugin: Couldn’t restart my listener

    related to my blog: Eclipse: running your project via mvn jetty:run and debugging it

    So there i was using my eclipse, running the external tool for debugging.
    I recompiled my source code and needed to re-run the debugger.
    But when I restarted the listener(part of external tool) it wouldn’t start.
    My guess was on the port. So I asked nap…

    checked it with lsof -i :4000

    it returned the process running using it.
    i guess eclipse was unable to kill that process, when i restarted my listener.
    after knowing the PID i then killed it and started my external tool.

    thanks nap.

  • Finding Memory Leaks

    As Jon Bentley said, “Make it work before you make it work fast.”

    I got this line in the JMP user guide. By the way, JMP stands for Java Memory Profiler.
    Oh yeah, we’re now looking for possible memory leaks.

    I also found out that JMP can be installed in Gutsy Gibbon using apt-get.
    After installing, I tried running it with MAVEN.
    added the -Xrunjmp:<your options> in the MAVEN_OPTS, it worked.

    There are three things you can profile with this tool:

    • Profiling objects to find memory leaks and find causes for heavy memory usage
    • Profiling methods to find out where your program spends time
    • Inspect threads to find out why your program is blocked
  • Java to DWR - decrease the file size of your javascript

    It was until yesterday i realized I was doing something wrong with regards to JAVA-DWR interfacing as pointed out by Cata.

    Backgrounder: in dwr.xml we define the classes(services) we use, which generates javasript which we will call facades and these can be imported in our javascript files.
    My practice: In my js file, i simply import those facades i need, even though i only use one method in one of the services.
    Issue: when importing a facade to your js files it will include everything even those methods you don’t use, thus increasing the size of your js file.

    Proposed solution: create another class composed of only those methods used in your front-end. So that it will lessen the file size of your javascript generated by the DWR.

  • Eclipse: running your project via mvn jetty:run and debugging it

    As part of my preparation for my new assignment, since I’ve been using Eclipse, I do really need this set to my IDE…



    Step 1
    Go to the Run/External Tools/External Tools …” menu item on the “Run” menu bar. Select “Program” and click the “New” button. On the “Main” tab, fill in the “Location:” as the full path to your “mvn” executable. For the “Working Directory:” select the workspace that matches your webapp. For “Arguments:” add jetty6:run.

    Move to the “Environment” tab and click the “New” button to add a new variable named MAVEN_OPTS with the value:

    -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y

    If you supply suspend=n instead of suspend=y you can start immediately without running the debugger and launch the debugger at anytime you really wish to debug.

    Step 2
    Then, pull up the “Run/Debug/Debug …” menu item and select “Remote Java Application” and click the “New” button. Fill in the dialog by selecting your webapp project for the “Project:” field, and ensure you are using the same port number as you specified in the address= property above.

    Now all you need to do is to Run/External Tools and select the name of the maven tool setup you created in step 1 to start the plugin and then Run/Debug and select the name of the debug setup you setup in step2.

    Some Notes:
    If your project has a modular structure, you need to set the “Working Directory” on the parent folder and use jetty:run-exploded for the argument field.
    Generally, your guide in configuring Step 1 would be how you run your project via command console.
    Make sure that you have ran your project in command console just to verify that “mvn jetty:run” or “mvn jetty:run-exploded” is working.

    Credits: http://simile.mit.edu/wiki/How_to_debug_mvn_jetty:run_in_Eclipse

  • Oracle Hibernate URL Connection String

    Bout: jdbc:oracle:thin:@localhost:1521/orcl vs jdbc:oracle:thin://localhost:1521/orcl

    Story:
    1. Checked out the project
    2. set parameters for the DB connection
    3. built it and attempted to run it.

    Problem: The app wouldn’t run.

    Attempts to solve:Checked parameters of database-c3p0.properties

    * system.connection.username=system (able to use this in the sqlplus)
    * system.connection.password=password (this was the password assigned during setup)
    * hibernate.connection.username = npn6 (this was created)
    * hibernate.connection.password = npn6 (this was the password assigned during creation of user)
    * hibernate.connection.url = jdbc:oracle:thin:@localhost:1521/orcl.sublime.local (changed to jdbc:oracle:thin:@localhost:1521/orcl , no go)

    My last resort: Called Ken D

    Solution: he used “jdbc:oracle:thin://localhost:1521/orcl” for the hibernate.connection.url

    thanks Ken D ;)

  • Weird Behavior in partitioning disk

    I have this old partitioning designed for Ubuntu 6.06 (Dapper)

    partition 1 NTFS my windows partition
    partition 2 FAT32 for writing files that would be accessible for both windows and linux
    partition 3 is my Ubuntu partition

    since Gutsy Gibbon does write in NTFS i had to remove FAT and expand my NTFS

    the queer thing was, when i booted to Windows its disk manager reports that i have the correct partitions and correct sizes,
    but when i get into windows explorer, my drive C still has the same capacity

    to cut things short, I just resized the partition back then once again and it eventually fixed it.

    just to be sure, i booted to windows and checked my C drive and its been corrected.

    i now have a bigger NTFS and FAT was out. I hate that FAT changing the cases of web-inf folder.

  • Dumping data to Oracle 10g via command line

    Assuming you have already created the DB user, see http://blogs.exist.com/jcutaran/2008/02/18/creating-a-user-in-oracle-10g-through-command-line/

    1. Log into a command console with the oracle user

    > su - oracle

    2. execute the command template below

    imp userid= fromuser= toUser= file= log= compile=y commit=y

    example:

    > imp userid=system/password fromuser=NPN6 toUser=NPN6 file=~/version1.dmp log=~/imp.log compile=y commit=y

    some notes:
    userid - refers to the account with administrative rights
    fromUser/toUser - refers to user account which the dump will be imported
    file - refers to the dump file

    again thanks to Ken D.

  • Creating a user in Oracle 10g through command line

    Assuming Oracle is installed and running…

    1. Log into a command console with the oracle user.

    > su - oracle

    2. Creat a file and place the text below.

    drop user npn6 cascade;
    create user npn6 identified by npn6;
    grant resource, connect, create view to npn6;
    commit;

    3. log into sqlplus to run the file you created

    >sqlplus / as sysdba

    4. from the sqlplus console, you may run the file you created, assuming the file name is user.sql

    SQL>@user.sql

    5. you should get an output like

    User created.

    Grant succeeded.

    Commit complete.

    SQL>

    5. then you may exit. You have created a user npn6

    I tried finding this over google, but i guess i’m not good at hunting :(

    Thanks to Ken del Rosario our “Oracle Main Man”.