Thursday, December 18, 2008

Setting endpoint for JAXWS ws


TriprequestService service = new TriprequestService();
Triprequest port = service.getTriprequestPort();
BindingProvider bp = (BindingProvider) port;
Map map = bp.getRequestContext();
map.put(BindingProvider.USERNAME_PROPERTY, "shafiek1");
map.put(BindingProvider.PASSWORD_PROPERTY, "password");
map.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://qapo:8888/trex-pn/triprequest");

Setting endpoint for JAX-RPC

stub._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY,
username);
stub._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY,
password);

Thursday, December 4, 2008

Not closing result set can cause leek?

John used http://www.jboss.org/community/docs/DOC-9255 which gave warnings about some result sets not being closed.

Wednesday, December 3, 2008

ContextMenuTablePanel

I created this panel that would show context menus whenever you clicked on a row. It requires that you add the table to the panel, which means the panel becomes the parent. This causes a problem when using the Scrolltable in incubator, as the Scrolltable is a panel which is the parent of the table.

If only there was a right-click listener.

Monday, December 1, 2008

Using Views for Unique Constraint

May not genereate a EntityExistsException, which seems to require with Sql server 2005 a unique key constraint.

Thursday, November 27, 2008

JBoss client jars

Following jars required for ejb client connection

set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jboss-aop-jdk50-client.jar
set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jboss-aspect-jdk50-client.jar
set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jboss-ejb3-client.jar
set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jboss-ejb3x.jar
set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jbossall-client.jar

jndi.properties

java.naming.factory.initial=org.jboss.security.jndi.JndiLoginInitialContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

java.naming.provider.url=qapo:1099
java.naming.security.principal=admin
java.naming.security.credentials=july321

Tuesday, November 25, 2008


When I try to use the "Open Table" feature in SQL Managment Studio
(Standard), I get the following error:

Class does not support aggregation (or class object is remote) (Exception
from HRESULT: 0x80040110 (CLASS_E_NOAGGREGATION))
(Microsoft.SqlServer.SqlTools.VSIntegration)


.. This is a management studio thing - when I opened up from another instance on my machine and connected remotely, I didn't get the problem

Sunday, November 23, 2008

Dual Monitor With Ubuntu

lspci to get the graphics card info (or look it up in /etc/X11/xorg.conf)

There were instructions at:
http://intellinuxgraphics.org/dualhead.html


I had to modify xorg.conf in /etc/X11 so that screen has virtual size big enough to hold both your screen resolutions (for me 2560 x 2048)

then I ran

xrandr --ouput VGA --right-of LVDS

Tuesday, November 18, 2008

GWT - How to change implementation based on properties

In module file:

<define-property name="entryPoint" values="snp,RunManagement,JobTracking">

<replace-with class="au.com.interdev.snp.client.runmgmt.RunManagementUI">
<when-type-is class="au.com.interdev.snp.client.SNPUI">
<when-property-is name="entryPoint" value="RunManagement">
</when-property-is>
</when-type-is></replace-with>
</define-property>

In html file:

<meta name="gwt:property" content="entryPoint=RunManagement">


You can also set the property via some javascript in the module file - see the module file fo i18n

Sunday, November 9, 2008

Web.xml security

http://forums.sun.com/thread.jspa?threadID=5233721

Tuesday, October 7, 2008

Whether to Make Exceptions unchecked

Typically we throw all these BlaUnknown exceptions when creating things.

Like when creating a Device, you need a DeviceType to exist. So the createDevice() method throws a DeviceTypeUnknown exception.

These make method calls very clunky because you have to catch all of these exceptions.

I thought of making them unchecked because you expect these things to exist when you are creating a device, and if they don't, its an internal runtime error.

Shafiek pointed out two reasons against this:
if it does happen, it's could be the result of another user deleting something - in which case this should be conveyed to the current user.

WebServices Need to know what exceptions will be thrwon.

Monday, September 22, 2008

Jars required for jboss ejb client

