Open Office - Unsatisfied Link Error


2008-06-09 Digg! icurtain Delcious icurtain Technorati icurtain


when running open office from a bootstrap routine or in headless mode for batch processing make sure the following settings to avoid an unsatisfied link error

soffice -accept="pipe,name=my_app;urp;"
java -Djava.library.path=/opt/openoffice.org/program java.app.class

useful reference on Oo: http://www.oooforum.org/forum/viewtopic.phtml?t=40263


java - find a number in a string


2008-05-07 Digg! icurtain Delcious icurtain Technorati icurtain


Pattern p = Pattern.compile("[0-9]");

Matcher m = p.matcher("asdas12dsad");

System.out.println(m.find());


http://kb.mozillazine.org/Browser.cache.disk_cache_ssl


2008-04-18 Digg! icurtain Delcious icurtain Technorati icurtain


http://kb.mozillazine.org/Browser.cache.disk_cache_ssl

EJB3 EntityManager Find


2008-03-06 Digg! icurtain Delcious icurtain Technorati icurtain


@In("myEntityManager")
private EntityManager em;

...

MyObject myObject = em.find(MyObject.class, myObjectPrimaryKey);


java.sql.SQLException: User not found: SA [SOLVED]


2008-03-05 Digg! icurtain Delcious icurtain Technorati icurtain


WARN [org.jboss.system.ServiceController] Problem starting service jboss:service=Hypersonic,database=localDB
java.sql.SQLException: User not found: SA

It's possible that your jboss deployment has gone a bit squiffy.. try deleting the following:
jboss/server/default/tmp
jboss/server/default/data
jboss/server/default/work


Exception creating identity: domainName


2008-02-13 Digg! icurtain Delcious icurtain Technorati icurtain


caused by: java.lang.RuntimeException: Exception creating identity: domainName

Solution

your computer can't find itself

go to:

etc/hosts
make sure the loopback address refers to the name of the box you are running on ie
127.0.0.1 documentationServerBox localhost.localdomain localhost

for other information on linux network configs look at the redhat linux network guide


SecPay Enumerated Type


2007-12-07 Digg! icurtain Delcious icurtain Technorati icurtain


public enum SecpayErrorType {

authorised ("Transaction authorised by bank. auth_code available as bank reference"),

notAuthorised ("Transaction not authorised. Failure message text available to merchant"),

commsProblem ("Communication problem. Trying again later may well work"),

fraud ("The SECPay system has detected a fraud condition and rejected the transaction. The message field will contain more details."),

amountInvalid ("Pre-bank checks. Amount not supplied or invalid"),

insufficientParams ("Pre-bank checks. Not all mandatory parameters supplied"),

paymentRepresented ("Pre-bank checks. Same payment presented twice"),

startInvalid ("Pre-bank checks. Start date invalid"),

expireInvalid ("Pre-bank checks. Expiry date invalid"),

issueInvalid ("Pre-bank checks. Issue number invalid"),

LUHNFailed ("Pre-bank checks. Card number fails LUHN check"),

cardTypeInvalid ("Pre-bank checks. Card type invalid - i.e. does not match card number prefix"),

nameInvalid ("Pre-bank checks. Customer name not supplied"),

merchantInvalid ("Pre-bank checks. Merchant does not exist or not registered yet"),

merchantAccountCardTypeInvalid ("Pre-bank checks. Merchant account for card type does not exist"),

merchardAccountCurrencyTypeInvalid ("Pre-bank checks. Merchant account for this currency does not exist"),

CVV2Invalid ("Pre-bank checks. CVV2 security code mandatory and not supplied / invalid"),

timeOut ("Pre-bank checks. Transaction timed out awaiting a virtual circuit. Merchant may not have enough virtual circuits for the volume of business."),

noMD5 ("Pre-bank checks. No MD5 hash / token key set up against account");

private final String description; // constructor

SecpayErrorType(String description) {

this.description = description;

}

public String getDescription(){

Runnable r = new Runnable() {

public void run(){

}

};

Runnable s = new MyRunnable();

return description;

}

private class MyRunnable implements Runnable {

public void run(){

}

}

}


Tag Library Descriptor - TLD files for Java Editors


2007-12-04 Digg! icurtain Delcious icurtain Technorati icurtain


xmlns:s="http://jboss.com/products/seam/taglib"
seam-ui.tld
xmlns:ui="http://java.sun.com/jsf/facelets"
jsf-ui.tld
xmlns:f="http://java.sun.com/jsf/core"
myfaces_core.tld
xmlns:h="http://java.sun.com/jsf/html"
myfaces_html.tld
xmlns:rich="http://richfaces.ajax4jsf.org/rich"
rich.tld
xmls:a4j="https://ajax4jsf.dev.java.net/ajax"
a4j.tld

