Saturday, September 26, 2020

GitHub Frequently Used Tips and Tricks

Adding an Existing project to GitHub

  1. Create a new repository(repo) on GitHub.
  2. In command prompt open Git Bash
  3. Change the current working directory to your local project.
  4. Initialize the local directory as a Git repository.
    git init
  5. Add (stage) the files in your new local repository.
    git add .
  6. Commit staged files locally.
    git commit -m "initial commit"
  7. In GitHub copy the https url of your newly created repo (e.g https://github.com/xxxxxxx.git)
  8. In the command prompt, add the URL for the remote repository where your local repository will be pushed.
    git remote add origin
    https://github.com/xxxxxxx.git

    git remote -v
  9. Push the changes in your local repository to GitHub.
    git push -f origin master

Tuesday, July 1, 2014

GlassFish 4.0 ClassCastException on Class with the Same Type

Repeated deploy and undeploy of applications in GlassFish you may encounter the following class loader issue.

java.lang.ClassCastException: my.com.Test cannot be cast to my.com.Test

Within the GlassFish administration console:

Disable and Undeploy the application.
Restart the server.
Deploy the application.

Using Reload or Redeploy will not resolve the issue.

Thursday, June 19, 2014

Mac OSX Tips


Setting JAVA_HOME

OSX: 10.9.3

Open a Terminal

Type: nano .bash_profile

Add: export JAVA_HOME=$(/usr/libexec/java_home)

Exit nano: ctrl+o and hit return

Type: source .bash_profile

Type:  echo $JAVA_HOME

You should see something like: Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home

Tuesday, January 14, 2014

Ripple Emulator: 500 Internal Server Error on localhost connections



I'm trying to develop a mobile app using Cordova (PhoneGap). To test this app I have been using Ripple this is a great tool and much more convenient than the slow Android emulator. One problem I did came across was a 500 Internal Server Error while trying to connect to another server running locally on my computer. This is the http headers and response.

Headers:
Request URL:
https://rippleapi.herokuapp.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//localhost%3A8080/xxxxxxxx/login/authenticateMobileUser

Request Method:
POST

Status Code:
500 Internal Server Error


Response:
{
  "code": "ECONNREFUSED",
  "errno": "ECONNREFUSED",
  "syscall": "connect"
}

To fix this problem - Ripple emulator by default has "Cross Domain Proxy" set to "Remote". For localhost connections change it to "Local".




Monday, June 18, 2012

Glassfish 3.1 Problems - "Attempting to execute an operation on a closed EntityManagerFactory"

Recently I tried to re-deploy a EJB jar application into the GlassFish 3.1 Server but got the following error:

java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory.

To fix this problem do a clean deploy by first undeploying the application and redeploying the application.

Wednesday, June 22, 2011

Eclipse: How to convert a Java Project into a Web Project

Eclipse Version: Helios Service Release 1

Java projects do not have the Export->WAR File option. To get this option you must convert your Java project into a web project.

Step 1: Create a new Dynamic Web Project
Step 2: Open the Dynamic Web Projects .project file and copy the following lines of XML to your Java projects .project file.


[2011-06-15 14:01:36 - ddms]null

<buildspec>
...
<buildcommand>   <name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
...
</buildSpec>

<natures>
...
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
...
</natures>


Step 3: Within the Java projects Project Facets enable the Dynamic Web Module and Java.

Tuesday, June 14, 2011

Android Programming: ddms]null java.lang.NullPointerException error

Starting Android emulator within Eclipse Helios I get:


[2011-06-15 14:01:36 - ddms]null
java.lang.NullPointerException
at com.android.ddmlib.Client.sendAndConsume(Client.java:572)
at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.java:671)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
}



To fix this problem set a Size on the SD card property within the Android Virtual Device (AVD).