set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jboss-aop-jdk50-client.jar
set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jboss-aspect-jdk50-client.jar
set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jboss-ejb3-client.jar
set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jboss-ejb3x.jar
set CLASSPATH=%CLASSPATH%;%JBOSS_CLIENT_DIR%\jbossall-client.ja



Jars required for jaxws ws client

set CLASSPATH=%CLASSPATH%;.\jaxws\FastInfoset.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\activation.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\http.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\jaxb-api.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\jaxb-impl.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\jaxb-xjc.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\jaxws-api.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\jaxws-rt.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\jaxws-tools.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\jsr173_api.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\jsr181-api.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\jsr250-api.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\resolver.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\saaj-api.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\saaj-impl.jar
set CLASSPATH=%CLASSPATH%;.\jaxws\sjsxp.jar


set CLASSPATH=%CLASSPATH%;%JBOSS_DIR%\lib\endorsed\xercesImpl.jar
Adding basic authentication to ws client

JAXWS

TriprequestService service = new TriprequestService();
Triprequest port = service.getTriprequestPort();
BindingProvider bp = (BindingProvider) port;
Map map = bp.getRequestContext();
map.put(BindingProvider.USERNAME_PROPERTY, "shafiek1");
map.put(BindingProvider.PASSWORD_PROPERTY, "password");
map.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://qapo:8888/trex-pn/triprequest");


JAXRPC

stub._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY,
username);
stub._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY,
password);

Wednesday, June 18, 2008

wireless security

If wireless is encrypted, does this mean people on the same network as me cannot read the contents of my packets? ie. If I logon to a site that uses basic http security, over an encrypted wireless connection, can other ppl easily see my username and password?

I think that when your wireless connection is encrypted, you have your own encrypted channel. Ie. others logged on to same wireless network cannot read your packets over the air.

Tuesday, May 6, 2008

check if a column exists using sqlserver metadata

if exists ( select * from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME='PTGatewayInBreak' and COLUMN_NAME='Foo' )

alter table PTGatewayInBreak drop column foo

Tuesday, April 29, 2008

Run unit tests before you commit!

Shafiek merged from my RD branch and some unit tests weren't working. I had released without running the unit tests.

Monday, April 21, 2008

Validate documents you give to 3rd partys

Jay from Maximas found one of my documents was invalid according to the schema. This could have been avoided if I had've run all documents I produce through a validator.

Sunday, April 20, 2008

mplayer

mplayer -noframedrop -dumpfile out.rm -dumpstream rtsp://url/to/file.rm

Tuesday, April 15, 2008

Getting jdbc connection from entity manager

org.hibernate.ejb.EntityManagerImpl emImpl = (org.hibernate.ejb.EntityManagerImpl) em;
Connection connection = emImpl.getSession().connection();

Monday, April 14, 2008

Wiring up bi-directional relationship can cause OptimisticLocking exceptions

Shafiek encountered problem whereby there was a bidirectional one-many relationship between LocationType and Location. When he created a location he added the location to the LocationType to "wire-up" the relationship. This adding of location to the locationType's collection caused version number of LocationType to change which then would cause OptimisticLocking exception.

In Hibernate 3.3 there is an enhancement to allow you to specify whether a property triggers an optimistic lock. But since the jboss we are using does not use this hibernate, as a work around we will just not wire up the relationship in the code that adds the location.

http://opensource.atlassian.com/projects/hibernate/browse/ANN-26

Tuesday, April 1, 2008

Non-greedy Quantifiers

Quantifier

Description
\{-}
matches 0 or more of the preceding atom, as few as possible
\{-n,m}
matches 1 or more of the preceding characters...
\{-n,}
matches at lease or more of the preceding characters...
\{-,m}
matches 1 or more of the preceding characters...
where n and m are positive integers (>0)

http://www.geocities.com/volontir/#Non-Greedy

Tuesday, March 25, 2008

Secondary Table not working in EJB

Had a customer and an embedded address. It would not use the EMBEDDED_ADDRESS table, instead it created a column called street in the customer table and used that.


