Sunday, March 23, 2014

JTA Tutorial

Following http://www.javacodegeeks.com/2013/07/spring-jta-multiple-resource-transactions-in-tomcat-with-atomikos-example.html

Installed MySQL and manually created the two databases/tables
When importing downloaded maven project to Eclipse Kepler (JEE) got error. Resolved using http://qussay.com/2013/09/13/solving-dynamic-web-module-3-0-requires-java-1-6-or-newer-in-maven-projects/ (need to right click project and do Maven Update Project.) Note: I also checked "Dynamic Web Module" under Project Facets

Added a run configuration with goal "package" per "Cimbom" - http://stackoverflow.com/questions/9665569/where-did-eclipses-run-as-maven-package-go - need to ensure JRE tab is set to JRE of 1.7 (or else get error: "javac: invalid flag: -s" --probably cuz I had workbench default JRE set to 1.5 duh.)
Ran it it produced springexample.war in target folder root.

Click Servers tab and add Tomcat 7, selected it and click start button. That loads the webapp but doesn't create a springexample under Apache not sure why. would need to start Apache manually (from bin dir) and copy the above war file to webapps.
Load localhost:8080/springexample/appServlet and confirm get "Both employees are inserted!" Verify items are added in MySQL Workbench. Test Rollback scenario per article.


Sunday, March 9, 2014

Tomcat OpenShift Projects

Create new Maven Project in Eclipse
On "Select an Archetype" screen, for filter type "webapp"
select "maven-archetype-webapp" under Artifact Id
Enter a group-id and artifact Id and click finish
Delete the project from Eclipse (but not from hard drive)
open command prompt and go to root of new project (where resides pom.xml)
enter: mvn eclipse:eclipse -Dwtpversion=2.0
Import project into eclipse (kepler java EE)
Open Project properties
under Project Facets change java version to match the system (i.e. 1.7)
Add a Tomcat Server to Eclipse
Under Server Locations ensure "use Tomcat installation" is checked
Set Server path to tomcat server e.g. c:\apache-tomcat-7.0.52
Set Deploy path to C:\apps\apache-tomcat-7.0.52\webapps
Open Modules tab and click Add Web Module
Choose the new project and click ok
Expand Servers and Tomcat v7.0 Server
open file tomcat-users.xml
Add to tomcat-users element:

 <role rolename="manager-gui"/>

<role rolename="admin-gui"/>
<user username="admin" password="admin" roles="admin-gui,manager-gui"/> 

click Debug - Tomcat v7.0 Server at localhost
Open localhost:8080 in the browser
click Manager App (and enter credentials)
scroll to your new web app and click it to show your site

Deploy to OpenShift
in command prompt in openshift app dir (with .openshift, deployments, src, etc.) enter:
 git rm -r src/
in xplorer2, select the src folder of the Eclipse maven project in the left pane and in the right pane have the openshift app dir
click copy to, when prompted allow to merge src.
back in cmd, enter 'git add .' then 'git commit -m "blah"' then git push
Load it in the browser e.g. http://jbossas-<your namespace>.rhcloud.com/<warName>/index.jsp
Now you can modify the eclipse project, e.g. add a main.jsp etc (see http://awgtek.blogspot.com/2014/03/deploy-small-java-app-to-openshift.html) and after each test in local tomcat do another Deploy to OpenShift.

Deploy Struts app to OpenShift? No problem. Set up StrutsExample per http://www.mkyong.com/struts/struts-hello-world-example/
follow same instructions as "Deploy to OpenShift" above, i.e. git delete src and copy src folder from the Struts eclipse tested app. THEN make a change to the pom.xml that exists in the openshift app dir copying over the two dependency elements from StrutsExample for org.apache.struts. git add/commit/push. OpenShift will download the dependencies per the maven pom.xml.

Monday, September 9, 2013

Database Modeling / ERwin



In ERwin I found I needed to use the physical view if I wanted to create a join table against the same table for purposes of creating a hierarchy without adding a nullable self-referencing parentId column to the target table. Looks like there are a lot of resources on SQL Hierarchies (http://stackoverflow.com/questions/4048151/what-are-the-options-for-storing-hierarchical-data-in-a-relational-database) So I'll have to study a bit -- not to mention, I'll need to find out whether an ORM like NHibernate will handle it.

Two open source options for data modeling I found are mogwai ER Designer NG and SQL Power Architect.

 Forward engineering to SQL Server 2008 works well in ERwin, except for some quirks: It adds extraneous collation metadata; it forces you to uncheck a lot of options e.g. uncheck Schema Create, uncheck all Trigger checkboxes, and those changes aren't saved between sessions. Looks like you can save an option set though, extra work...

To get crows feet notation, choose Information Engineering instead of IDEF1x in Model properties. I learned that and other stuff from http://www.isqa.unomaha.edu/wolcott/tutorials/erwin/erwin.html

Monday, August 19, 2013

NMock3

Was going to use Visual Studio 2012's new ease-of-use mocking feature, but then discovered they removed the ease-of-use right-click create unit test feature. So I had to do that in Visual Studio 2010 instead, and for mocking used NMock3 which worked beautifully after I followed the example here: http://searchcode.com/codesearch/view/10455162

Sunday, August 11, 2013

ASP.NET MVC 4 plus EF CF Tutorial

followed first three of http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
Provides all the basics on code first migrations and ASP.NET MVC scaffolding

Sunday, July 28, 2013

Jetty Eclipse Tutorial

Following this as exercise: http://docs.codehaus.org/display/JETTY/Importing+Jetty+Source+into+Eclipse
which illustrates the use of the Maven Eclipse Plugin against jetty-6.
but it relies on old files, including cvs.exe. To work around I need to download sources manually via tortoiseSVN from https://svn.java.net/svn/glassfish~v2/trunk/pwc-commons, ./appserv-webtier, etc. directly to targets under modules, e.g. modules/jsp-2.1/target/glassfish, etc.
Then modify modules\jsp-2.1\pom.xml, replacing "extract-src" in ant task element with "update", doing same for jsp-api-2.1 folder. this is to prevent a cvs attempt at a defunct server (i.e. cvs.dev.java.net).