Monday, August 06, 2012

Data Source Configuration in JBoss AS 7 (MySQL)

I have tried to configure Data Source in JBoss for about 5 hrs now - With this being the only solution.

Solution
Simply replace the contents of the module/com/mysql/main with the contents of this tar file.
https://community.jboss.org/wiki/DataSourceConfigurationInAS7


The trick is that an index file needs to be present ..and for some reason its married the version of the jar.
Its suppose to be auto-generated by JBoss when you start the AppSever.


But on my MacAir - It never happened.

Is it a permissions issue?
Is it an OS issue?
Or is there something else I am missing here??

$ 1M  - to anyone that can explain this anomaly!! *wink*

Sunday, August 05, 2012

Why not to use Apache OpenJPA?

After doing a lot of analysis and sandboxing I realized that there are some issues with implementing OpenJPA in a WebApplication.

First issue was implementing HSQL - Problem: It always fails complaining about java-heap-size.
Even when this was increased.

Second issue was encountered when using MySQL: - OpenJPA now needs javaagent...

http://stackoverflow.com/questions/2127263/openjpa-on-java-se

No too sure on why..

Moving to Hibernate JPA.

Friday, August 03, 2012

Setup HSQLDB on MAC

1.  Start the Server


Hsqldb Server

This is the preferred way of running a database server and the fastest one. A proprietary communications protocol is used for this mode. A command similar to those used for running tools and described above is used for running the server. The following example of the command for starting the server starts the server with one (default) database with files named "mydb.*".
    java -cp ../lib/hsqldb.jar org.hsqldb.Server -database.0 file:xdb -dbname.0 xdb
The command line argument -? can be used to get a list of available arguments.

Note that both "xdb" is used for both File and database name.


2. Start the DB Manager Swing application

Running Tools

All tools can be run in the standard way for archived Java classes. In the following example the AWT version of the Database Manager, the hsqldb.jar is located in the directory ../lib relative to the current directory.
    java -cp ../lib/hsqldb.jar org.hsqldb.util.DatabaseManager
If hsqldb.jar is in the current directory, the command would change to:
    java -cp hsqldb.jar org.hsqldb.util.DatabaseManager
Main classes for the Hsqldb tools
  • org.hsqldb.util.DatabaseManager
  • org.hsqldb.util.DatabaseManagerSwing
  • org.hsqldb.util.Transfer
  • org.hsqldb.util.QueryTool
  • org.hsqldb.util.SqlTool



3. Setup the tool to Connect to the HSQL DB



Use these setting in the connection to setting to run the server.



4. Start the DB Manager Swing application

HSQL needs to be setup in JPA persistence.xml to perform connections.


<persistence-unit name="Stocks" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>nJTA</non-jta-data-source>
        <class>net.vinant.db.Stock</class>
        <properties>
        <!-- jdbc:hsqldb:mdb -->
        <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:hsql://localhost/mdb" />
        <property name="javax.persistence.jdbc.user" value="SA"/>
        <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(SchemaAction='add', ForeignKeys=true)"/>
<property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/>        
     <property name="openjpa.jdbc.DBDictionary" value="hsql" />
<property name="openjpa.jdbc.Schema" value="PUBLIC" />
        </properties>   
    </persistence-unit> 
</persistence>



Enjoy!


Thursday, February 10, 2011

GWT Tomcat Integration - Making Google Web toolkit work with Apache Tomcat

This is my quick and easy way to make GWT work with Tomcat.

Ingredients:
  • GWT on Eclipse
  • Apache Tomcat (I have 5.5.26)
Lets create a new GWT Project called "test".

Also download and copy the "tomcat-gwt.xml" to the "test" Project directory.
Edit the tomcat-gwt.xml files and add your project specific settings.

    <property name="tomcat.webapps" value="C:\apache-tomcat-5.5.26\webapps" />
    <property name="project.name" value="test" />   

Change the above settings to your specific settings.

Now add this builder to your project.
Right Click Project ("test") >>  Properties >> Builders
Select import to add the XML.

Make sure the tasks are selected as displayed below.


The application is deployed to tomcat everytime you do a "CLEAN".