@Entity
@Table(name = "CUSTOMER")
@SecondaryTable(name = "EMBEDDED_ADDRESS", pkJoinColumns = {@PrimaryKeyJoinColumn(name = "addressId")})
public class CustomerBean {

@Id @GeneratedValue(strategy=GenerationType.AUTO)
private int id;
private String name;
private String street;

public CustomerBean(){}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Column(name = "street", table = "EMBEDDED_ADDRESS")
public String getStreet()
{
return street;
}

public void setStreet(String street) {
this.street = street;
}



}

Setting up Cygwin

Set home location by set HOME=E:\cygwinhome in cygwin.bat

Make it run you .bashrc every time you start a cygwin shell by creating a file .bash_profile with the following

case $- in
*i*) [ -f ~/.bashrc ] && [ -r ~/.bashrc ] && . ~/.bashrc
esac

from http://www.issociate.de/board/post/397417/Cygwin_Bash_problem.html

Friday, March 14, 2008

Configure sql server 2005 express to allow TCP/IP connections

http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx

Tuesday, January 29, 2008

What is ENC

There is a difference between component namespace and appserver (global) namespace.

Each "component" has it's own ENC at java:/comp/env

When it declares a dependency, it binds it to a name in here, eg. java:/comp/env/ejb/SomeEJB
It looks it up using this name. It is up to the deployer to bind this name with the global appserver name of the required resource eg below of a sun-web.xml. The resource could physically be in another server.


jdbc/FooDS -- relative to java:/comp/env
jdbc/OracleDS -- global jndi name


They say directo global lookups are not portable because appserver global namespace is implementation-specific.

Mappend name in @Resource annotation is the global jndi name (gets rid of need for sun-web.xml). Name (has a default of classname/fieldname) is the name in java:comp/env

If you don't suppy a mappedname, and don't provide a mapping in xml, it will look up global jndi name which is the same as the resource dependency's name in java:comp/env

https://glassfish.dev.java.net/javaee5/ejb/compdependencies_xmlforum_nov15.pdf

Monday, January 28, 2008

Stick to commen-sense conventions

I implemented an update by deleting and recreating an entity, thinking this would have no consequences (mainly because the weak foreign keys stayed the same and I expected access would happen through these keys). But I added another independent guid, and then there was a problem that because the guid changed, a client could no longer retrieve the object.

Wednesday, January 23, 2008

XCS clustering problem

XCS wasn't responding. Logs showed things about GMSImpl, wrongMethod() suspect(). It was trying to join cluster but something was going wrong.

Removing XmotionSessionCache-service.xml stoppedt his.

Thursday, January 17, 2008

java.lang.OutOfMemoryError: PermGen space

Monitor memory sizes through jboss by invoking listMemoryPools() of ServerInfo jmx object in the jmx-console

Tuesday, January 15, 2008

wire up your relationships!

Again I got caught by not wiring up my ejb bidirectional relationships. As an example I had GeoFence (gf) and GeoFenceDataSet (ds). gf has one ref to ds and ds has lazy collection of gf's.

I never understood why I need to do a ds.getGeoFences().add(gf). I thought this should be magically looked after whenever I create a gf with gf.setDataSet(ds). In particular what I saw was, I would do the following within a transaction

em.persist(gf)
em.flush()

and then

for (gf : ds.getGeoFences() )

in a separate transaction. Since my collection was lazy-loaded, I expected the newly added gf to be in that collection, since it should have been loading the collection from the database, but it didn't. It looks like the entity manager knows whether to read in collection or not. It seems to keep track of the ds verison number and the last gf id it should know about.

Sunday, January 13, 2008

sql server and collation

http://www.databasejournal.com/features/mssql/article.php/10894_3302341_2
http://blogs.msdn.com/michkap/archive/2005/11/08/490305.aspx
http://www.madprops.org/cs/blogs/mabster/archive/2007/07/02/sql-collation-made-easy.aspx

Default collation depends on how sql server was installed.

Looks like SQL collations were just for sql server, and windows collations are for the whole of windows.