Featured post

MyEclipse start problem java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer


I recently ran into an issue where MyEclipse would not start. I would click to open, select my workspace and then it would be MIA! Looking at the logs in :

<workspace-directory>\.metadata\.log

I found this

org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources.

and this error

java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer

To resolve my issue, I had to delete the .snap file located in the directory :

<workspace-directory>\.metadata\.plugins\org.eclipse.core.resources

After deleting that file, I was able to start MyEclipse with no problem.

Additional Log Stacktrace


!ENTRY org.eclipse.osgi 4 0 2010-08-04 13:30:01.386
!MESSAGE Application error
!STACK 1
java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:107)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)

Additional Log


org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1018)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:400)
at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:111)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:189)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:340)
at org.eclipse.osgi.framework.internal.core.SingleSourcePackage.loadClass(SingleSourcePackage.java:37)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:405)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:369)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:357)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:107)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
Caused by: java.lang.IllegalArgumentException: Path for project must have only one segment.
at org.eclipse.core.runtime.Assert.isLegal(Assert.java:62)
at org.eclipse.core.internal.resources.WorkspaceRoot.getProject(WorkspaceRoot.java:165)
at org.eclipse.core.internal.resources.ProjectDescriptionReader.endProjectsElement(ProjectDescriptionReader.java:470)
at org.eclipse.core.internal.resources.ProjectDescriptionReader.endElement(ProjectDescriptionReader.java:221)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.core.internal.resources.ProjectDescriptionReader.read(ProjectDescriptionReader.java:552)
at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:655)
at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:792)
at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:772)
at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:663)
at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1319)
at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:1949)
at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:1713)
at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:363)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:999)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:993)
... 29 more
Root exception:
java.lang.IllegalArgumentException: Path for project must have only one segment.
at org.eclipse.core.runtime.Assert.isLegal(Assert.java:62)
at org.eclipse.core.internal.resources.WorkspaceRoot.getProject(WorkspaceRoot.java:165)
at org.eclipse.core.internal.resources.ProjectDescriptionReader.endProjectsElement(ProjectDescriptionReader.java:470)
at org.eclipse.core.internal.resources.ProjectDescriptionReader.endElement(ProjectDescriptionReader.java:221)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.core.internal.resources.ProjectDescriptionReader.read(ProjectDescriptionReader.java:552)
at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:655)
at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:792)
at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:772)
at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:663)
at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1319)
at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:1949)
at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:1713)
at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:363)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:999)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:993)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:400)
at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:111)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:189)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:340)
at org.eclipse.osgi.framework.internal.core.SingleSourcePackage.loadClass(SingleSourcePackage.java:37)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:405)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:369)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:357)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:107)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)

Stripe grails integration


In this tutorial, we will build a very simple 1 controller grails application that will process a fake credit card charge.

If you are new to Stripe, “Stripe is a developer-friendly way to accept payments online and in mobile apps.” http://stripe.com

Its important to note how Stripe processes credit card information. Stripe provides an Javascript API that will asynchronously retrieving a token representation of the credit card credentials. This prevents you from having to deal with credit card information server side. Here is an example on how you get the token.

Tutorial source code https://github.com/mcroteau/stripe-example

1. Create Application

grails create-app stripe-example

2. Add dependency

First step, add the stripe maven dependency in the dependencies section of the BuildConfig.groovy

runtime 'com.stripe:stripe-java:1.12.0'

3. CheckoutController

Now lets create a CheckoutController for payment process

grails create-controller Checkout

4. Create gsps

Grails will create the controller grails-app/controllers/CheckoutController.groovy and a grails-app/views/checkout directory. Lets go ahead and create a grails-app/views/checkout/index.gsp and a grails-app/views/checkout/checkout.gsp

5. grails-app/views/checkout/index.gsp

<!DOCTYPE html>
<html>
<head>
	<meta name="layout" content="main"/>
	<title>Stripe Checkout</title>
	
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
	
	<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
	
	<style type="text/css">
		.container{
			padding:30px;
		}
		.form-group{
			margin:10px 0px;;
		}
		label{
			display:block;
			font-weight:bold;
		}
		label span{
			font-size:11px;
			font-weight:normal;
			display:block;
		}
	</style>