Contents of "tomcat-gwt.xml"

<?xml version="1.0" encoding="UTF-8"?>
<project name="Tomcat-GWT" default="copy" basedir=".">
    <property name="tomcat.webapps" value="C:\apache-tomcat-5.5.26\webapps" />
    <property name="project.name" value="test" />       
    <property name="source.dir" value="${basedir}\war" />
    <target name="copyx">
        <echo>${source.dir}</echo>
        <echo>${tomcat.webapps}</echo>
    </target>
    <target name="copy">
        <mkdir dir="${tomcat.webapps}\${project.name}" />
        <copy todir="${tomcat.webapps}\${project.name}">
            <fileset dir="${source.dir}" includes="**/**" />
        </copy>
    </target>
</project>

Friday, January 28, 2011

Websphere - XA Transaction Error

Problem
[1/28/11 18:26:02:109 EST] 00000014 XARminst      E   WTRN0037W: The transaction service encountered an error on an xa_recover operation. The resource was com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl@51ef51ef. The error code was XAER_RMERR. The exception stack trace follows: javax.transaction.xa.XAException
    at oracle.jdbc.xa.OracleXAResource.recover(OracleXAResource.java:526)
    at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.recover(WSRdbXaResourceImpl.java:962)
    at com.ibm.ws.Transaction.JTA.XARminst.recover(XARminst.java:137)
    at com.ibm.ws.Transaction.JTA.XARecoveryData.recover(XARecoveryData.java:690)
    at com.ibm.ws.Transaction.JTA.PartnerLogTable.recover(PartnerLogTable.java:512)
    at com.ibm.ws.Transaction.JTA.RecoveryManager.resync(RecoveryManager.java:1949)
    at com.ibm.ws.Transaction.JTA.RecoveryManager.run(RecoveryManager.java:2457)
    at java.lang.Thread.run(Thread.java:832)


Solution


http://www.coderanch.com/t/414861/EJB-JEE/java/Help-XAException
http://www.ibm.com/developerworks/websphere/library/techarticles/0407_woolf/0407_woolf.html

Thursday, August 26, 2010

Could not inspect JDBC autocommit mode

Could not inspect JDBC autocommit mode

JPA and EJB3 Caveats - I

javax.persistence.PersistenceException: [PersistenceUnit: UnitName] class or package not found

WARN [ServiceController] Problem starting service persistence.units:ear=

If you get the above warning followed by the exception in the title, check your persistence.xml, some of the entity classes maybe declared wrong (e.g. point to wrong package).


JPA/EJB 3 Setup on Eclipse

Make sure that the persistence.xml file is located in the META-INF of the EAR Project.
Having it in your JPA project does NOT automatically propogate this file to where it needs to be.

Tuesday, August 10, 2010

Quotes

Optimist/Pessimist
The optimist live in the peninsula of infinite possibilities, where as the pessimist is stranded on an island of perpetual indecision.

Saturday, May 29, 2010

Virtual Memory arguments for Eclipse

On Windows:


C:\eclipse\eclipse.exe -data c:\MyWorkspace -vmargs -Xms128M -Xmx256M


Workspace location = MyWorkspace
Starting memory = 128 mb
Maximum memory = 256 mb



Monday, February 15, 2010

C++ Listing all Directories in a Folder.

View the contents of a directory

This is how you get the contents of a directory in Windows with C++.

#include 
#include 

using namespace std;

int main()
{
WIN32_FIND_DATA FindFileData; 
HANDLE hFind = INVALID_HANDLE_VALUE; 
char DirSpec[MAX_PATH]; // directory specification 

cout<<"Path: ";
cin.get(DirSpec, MAX_PATH);
cout<<"\n";
strncat(DirSpec, "\\*", 3);
hFind = FindFirstFile(DirSpec, &FindFileData);

 if(hFind == INVALID_HANDLE_VALUE)
 {
 cout<<"Error: invalid path\n";
 }

cout<<<"\n";

 while(FindNextFile(hFind, &FindFileData) != 0)
 {
 cout<<<"\n";
 }

FindClose(hFind);

return 0;
}