Java For Loop


2007-12-03 Digg! icurtain Delcious icurtain Technorati icurtain


for (OrderTransaction orderTransaction : secPayResultList) {

for(Payment payment : orderTransaction.getPayments()){

if(PaymentMethodType.CARD.equals(payment.getMemberPaymentMethod().getPaymentMethod().getType())){

//do a transaction in here

ValidateTransactionResult validateTransactionResult = doSecPayTransaction(payment.getReference());

if (validateTransactionResult.getValid() != true) { FacesMessages.instance().add("TransactionResult: " + validateTransactionResult.getMessage()) ;

}

}

}

}


Midas-Iflow CVS


2007-11-22 Digg! icurtain Delcious icurtain Technorati icurtain


Check out as a project configure using the new project wizard
_> Head
-> java
-> java project

iFlow

libs - add all
order & export - select all


Midas
projects - add iflow

Tomcat Installation and Setup on Windows


2007-09-13 Digg! icurtain Delcious icurtain Technorati icurtain


  1. make sure the file msvcr71.dll is present in the system path 
  2.  
  3. intall java jre 
  4. install tomcat 
  5.  
  6. copy the deployment directory onto the local drive 
  7.  
  8. edit: 
  9.  
  10. ..\Apache Software Foundation\Tomcat 6.0\conf\server.xml 
  11.  
  12. to include the deployment path to the application 
  13.  
  14. this looks like this and should sit inside the following heirachy within the xml document 
  15.  
  16. <Server> 
  17.    <Service> 
  18.       <Engine> 
  19.          <Host> 
  20.             <Context path="/Project" reloadable="true" docBase="C:\Project" workDir="C:\Project\work" /> 
  21.          </Host> 
  22.       </Engine> 
  23.    </Service> 
  24. </Server> 
  25.  
  26. edit: 
  27.  
  28. ..\Project\WEB-INF\web.xml 
  29.  
  30. to make sure the logging directories are set up correctly etc (packages etc) 
  31.  
  32. launch tomcat and deploy the project from the project manager 
  33.  
  34. it should now be available at http://localhost:8080 
  35.  
  36. run emulate from the run.bat batch file - making sure its pointing to the right target within the batch file 
  37.  

Tomcat prunsrv.c javajni.c [error] - Service Error


2007-09-13 Digg! icurtain Delcious icurtain Technorati icurtain


When tomcat generates something similar to the following log output chances are its missing the Windows C dll MSVCR71.dll - Tomcat needs this to initialise java when the service starts. Put a copy in your c:\windows\system32 directory or wherever you want as long as its in your system path

[2007-09-13 04:12:54] [info] Running Service...
[2007-09-13 04:12:54] [info] Starting service...
[2007-09-13 04:12:54] [173 javajni.c] [error] The specified module could not be found.
[2007-09-13 04:12:54] [924 prunsrv.c] [error] Failed creating java C:\Program Files\Java\jre1.6.0_02\bin\client\jvm.dll
[2007-09-13 04:12:54] [1179 prunsrv.c] [error] ServiceStart returned 1
[2007-09-13 04:12:54] [info] Run service finished.
[2007-09-13 04:12:54] [info] Procrun finished.


Copy a file in Java


2007-09-12 Digg! icurtain Delcious icurtain Technorati icurtain


public static void copyFile(String sourceFile, String filePath, String destinationFile) {

try {
FileInputStream streamSource = new FileInputStream(sourceFile);
FileOutputStream streamDest = new FileOutputStream(filePath + destinationFile);

byte[] buffer = new byte[1024];
int i = 0;
while ((i = streamSource.read(buffer)) != -1) {
streamDest.write(buffer, 0, i);
}
streamSource.close();
streamDest.close();

} catch (IOException e) {
// LOG.debug("file(input|output)stream error: " + e);
}


Simple Regex replace in java and Striptags


2007-08-20 Digg! icurtain Delcious icurtain Technorati icurtain


replacing two chars using an or (pipes)

String p = "text to search.. through with = and , and ^

regex

";

System.out.println("result: "+ p.replaceAll(",|=", "") );

if you want to strip all the tags out you can use:

System.out.println("p: "+ p.replaceAll("\\W", " ") );

note.. that will strip spaces too hence we are replacing with " "

to strip tags properly and remove what's between them use

System.out.println("p: "+ p.replaceAll("<[^>]+>", "") );