</head>
<body>

	<div class="container">
		<g:form action="checkout" method="post" id="checkout_form" name="checkout_form">
			
			<!-- * Important * you will need to set a hidden form input after retrieving the Stripe Token-->
			<input type="hidden" name="stripeToken" value="" id="stripeToken"/>
			
			<div class="form-group">
				<label>Amount</label>
				<input type="text" name="amount" value="" id="amount" size="7"/>
			</div>
			<div class="form-group">
				<label>Credit Cart # <span>(for testing purposes use 4242424242424242)</span></label>
				<input type="text" name="cc_number" value="4242424242424242" id="cc_number"/>
			</div>
			<div class="form-group">
				<label>CVC <span>(Any 3 numbers)</span></label>
				<input type="text" name="cvc" value="" id="cvc" size="3"/>
			</div>
			<div class="form-group">
				<label>Expiration <span>(MM/YYYY)</span></label>
				<input type="text" name="exp_month" value="" id="exp_month" size="2"/>
					 / 
				<input type="text" name="exp_year" value="" id="exp_year"/>
			</div>
		</g:form>

		<!-- Placing outside the form as we are going to manually submit the form after recieving the Stripe Token from Stripes web service -->
		<div class="form-group">
			<input type="submit" name="submit" size="4" id="submit" value="Stripe Checkout"/>
		</div>
		
	</div>
	

<script type="text/javascript">
			
$(document).ready(function(){

	var $tokenInput = $('#stripeToken'),
		$cardNumberInput = $('#cc_number'),
		$cardCvcInput = $('#cvc'),
		$cardExpMonth = $('#exp_month'),
		$cardExpYear = $('#exp_year'),
		$checkoutForm = $('#checkout_form');

	Stripe.setPublishableKey("YOUR STRIPE PUBLISHABLE KEY");

	$('#submit').click(checkCreditCardValues);
	
	function checkout(){
		console.info('submit form, process payment, create transaction', $checkoutForm);
		$checkoutForm.submit();
	}

	function setStripeTokenInput(code, token){
		console.info("retrieved token : ", token)
		//set hidden stripe token input
		$tokenInput.val(token.id)
		checkout();
	}

	 /**
	 	* IMPORTANT *
	    This is the somewhat tricky part, you will receive a token object in 
	    the callback function arguments.  You want to take this token and set
	    a hidden form input that later will get passed to the server side
	**/
	
	function getStripeToken(){
		console.info('get stripe token')
		Stripe.card.createToken({
		    number    : $cardNumberInput.val(),
		    cvc       : $cardCvcInput.val(),
		    exp_month : $cardExpMonth.val(),
		    exp_year  : $cardExpYear.val()
		}, setStripeTokenInput);
	}


	function checkCreditCardValues(){
		if($cardNumberInput.val() != "" &&
				$cardCvcInput.val() != "" &&
				$cardExpMonth.val() != "" &&
				$cardExpYear.val() != ""){
			getStripeToken();
		}else{
			alert('Please make sure all credit card information is provided')
		}
	}
	
})
</script>			
</body>
</html>

6. grails-app/views/checkout/checkout.gsp

<!DOCTYPE html>
<html>
<head>
	<meta name="layout" content="main"/>
	<title>Stripe Checkout</title>
</head>
<body>	
	<g:if test="${flash.message}">
		<h2 class="message" role="status">${flash.message}</h2>
	</g:if>
</body>
</html>	

7. CheckoutController.groovy

package stripe.example

import com.stripe.Stripe
import com.stripe.model.Charge

class CheckoutController {

    def index() { }
	
	def checkout() {
	
		try {
			//Set Stripe Secret/Api Key
			Stripe.apiKey = "YOUR STRIPE API KEY"
			  		
			def amount = Double.parseDouble(params.amount)
			def token = params.stripeToken
			
			if(amount && token){
				println "\n\nSTRIPE API KEY : ${Stripe.apiKey} -> TOKEN : ${token} -> AMOUNT : ${amount}\n\n"
				//convert amount into cents
    			def amountInCents = (amount * 100) as Integer
    			
				//create Stripe parameters object
    			def chargeParams = [
    			    'amount': amountInCents, 
    			    'currency': 'usd', 
    			    'card': token, 
    			    'description': "Order Placed ${amount}"
    			]
    			
    			Charge.create(chargeParams)
				flash.message = "Successfully charged Stripe"
			}

    	
		} catch (Exception e) {
			flash.message = "Something went wrong ..."
			println("Status is: " + e.printStackTrace());
		}	
	}
}

8. Run the app

Browse to http://localhost:8080/stripe-example/checkout

Here is a link to the complete tutorial source code https://github.com/mcroteau/stripe-example

WPF / .NET / XAML – blurry images


I have been doing a little UX/UI development work on a WPF Application recently. I created some mockups on how I wanted some buttons to look. When attempting to implement the mockup design in xaml using an image, I noticed that the image rendered with a blur. After a quick search, and reviewing a couple stackoverflow threads, found a solution that worked for me.

Setting UseLayoutRounding to “True” in the Main Window rendered the image without a blur.

UseLayoutRounding="True"

Take a look below :

xaml, wpf, .net blurry images.  render image with blur

xaml, wpf, .net blurry images. render image with blur

Stackoverflow thread

Juniper Jammery’s Orange & Orange Jalapeno marmalades reviewed… we be jammin


Juniper Jammery Marmalades

Juniper Jammery Zesty Orange, Zesty Jalapeno Orange & Grapefruit Marmalades

Recently I was given the opportunity to try a couple marmalades made by Juniper Jammery (JJ), a small family owned business. (Read more about them : http://blog.thejuniperjammery.com/?p=6)

The 2 I have tried so far are the Zesty Orange and the Zesty Orange Jalapeno

Orange Marmalade

Due to my busy schedule, I find myself eating a lot of peanut butter and jelly sandwiches. After receiving my tasters, I switched out the Jelly with JJ’s Orange Marmalade. Now Im no marmalade connoisseur, however, I can say that I have eaten my fare share of marmalades, jams and jellys and Juniper Jammery’s Zesty Orange is delicious… The consistency (now I am trying to sound like a connoisseur) is near perfect, spreadable but not too light. The marmalade is full of orange flavor, to put it simply Juniper Jammery made my Peanut Butter and Marmalade sandwich refreshing

Orange Jalapeno Marmalade

This was just as tasty as the Zesty Orange however, it didn’t have as much kick as I thought it would. Still a great tasting marmalade, full of Orange flavor and just as refreshing. Maybe my next order will have a litte more kick.

Summary

All in all Juniper Jammery’s marmalades are great tasting and refreshing. Leonardo Divinci was quoted as saying “Simplicity is the ultimate sophistication”. If that were true, with 5 ingredients, all of which are 100% natural… its fair to say “Juniper Jammery Orange Marmalade is the ultimate sophistication”. (ok, a little over the top… bottom line, good marmalade).

Here is a link to their site http://www.thejuniperjammery.com/

Fix SSH + VIM issues on mac to windows box running cygwin


Recently I ran into some vim issues while ssh’ing onto a windows server running cygwin… the process of getting things to work right was painful enough for me to do a write up.

To be more explicit, this was my situation : I was working on a mac laptop ssh’ing onto a windows machine running cygwin and using vim to edit files.

Here were the list of issues that I ran into and how I was able to address them :

SSH terminal window had a grayish color surrounding all text

To fix this I had to explicitly set the terminal type. I am not an expert on terminal types, and not really interested in becoming one, so all I can offer in this post is what worked for me, and that setting it to vt100.

If you are unclear on how to set the terminal type, it is an environment variable that be set in either your .profile or manually in the mac terminal by using the following command :


export TERM=vt100

Or open up the mac terminal preferences -> Settings -> Advanced -> under “Emulation” select vt100

Here is a decent article explaining terminal types

VIM issue with Delete not working outputting “^_”

What was happening here was that mac sends a different command for backspace than windows uses. This was took a few google searches but was able to track down the fixes for this issue.

1. Edit Terminal Preferences : Open up the mac terminal preferences -> Settings -> Advanced -> check “Delete sends Ctrl-H”

2. ssh onto the windows machine running cygwin and add the following to the .vimrc file in your home directory :


set backspace=indent,eol,start

These two things made vim work as expected while ssh’ing onto windows machine running cygwin.