Tuesday, December 09, 2008

Weblogic states

WE had a question on our weblogic status recently. SOme libraries were listed as been in the "Installed" state, as opposed to the usual "Active" state.

Heres a breakdown on the various states in Bea Weblogic:

1. There is no valid deployment state as "Installed".

2.. The deployment state is stored in "weblogic.management.runtime.AppRuntimeStateRuntimeMBean". As per the documentation these are the states:
STATE_ACTIVE, STATE_ADMIN, STATE_FAILED, STATE_NEW, STATE_PREPARED, STATE_RETIRED, STATE_UPDATE_PENDING
This is the link to documentation: http://e-docs.bea.com/wls/docs90/javadocs_mhome/weblogic/management/runtime/AppRuntimeStateRuntimeMBean.html

3. You can also check this runtime MBean on the MBean Reference: http://e-docs.bea.com/wls/docs92/wlsmbeanref/core/index.html

4. I got some known issues where it is stated that "Installed" is a console text string that indicates the LibraryMBean is present in the configuration.The Installed state can be changed by rebooting the domain. The problem can happen unexpectedly. Also the library works fine with Installed state as well.

5. It may be possible that the console is picking up a wrong state for the deployment.

6. We can verify this by using WLST to reach the AppRuntimeStateRuntimeMBean and then get the status.
i) First access the DomainRuntimeMBean using the following link: http://e-docs.bea.com/wls/docs92/config_scripting/nav_edit.html#wp1001225
ii) The DomainRuntimeMBean has the handle to AppRuntimeStateRuntimeMBean. Please check the API docs for the method getAppRuntimeStateRuntime(): http://e-docs.bea.com/wls/docs92/javadocs_mhome/weblogic/management/runtime/DomainRuntimeMBean.html
iii) Then get the module IDs and then access the status using AppRuntimeStateRuntimeMBean.getCurrentState(..).

Please let me know what are the results of this test.

Moreover this seems to be a non-reproduceable issue as we can see this occurs only in Production but not in Test.

Please let me know whether the provided information is sufficient. Also let me know if you face any problems in testing the deployment status using WLST.

Monday, December 01, 2008

svn externals

It often useful to link to an external resource within a svn project.

for instance you may store Wsdl and Xsd files in one location, but your implementation code may need to access it. You don't want to copy and paste it since you will end up with 2 copies to maintain.

for these cases you can use svn externals to link to an external svn directory (note only directories can be linked to, not individual files)

e.g. (I set svn:externals via eclipse)

Use Team> Set Property > [select svn:externals]
Enter the name of the directory link you want, (a revision number if required, e.g. -r123), followed by the remote directory to link to.

wsdl [-r rev] http://svnHost/repos/trunk/MyProject/myDir1/wsdl

xsd [-r rev] http://svnHost/repos/trunk/MyProject/myDir1/xsd

SVN Ignore
Svn can be instructed to ignore certain files etc.

For example when working with eclipse projects you will want to specify that .classpath, and .project files will not be included in svn, checkin's or diff's.

Ignores can be setup globally or per directory.

Global
This can be done via eclipse (in the windows/ preferences/ Team control),

or find your subversion config file. e.g. ~/.subversion/config then edit the following line, e.g.

global-ignores = .project .claspath *.o *.lo *.la #*# .*.rej *.tmproj

Local
cd to project directory,
svn propset svn:ignore "target/*

This should ignore the target directory (e.g. for maven builds)

Wednesday, November 19, 2008

ALSB install problems

On of our servers was throwing up an exception, while trying to start the Adminserver

####<19-Nov-2008 16:17:22 o'clock GMT> <Critical> <WebLogicServer> <vmmiddleware06> <AdminServer> <Main Thread> <<WLS Kernel>> <> <> <1227111442502> <BEA-000386> <Server subsystem failed. Reason: java.lang.NumberFormatException: null
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:415)
at java.lang.Integer.parseInt(Integer.java:497)
at weblogic.ldap.EmbeddedLDAP.validateVDEDirectories(EmbeddedLDAP.java:1035)
at weblogic.ldap.EmbeddedLDAP.start(EmbeddedLDAP.java:212)
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)

The solution appears to be
"This usually happens if your machine is running low on space and WebLogic Server corrupted a file in the embedded LDAP.
To fix this problem you can delete the file /servers//data/ldap/config/replicas.prop or add 'replica.num=0' to replicas.prop file. "


Thanks to the following link
http://satya-ghattu.blogspot.com/2008/10/number-format-exception-while-starting.html

Thursday, September 25, 2008

Search jar files for class

Heres a handy little command for searching classes withen jar files (for example when searching all the jars in a war file)

find <dirs> -name '*.jar' -exec jar tvf {} \; > outputfile

THis will produce a list of all files in the jar files outputted to outputfile.

This script below will print out the filename of each jar, and each associated file within.


list=$(find /apps/bea -print | grep .jar)

for el in $list; do

printf "Searching in %s\n" "$el";

case $el in

jar -tf $el | grep com.bea.console.utils.ConsoleRequestListener

;;

esac

done

Thursday, August 07, 2008

Jaxb Multiple namespace definitions

I was mildly concerned about the number of namespace definitions that Jaxb was printing every time it marshaleld an Xml document.

I'm using Spring-ws with jaxb bindings. In my definition of the Spring Marshaller I declare the jaxb packages which this marshaller will marshall. Each of these is turned into a namespace definiton on the resulting xml doc.

<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.company.package1:com.company.package2:com.company.package3:com.company.package4">
</property>
</bean>

Results in

<ns1:request ns1="http://www.company.com/Package1" ns2="http://www.company.com/Package2" ns3="http://www.company.com/Package3" ns4="http://www.company.com/Package4">
<ns1:data>text
</ns1:data>
</request>

This was mildly irritating.

After a bit of searching I find its a 'performance feature' in Jaxb2

https://jaxb.dev.java.net/issues/show_bug.cgi?id=103

So they won't be fixing it.

The alternative from my point of view is to declare multiple marshallers, and use them where appropriate.

<bean id="jaxb2Marshaller1" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.company.package1">
</property>
</bean>
<bean id="jaxb2Marshaller2" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.company.package2">
</property>
</bean>
..etc..

Tuesday, August 05, 2008

Python gotcha

This Seemingly innocuous indentation error in python was annoying me.

Problem invoking WLST - Traceback (innermost last):
(no code object) at line 0
File "C:\apps\installWls.py", line 249
toDeploy = sys.argv[3]
^
SyntaxError: inconsistent dedent

Looking at my code (wlst code to auto deploy application into weblogic server), it was all indented correctly.

Well of course the computer was right. It wasn't indented correctly, but it was no obvious.

The issue was some copy and paste code I took from the internet.

It was indented using spaces, whereas I was using tabs.

Replacing the space indentation with tabs fixed the issue (but its not obvious uinless you set your editor to display non visible characters.

Tuesday, July 29, 2008

StackoverFlow using spring-ws on weblogic 9.2


We finally got our spring-ws application deployed.

Or so we thought. The next day when we arrived int he code was crashing, and the JMS queue was not been read....

The img to the right shows the non-heap memory growth. Something is not clearing.

Below is the stack trace we get





Edit

Two things to check that might help: (I have not been able to test this now, as I no longer work on this project or for this client.)

* Make sure that you haven't somehow configured a foreign JNDI or foreign JMS server that is self referencing.

* Make sure that you haven't specified a URL when there's no need to specify a URL. (Server side applications and configuration should never specify a URL for a resource unless the resource is in a different cluster. When a resource is located in the same cluster, JNDI lookups should simply be made directly in the cluster's JNDI name-space. The way to ensure that the lookup is direct is simply to use initial contexts that were created without an URL.)

http://forums.oracle.com/forums/message.jspa?messageID=2675334#2675334




10:12:31 INFO [org.springframework.jms.listener.DefaultMessageListenerContainer
] - Successfully refreshed JMS Connection
10:12:31 DEBUG [org.springframework.jndi.JndiTemplate] - Looking up JNDI object
with name [java:comp/env/jms.queue.provisioning.request]
10:12:36 INFO [org.springframework.jms.listener.DefaultMessageListenerContainer
] - Setup of JMS message listener invoker failed - trying to recover
java.lang.StackOverflowError
at java.lang.String.indexOf(String.java:1564)
at java.lang.String.indexOf(String.java:1546)
at weblogic.jndi.internal.AbstractURLContext.removeURL(AbstractURLContext.java:24)
at weblogic.jndi.factories.java.javaURLContextFactory$JavaURLContext.rem
oveURL(javaURLContextFactory.java:130)
at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.j
ava:130)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyCo
ntextWrapper.java:45)
....
at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.j
ava:130)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyCo
ntextWrapper.java:45)



It appears that the first exception thrown is

2008-07-26 00:14:08,679 DEBUG org.springframework.jms.listener.DefaultMessageListenerContainer - Consumer [weblogic.jms.client.WLConsumerImpl@14f7bad] of session [weblogic.jms.client.WLSessionImpl@15015db] did not receive a message
2008-07-26 00:14:08,696 INFO org.springframework.jms.listener.DefaultMessageListenerContainer - Setup of JMS message listener invoker failed - trying to recover
weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-11D22EBAEF18F82704CC:error resuming transacted session's internal transaction
at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:61)
at weblogic.jms.client.JMSSession.receiveMessage(JMSSession.java:797)
at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:579)
at weblogic.jms.client.WLConsumerImpl.receive(WLConsumerImpl.java:167)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:404)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:285)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:944)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:874)
at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61)
at weblogic.work.j2ee.J2EEWorkManager$WorkWithListener.run(J2EEWorkManager.java:259)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-11D22EBAEF18F82704CC:error resuming transacted session's internal transaction
at weblogic.jms.frontend.FESession.transactedException(FESession.java:2024)
at weblogic.jms.frontend.FESession.throwTransactedException(FESession.java:2039)
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2140)
at weblogic.jms.frontend.FEConsumer.receive(FEConsumer.java:527)
at weblogic.jms.frontend.FEConsumer.invoke(FEConsumer.java:780)
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:759)
at weblogic.messaging.dispatcher.DispatcherServerRef.invoke(DispatcherServerRef.java:276)
at weblogic.messaging.dispatcher.DispatcherServerRef.handleRequest(DispatcherServerRef.java:141)
at weblogic.messaging.dispatcher.DispatcherServerRef.access$000(DispatcherServerRef.java:36)
at weblogic.messaging.dispatcher.DispatcherServerRef$2.run(DispatcherServerRef.java:113)
... 2 more
Caused by: javax.transaction.InvalidTransactionException: Attempt to resume an inactive transaction: BEA1-11D22EBAEF18F82704CC
at weblogic.transaction.internal.TransactionManagerImpl.resume(TransactionManagerImpl.java:360)
at weblogic.transaction.internal.ServerTransactionManagerImpl.resume(ServerTransactionManagerImpl.java:356)
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2085)
... 9 more
2008-07-26 00:14:08,709 INFO org.springframework.jms.listener.DefaultMessageListenerContainer - Successfully refreshed JMS Connection
2008-07-26 00:14:08,713 DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/meteor.jms.queue.provisioning.request]
2008-07-26 00:14:13,758 INFO org.springframework.jms.listener.DefaultMessageListenerContainer - Setup of JMS message listener invoker failed - trying to recover
java.lang.StackOverflowError
at java.lang.String.indexOf(Ljava.lang.String;I)I(Unknown Source)
at java.lang.String.indexOf(Ljava.lang.String;)I(Unknown Source)
at weblogic.jndi.internal.AbstractURLContext.removeURL(AbstractURLContext.java:24)

Wednesday, June 18, 2008

Spring-ws and weblogic incompatibilities

I wrote about incompatible versions of spring before resulting in cryptic error messages.

Well my solution there wasn't the full picture, if you are running xml /web servicse on weblogic. (Though at least this time I recognised the error as incompatible jars)

I was getting various different non-intuitive errors when trying to run a spring-ws application on weblogic 9.2.1.

e.g.
<User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webServiceTemplateProxy' defined in class path resource [com/meteor/provisioning/servicecategory/serviceBeansSpringConfig.xml]: Cannot resolve reference to bean 'webServiceTemplate' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean withname 'webServiceTemplate' defined in class path resource [com/meteor/provisioning/servicecategory/serviceBeansSpringConfig.xml]: Cannot resolve reference to bean 'messageFactory' while setting bean property 'messageFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'messageFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.support.AopUtils.getTargetClass(Ljava/lang/Object;)Ljava/lang/Class;.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webServiceTemplateProxy' defined in class path resource [com/meteor/provisioning/servicecategory/serviceBeansSpringConfig.xml]: Cannot resolve reference to bean 'webServiceTemplate' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creatingbean with name 'webServiceTemplate' defined in class path resource [com/meteor/provisioning/servicecategory/serviceBeansSpringConfig.xml]: Cannot resolve reference to bean 'messageFactory' while setting bean property 'messageFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception isjava.lang.NoSuchMethodError: org.springframework.aop.support.AopUtils.getTargetClass(Ljava/lang/Object;)Ljava/lang/Class;
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1244)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
Truncated. see log file for complete stacktrace

or

java.lang.NoClassDefFoundError: org/apache/axiom/soap/SOAPFactory

After a lot of effort and with help from various postings (namely here, and here ), I managed to track down the various xml jars I needed to override weblogics internal jars.

These include the following taken from my maven pom.xml file. (Note I can't guarantee that this is the full list, or that this list does not contain jars that are in fact not needed. All I can say is that this list worked for me). BTW some of these I had to manually install in my maven repository myself, as I couldn't find them on remote repositories.

<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-dom</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>apache-xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.3.03</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
<version>3.2.6</version>
</dependency>


The problem is with weblogic (various versions, 9.2, 9.2.1, 8.1, and I believe 10) and spring-ws. Weblogic comes with various xml libraries, most of which have been superseded by newer versions. Spring-ws requires some of these newer jars (e.g. saaj, and axiom), which in turn refer to newer versions of base xml libraries. Thus you have an incompatibility.


Also from Arjens post you need to update your weblogic.xml file, adding the following, to instruct weblogic to take the supplied files before already installed files int he weblogic system
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>


BTW I was only able to finally fix the problem by firstly deploying it on Tomcat.

The above example works much easier in Tomcat, since it doesn't have any conflicting xml libraries causing grief. By actually getting the application running in tomcat, I was able to (relatively) quickly find out which jars I needed.

Tomcat would throw a NoClassDefFound exception when it came across a jar it didn't have. This doesn't happen in weblogic since it has xml jars, just the wrong versions. Once I had the application running in tomcat, I knew I had found all the required jars. When I moved it back to weblgoic the problem was solved.

Note: unlike Ajens post, I required saaj1.3 in my WEB-INF/lib folder

Actually I wasn't quite there yet, (see next post), but I this had finally sorted out this problem

Failure executing javac

There's nothing quite so deflating as seeing a message like the following

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
Failure executing javac, but could not parse the error:
An exception has occurred in the compiler (1.5.0_06). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
com.sun.tools.javac.code.Symbol$CompletionFailure: file javax\xml\ws\WebServiceClient.class not found


You really begin to wonder if you're doing something very wrong.
Fortunately you're not, and there is a quick and easy workaround.
This it turns out is a bug with javac on windows

My quick solution. Compile using cygwin. (If you haven't got cygwin, simply download setup.exe, and install)

This worked fine. My details was using jdk 1.5.0_06 (the bug has been reported on 1.5.0_04, and seen on 1.6 as well), on windows xp building using maven 2.0.8. Running my maven script in a cygwin bash window worked fine.

Tuesday, June 10, 2008

spring versions

Beware of mixing tools with different Spring versions.

I was using spring ws 1.5.3, and getting the following error

java.lang.NoSuchMethodError: org.springframework.util.ResourceUtils.toURI(Ljava/net/URL;)Ljava/net/URI;
....

Problem is that I had spring 2.0.x on my path, but spring-ws requires spring 2.5.x

Once I updated to using spring 2.5.x the problem was solved.

Could be a nasty problem, since the error message could easily lead you on a wild goose chase

Friday, June 06, 2008

GSM Codes

GSM codes.

These can be saved in you phonebook/ contacts list for fast access.

Most are obviously selectable by going through your phones menu, but these are much quicker, and I can never find some of them, like call waiting and call hold

Call Divert (all call types)

All
Set: **21*destination#[SEND]
Cancel: ##21#[SEND]
Query: *#21#[SEND]
No Answer
Delay nn seconds: max 30 seconds, in 5 second increments
Set: **61*destination*nn#[SEND]
Cancel: ##61#[SEND]
Query: *#61#[SEND]
Unreachable
Set: **62*destination#[SEND]
Cancel: #62#[SEND]
Query: *#62#[SEND]
Busy
Set: **67*destination#[SEND]
Cancel: ##67#[SEND]
Query: *#67#[SEND]
Cancel All
##002#[SEND]

Divert Voice Calls

All
Set: **21*destination*11#[SEND]
Cancel: ##21*11#[SEND]
Query: *#21*11#[SEND]
No Answer
Delay nn seconds: max 30 seconds, in 5 second increments
Set: **61*destination*11*nn#[SEND]
Cancel: ##61*11#[SEND]
Query: *#61*11#[SEND]
Unreachable
Set: **62*destination*11#[SEND]
Cancel: ##62*11#[SEND]
Query: *#62*11#[SEND]
Busy
Set: **67*destination*11#[SEND]
Cancel: ##67*11#[SEND]
Query: *#67*11#[SEND]

Divert Data Calls

All
Set: **21*destination*25#[SEND]
Cancel: ##21*25 [SEND]
Query: *#21*25#[SEND]
No Answer
Delay nn seconds: max 30 seconds, in 5 second increments
Set: **61*destination*25*nn#[SEND]
Cancel: ##61*25#[SEND]
Query: *#61*25#[SEND]
Unreachable
Set: **62*destination*25#[SEND]
Cancel: ##62*25#[SEND]
Query: *#62*25#[SEND]
Busy
Set: **67*destination*25#[SEND]
Cancel: ##67*25#[SEND]
Query: *#67*25#[SEND]

Divert Fax Calls

All
Set: **21*destination*13#[SEND]
Cancel: ##21*13#[SEND]
Query: *#21*13#[SEND]
No Answer
Delay nn seconds: max 30 seconds, in 5 second increments
Set: **61*destination*13*nn#[SEND]
Cancel: #61*13#[SEND]
Query: *#61*13#[SEND]
Unreachable
Set: **62*destination*13#[SEND]
Cancel: #62*13#[SEND]
Query: *#62*13#[SEND]
Busy
Set: **67*destination*13#[SEND]
Cancel: ##67*13#[SEND]
Query: *#67*13#[SEND]

Divert Line 2 Calls

All
Set: **21*destination*89#[SEND]
Cancel: #21*89#[SEND]
Query: *#21*89#[SEND]
No Answer
Delay nn seconds: max 30 seconds, in 5 second increments
Set: **61*destination*89*nn#[SEND]
Cancel: ##61*89#[SEND]
Query: *#61*89#[SEND]
Unreachable
Set: **62*destination*89#[SEND]
Cancel: ##62*89#[SEND]
Query: *#62*89#[SEND]
Busy
Set: **67*destination*89#[SEND]
Cancel: ##67*89#[SEND]
Query: *#67*89#[SEND]

Call Barring

You use call barring to control what calls can be made or received by your account.

The barring code is specific to the network. Ask your service provider.

Note that Call Barring can't work if call diverts are active, even the autodivert set by the network.

All calls
Set: **330*barring code#[SEND]
Cancel: ##330*barring code#[SEND]
Query: *#330#[SEND]

Outgoing calls
Set: **333*barring code#[SEND]
Cancel: ##333*barring code#[SEND]
Query: *#333#[SEND]

Incoming calls
Set: **35*barring code#[SEND]
Cancel: ##35*barring code#[SEND]
Query: *#35#[SEND]

Outgoing international calls
Set: **331*barring code#[SEND]
Cancel: ##331*barring code#[SEND]
Query: *#331#[SEND]

Outgoing international calls except to home country
Set: **332*barring code#[SEND]
Cancel: ##332*barring code#[SEND]
Query: *#332#[SEND]

Incoming calls when outside home country
Set: *351*barring code#[SEND]
Cancel: #351*barring code#[SEND]
Query: *#351#[SEND]
Cancel All Call Barring
#330*barring code#[SEND]

SMS

There is no provision in the GSM specification for diverting SMS messages

Bar incoming SMS messages
Set: *35*barring code*16#[SEND]
Cancel: #35*barring code*16#[SEND]

Call waiting

Set: *43#[SEND]
Cancel: #43#[SEND]
Query: *#43#[SEND]

Incoming call waiting

Reject: 0 [SEND]
Drop current call and answer: 1 [SEND]
Hold current call and answer: 2 [SEND]

Calling line identity

Outgoing CLI Release (recipient sees your number)
Release: *31# destination [SEND]
Withhold: #31# destination [SEND]
Query default: *#31#[SEND]

Incoming CLI Presentation (you see the caller's number)
Allow: *30#[SEND]
Prevent: #30#[SEND]
Query default: *#30#[SEND]

Dial number from memory

Where nnn is the memory location number
nnn#[SEND]

Change PIN codes

Change Call Barring pin code
**03*oldpin*newpin*newpin#

Change SIM pin code
**04*oldpin*newpin*newpin#

Change SIM pin2 code
**042*oldpin*newpin*newpin#

Unblock SIM pin code
**05*PUK*newpin*newpin#

Unblock SIM pin code
**06*PUK2*newpin*newpin#

Wednesday, May 14, 2008

Maven multiple source directories

By default with maven you can only specify a single source directory. Not very flexible. The following pluggin expands this, allowing you to specify many src dirs.

Heres a sample from the pom.xml

<build>


<build>
   <!-- Replaced with build-helper-maven-plugin below to allow for multiple source directories
       <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
   -->
   <testSourceDirectory>
       ${basedir}/src/test/java
   </testSourceDirectory>
   <plugins>
       <plugin>
           <artifactId>maven-compiler-plugin</artifactId>
           <configuration>
               <source>1.5</source>
               <target>1.5</target>
               <debug>false</debug>
           </configuration>
       </plugin>
       <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>
           <version>1.1</version>
           <executions>
               <execution>
                   <id>add-source</id>
                   <phase>generate-sources</phase>
                   <goals>
                       <goal>add-source</goal>
                   </goals>
                   <configuration>
                       <sources>
                           <source>
                               ${basedir}/src/main/java
                           </source>
                           <source>
                               ${basedir}/src/types/java
                           </source>
                       </sources>
                   </configuration>
               </execution>
           </executions>
       </plugin>
   </plugins>
</build>

Tuesday, May 06, 2008

Why spring rocks in a nuthell

http://www.jroller.com/kdonald/entry/the_essence_of_spring

Injecting enums in Spring beans
Found this while searching for how to insert enums into Spring beans from the xml config file (basically you just put the enum value directly in the xml file, http://www.jroller.com/kdonald/entry/spring_hidden_gem_support_for)

Friday, May 02, 2008

PropertyPlaceholderConfigurer doesn't work with XmlBeanFactory

SImple gotcha.

I was using Spring and the PropertyPlaceholderConfigurer. This simply allows you to populate your spring config file with values from a properties file at runtime. For me the properties file is loaded from the classpath (using the classpath: prefix). this is then stored in a seperate config folder whihc is shared between all projects, thus allowing us to update the config file with needing to redploy the complete application again.

e.g.

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>jms.properties</value>
<ref bean="getNetworkServicePropertyFile" />
</list>
</property>
</bean>
<bean id="test" class="com.meteor.provisioning.Test">
<property name="jmsTemplate" value="${jms.receiveTimeout}" />
</bean>


I write a simple class to instantiate this from a Unit test.


public static BeanFactory getSpringContext() {
springConfigFile = System.getProperty("SpringConfig", springConfigFile);
if (_beanFactory == null) {
Resource resource = new ClassPathResource(springConfigFile);
//_beanFactory = new XmlBeanFactory(resource);
}
return _beanFactory;
}
public static Object getBean(String bean){
return getApplicationContext().getBean(bean);
}

and finally a test case

public class Test {
private String jmsTemplate;

public void setJmsTemplate(String jmsTemplate) {
this.jmsTemplate = jmsTemplate;
System.out.println("jmsTemplate = "+jmsTemplate);
}

@org.junit.Test
public void doTest(){
Utils.getBean("test");
}

}



It didn't work. The PropertyPlaceholderConfigurer, wasn't updating the internal spring file with values from the jms.properties. The jmsTemplate value was been returned as ${jms.receiveTimeout}

Turns out that only ApplicationContext files do the replacement. A quick update to

public static ApplicationContext getApplicationContext() {
springConfigFile = System.getProperty("SpringConfig", springConfigFile);
if (_beanFactory == null) {
_beanFactory = new ClassPathXmlApplicationContext(springConfigFile);
}
return _beanFactory;
}

fixed the problem. Thanks also to http://francisoud.blogspot.com/2007/06/spring-property-placeholder.html

Friday, April 18, 2008

N95

I recently got a N95 8GB.

A list of some of the shortcut keys













CodeResult
*#7370#Reset the phone N.B. This deletes all content off your SiM including Spiderman 3 activation code. Be sure to back it up before hand
*#0000Show phone firmware version.. e.g. my N95 8GB (aka N95-2) is V20.0.016
02-03-08
RM-320
Nokia N95 (01.01)
*#06# IMEI number (International Mobile Equipment Identity)
3 Finger Restart Call (Grenn Key) + * + 3. THen hold down start keyDoes a hard restart. can be used if phone won't start. (Also try removing battery for about 10 seconds. This worked for me)
*#92702689#
Life timer (W A R 0 A N T Y) - The amount of time your phone has spent sending and receiving calls.
*#62209526#Wireless MAC Address
*#2820#Bluetooth MAC address
*#7370# Format phone

Sunday, February 24, 2008

Converting Video and Audio

This is going to be an ongoing article as I try and locate the best free tools for the job.
Good general reference site is Afterdawn, and their forums

Ok firsts.
Copy/ Backup DVD
DVDShrink is an invaluable tool for compressing and copying and backing up DVD's to a directory on your pc. It can copy full DVD, or you can remaster the contents and remove copyright protection notices/ menus/ trailers etc.
There's a handy guide on MrBass

Some newer DVD's have copy protection which DVDShrink can't handle, then DVDDecrypter can sometimes help. If you want to burn the result onto a backup DVD (instead of just storing it on your pc) you probably will still need to run DVDShrink on the ripped files to reduce them enough to fit on your backup DVD. (Unless your DVD burner can burn multi layer)

Burning Images
ISOBurn for buringn images

Video Converting formats

handbrake. This si a great tool (oringally only on Mac, but on Windows and Linux now), for ripping dvd's to mp4, or H264 formats. Doesn't convert formats from what I can see

Super tool for convert all sorts of types

Audio

Switch is a tool. I've just tried to convert 3 mp4's. Converted for 2 of them, didn't work on one.
  • wav (PCM, ADPCM+, aLaw+, uLaw+, and others)
  • mp3 (MPEG Layer 3)
  • mp2+ (MPEG Layer 2)
  • mpga+ (MPEG Audio)
  • au
  • aif/aiff
  • gsm
  • dct
  • vox
  • raw
  • ogg
  • flac
  • amr
  • wma*
  • wmv*
  • aac* (not aacPlus)
  • m4a*
  • mid+
  • act/rcd/rec+ (newer version of format not supported)
  • rm / ra / ram+
  • dvf+ (Not all dvf recorders are supported)
  • msv+ (Not all msv recorders are supported)
  • dss+ (SP Mode only)
  • sri+
  • shn+
  • cda+
  • mov !
  • avi+
  • mpg/mpeg+
  • .m3u+^
  • .pls+^
to any of the following

  • wav (PCM, ADPCM+, aLaw+, uLaw+, and others, see here)
  • mp3
  • au
  • aif/aiff
  • gsm
  • vox
  • raw
  • ogg
  • flac
  • .rss
  • .m3u^
  • .pls^
  • .wpl
  • .amr+
  • aac+
  • m4a+
  • wma+
  • .mov!


Monday, December 10, 2007

Ruby Calnder plugin

New day new problem.

I installed a ruby on rails calendar plugin. Install worked fine. One of the install steps was to run

rake rdoc

This gave me the following problem
rake aborted!
no such file to load -- hoe
C:/dev/ruby/timesheet/vendor/plugins/calendar_helper/rakefile:4
(See full trace by running task with --trace)

Hoe it turns out is a simple ruby project for helping with rakefiles. To install Hoe

gem install hoe
(no need for sudo since I'm on windows)

Now rake rdoc gives me
rake aborted!
couldn't find HOME environment -- expanding `~/.hoerc'
C:/dev/ruby/timesheet/vendor/plugins/calendar_helper/rakefile:7:in `new'
(See full trace by running task with --trace)

This was because I was running on Windows not unix. Setting HOME environment helps this

set HOME=%HOMEPATH%

Now the problem is
rake aborted!
Don't know how to build task 'README'

This as it turns out was a problem with the rakefile. It referred to a non-existant file 'README ' in the plugin. There was however a Readme.txt file. Updating the Rakefile to refer to this finally fixed the issues.


require 'rubygems'
require 'rake'
require 'rake/rdoctask'
require 'hoe'
require './lib/calendar_helper.rb'

Hoe.new('calendar_helper', CalendarHelper::VERSION) do |p|
p.rubyforge_name = 'seattlerb'
p.author = 'Geoffrey Grosenbach'
p.email = 'boss AT topfunky.com'
p.summary = 'Generates a configurable, CSS-tagged HTML calendar.'
p.description = "A simple method to create an HTML calendar for a single month. Can be styled with CSS. Usable with Ruby on Rails."
p.url = "http://rubyforge.org/projects/seattlerb"
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
p.clean_globs = ['test/output']
end

# desc "Test task (actually runs specs)"
# task "test" do
# system "spec --format specdoc --color spec/*_spec.rb"
# end

# -- Rails-specific --

desc 'Generate documentation for the calendar_helper plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'CalendarHelper'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('Readme.txt')
rdoc.rdoc_files.include('lib/**/*.rb')
end

Sunday, December 09, 2007

Ruby on Rails install headaches

Some problems installing ruby on rails that I thought I's document.

Firstly I followed the instructions on rubyonrails.org, downloading the altest version of ruby 1.86_25, downloading and installing ruby Gems. The the next step where you actually install rails is where the trouble started

C:\apps\ruby186.25\rubygems-0.9.5>gem install rails --include-dependencies
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Bad file descriptor - connect(2) (Errno::EBADF)


First problem was web proxys.

My laptop is used both in work and at home. In work I use a http proxy to access the web. At home I don't. The problem was I had set a system variable to set a http proxy variable. (http_proxy), but I was using my laptop at home.

To check if you use a http proxy from a DOS window type the following

echo %http_proxy%

If you get a response like
http://10.105.24.70:8080

then you have a http proxy set.

For me I had to remove the proxy. This is done by
set http_proxy=

For most people however I would imagine the problem is the opposite, you may need to set the http_proxy for your DOS window. To check if you need a http_proxy, goto your web browser

For IE
Tools/ Internet Options/ Connections/ LAN Settings/ Proxy Server
Note the url and port

For Firefox goto
Tools/ Options/ Advanced/ Network tab/ Settings (phew)
Note the url and port

You can set the proxy in the dos window simply by typing
set http_proxy=http://10.105.24.70:8080

With this done you should be able to retry the install

Next problem was

C:\apps\ruby186.25\rubygems-0.9.5>gem install rails --include-dependencies
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
OpenURI::HTTPError: 404 Not Found reading http://gems.rubyforge.org/gems/activesupport-2.0.1.gem


THis was a temporary problem. I inserted the url into a browser and it worked. When I retried the command it also worked.

Thursday, December 06, 2007

Oracle version

Ever wondered what version of oracle you were running?

Wonder no more

select name from v$database
select * from v$version

Monday, August 20, 2007

Working with saxon

Saxon didn't like the concatenation of the sequence. changing this to fn:string-join worked however.


declare namespace xf = "http://tempuri.org/xqueryTest/XQueryTransformations/csv/";

declare function xf:csv($aPIMessage1 as element(APIMessage))
as xs:string {
fn:string-join(
for $line in $aPIMessage1/AuthResponse
let $ct := concat($line/ClientTransactionReference, "," , $line/SystemReferenceNumber, ",", $line/ResponseInfo/ResponseCode , ",", $line/ResponseInfo/Result ,",", $line/ResponseInfo/Description , ",", $line/ApprovalInfo/ApprovalCode , ",", $line/ApprovalInfo/DateTime, " ")
return $ct,"")
};


declare variable $aPIMessage1 as element(APIMessage) external;

xf:csv(doc("./resp.xml")/APIMessage)

My first xquery; xml to csv

Got this working. Thought I'd post it. My first xquery. Parses an Xml response file (from a credit card authorisation system), and outputs some of the fields as a csv file. It was written using the BEA XQuery Mapper, which is a pluggin by BEA for eclipse 3.1.

Having an issue running it with Saxon at the moment


declare namespace xf = "http://tempuri.org/xqueryTest/XQueryTransformations/csv/";

declare function xf:csv($aPIMessage1 as element(APIMessage))
as xs:string {
concat(for $line in $aPIMessage1/AuthResponse
let $ct := concat($line/ClientTransactionReference, "," , $line/SystemReferenceNumber, ",", $line/ResponseInfo/ResponseCode , ",", $line/ResponseInfo/Result ,",", $line/ResponseInfo/Description , ",", $line/ApprovalInfo/ApprovalCode , ",", $line/ApprovalInfo/DateTime, " ")
return $ct)
};



declare variable $aPIMessage1 as element(APIMessage) external;

xf:csv($aPIMessage1)

Friday, May 25, 2007

Ibatis problem

Document root element "sqlMap", must match DOCTYPE root "null"

This was the unhelpful exception I was gettign when I tried to run my ibatis/ spring prototype.

My ibatis sqlMap file looked ok

<sqlmapconfig>
<sqlmap resource="db/prov.xml">
</sqlmap>
<sqlmapconfig>javascript:void(0)
Publish Post

Had a search, you must add

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">

to your sql map files

Note you must also have

<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">

to your sql-map-config.xml file.

Tuesday, January 30, 2007

java http proxy support

Heres a good post on getting java to use the host machines proxy settings

http://weblogs.java.net/blog/kohsuke/archive/2005/08/we_deserve_a_be.html

Upshot is to include the following in you java prog before making http requests

try {
System.setProperty("java.net.useSystemProxies","true");
} catch (SecurityException e) {
; // failing to set this property isn't fatal
}
Sweet!

Wednesday, December 20, 2006

Unlocking mobile phones

I recently got a second mobile phone, and wanted to swap sims between the two.

The phones I wanted to unlock were a Nokia 6021, and a Nokia 6070

My experience was
  • Get your IMEI code off your phone (type *#06# into the phone).
  • Figure out if you are DCT3 or DCT 4 and your phone type from this site http://www.mobyproject.com/link/dct3&4list.txt
  • Goto this site http://unlock.nokiafree.org. Enter the details and get the code
  • Take out your sim and start phone without it.
  • Type in the bottom (7th) code from the list following the instructions from http://unlock.nokiafree.org. (Press * multiple times to get letters *, P, W +)

Voila.

Of course there are risks.
This article gives a good synopsis of what to do and some exceptions that can occur
http://www.oreilly.com/pub/wlg/3935

Good luck

Monday, October 16, 2006

Misc unix commands

chmod only dirs, using find
find /dir/to/chmod/all/dirs -type d -exec chmod a+x {} \;

Move all files after a certain date (Yesterday) , using find
find /dir/ -mtime -1 -exec mv {} ./temp \;

List only directories
ls -l | grep ^d

Find last created entity (file or directory)
ls -t ${CIDIR}| head -n 1

Find last created directory (note must use long ls results, therefore we need to parse 8th elment)
ls -tl | grep ^d | head -n 1 | awk '{print $8}'

grep multiple log files in different locations. (Join multiple lines into one line)


grep EXCEPTION `ls -t /var/log/bea/logs/MWOSBDomain/servers/MWOSB1?/customaudit/LogFile1?.log.* | head -n 3 |  tr '\n' ' '`

e.g. this will grep log files in differnt locations from yesterday (based on naming convention LogFile12.log = current log file. LogFile12.log. is rolled over log file. Assuming log files roll over every night).
Top 3 files are taken from ls command (in this case I know there are 3 log directories, so top 3 files are all yesterdays file in each directory)
List output is then 'translated', converting each line break into a space, so feed into grep command.

Dirname

Discovers the dir where the current running script is running;

Useful if writing bash scripts and you want to know where the current file is (for example if loading other companion scripts)

DIR="$( cd "$( dirname "$0" )" && pwd )"

e.g

#!/bin/bash

export DIRNAME=$(cd `dirname $0` && pwd)

source ${DIRNAME}/common.sh

#echo $JAVA_HOME/bin/java -cp $CLASSPATH ie.bge.middleware.envstatus.app.SetSystemStatus $@

$JAVA_HOME/bin/java -cp $CLASSPATH ie.bge.middleware.envstatus.app.SetSystemStatus $@

N.B. script must be executable. Therefore chmod +x


Parse log file with awk
awk normally splits lines based on whitespace characters. This can be forced however using the -F switch and passing a regex.
e.g. the following splits on semi-colon, and prints the 3rd and 6th fields.
awk -F ";" '{print $3 " " $6 }'
this example splits on commas, within quotes e.g. "value1", "value2", ..
awk -F "\"*,\"*" '{print $3}' file.csv

Identify unix version
uname -r
cat /etc/*-release
cat /etc/issue
rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n"|grep release|sort

Misc Tips
Whitepace gothcas when writing bash scripts.

Bash IF statment requires whitespace.
DIRNAME=mydir
if [ -d $DIRNAME ]; then
echo $DIRNAME exists
else
echo $DIRNAME does not exist
fi

1/ There must be NO whitespace in the set command (DIRNAME=mydir, ..e.g. the following won't work DIRNAME = mydir). Otherwise bash misinterprets the set operation as a command (called DIRNAME here).
2/ The whitespace between the IF statement and the [..] is required. e.g. (if [-d $DIRNAME]; then will cause an error)

Script to copy latest build folder to other location
#!/bin/bash
# Exit on Error
set -e
DIR=/usr/local/apache2/htdocs/Repository
CIDIR=/opt/continuous_integration/build_archive/
echo $#
if [ $# -ne 1 ]; then
echo Usage: PublishBuild.sh VER. Must supply version number.
exit 1
fi
VER=$1
if [ ! -d ${DIR}/$VER ]; then
mkdir ${DIR}/$VER
fi
if [ ! -d ${DIR}/${VER}/osb ]; then
mkdir ${DIR}/$VER/osb
fi
CIB=`ls -t ${CIDIR}| head -n 1`
echo cp -R ${CIDIR}/${CIB}/* ${DIR}/${VER}/osb
cp -R ${CIDIR}/${CIB}/* ${DIR}/${VER}/osb
echo Copied ${CIB} to ${VER}
exit 0

Friday, October 13, 2006

Drupal built in Global

Heres the small prog to produce this list

foreach($GLOBALS as $g=>$v){
if(is_array($v)){
echo("$g = Array {");
foreach($v as $a2=> $b2){
echo("$a2=$b2,");
}
echo("}");
}else
echo("$g = $v");
}

Heres the list
  • HTTP_POST_VARS = Array {}
  • _POST = Array {}
  • HTTP_GET_VARS = Array {q=node/11,}
  • _GET = Array {q=node/11,}
  • HTTP_COOKIE_VARS = Array {MANTIS_PROJECT_COOKIE=5,PHPSESSID=b9fb481c4b12115c83761754702db5ae,MANTIS_STRING_COOKIE=b36c8ddd894abf6d551b90aed8552328be6ab68c73aafdf3d611d932e25c67da,userwdth=null,userfontsz=null,userbg=null,phpMyAdmin=8d176d85421e8ec646ce148c4893cbec,}
  • _COOKIE = Array {MANTIS_PROJECT_COOKIE=5,PHPSESSID=b9fb481c4b12115c83761754702db5ae,MANTIS_STRING_COOKIE=b36c8ddd894abf6d551b90aed8552328be6ab68c73aafdf3d611d932e25c67da,userwdth=null,userfontsz=null,userbg=null,phpMyAdmin=8d176d85421e8ec646ce148c4893cbec,}
  • HTTP_SERVER_VARS = Array {HTTP_HOST=localhost,HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7,HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5,HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5,HTTP_ACCEPT_ENCODING=gzip,deflate,HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7,HTTP_KEEP_ALIVE=300,HTTP_CONNECTION=keep-alive,HTTP_REFERER=http://localhost/psoup/lia/?q=node/13,HTTP_COOKIE=MANTIS_PROJECT_COOKIE=5; PHPSESSID=b9fb481c4b12115c83761754702db5ae; MANTIS_STRING_COOKIE=b36c8ddd894abf6d551b90aed8552328be6ab68c73aafdf3d611d932e25c67da; userwdth=null; userfontsz=null; userbg=null; phpMyAdmin=8d176d85421e8ec646ce148c4893cbec,HTTP_CACHE_CONTROL=max-age=0,PATH=c:\\apps\\ruby\\ruby-184-17\\bin;c:\\apps;C:\\oracle\\product\\10.2.0\\db_2\\bin;c:\\beaSP2\\jdk141_05\\bin;c:\\apps\\ruby\\bin;c:\\apps\\sybase\\OCS-12_5\\lib3p;c:\\apps\\sybase\\OCS-12_5\\dll;c:\\apps\\sybase\\OCS-12_5\\bin;c:\\apps\\sybase\\SQLRemote\\dll;c:\\apps\\sybase\\RPL-12_5\\bin;c:\\apps\\sybase\\JS-12_5\\bin;c:\\apps\\sybase\\ASE-12_5\\dll;c:\\apps\\sybase\\ASE-12_5\\bin;C:\\Program Files\\ATI Technologies\\ATI Control Panel;c:\\apps\\imagemagick-6.1.5-q16;c:\\apps\\gpg\\bin;c:\\apps\\sybase\\OLEDB;c:\\apps\\cvs;c:\\apps\\sybase\\ODBC;c:\\apps\\sybase\\ASEP_Win32;c:\\apps\\sybase\\OCS-12_5\\dll;c:\\apps\\sybase\\OCS-12_5\\lib3p;c:\\apps\\sybase\\OCS-12_5\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\\ATI Technologies\\ATI Control Panel;c:\\apps\\apache-ant-1.6.2\\bin;C:\\Program Files\\Subversion\\bin;c:\\apps\\php-4.3.9-Win32;C:\\Program Files\\Common Files\\GTK\\2.0\\bin;c:\\Program Files\\MySQL\\MySQL Server 4.1\\bin;C:\\Program Files\\cvsnt;C:\\apps\\php-4.3.9-Win32;C:\\Program Files\\QuickTime\\QTSystem\\,SystemRoot=C:\\WINDOWS,COMSPEC=C:\\WINDOWS\\system32\\cmd.exe,PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.RB;.RBW,WINDIR=C:\\WINDOWS,SERVER_SIGNATURE=
  • Apache/2.0.58 (Win32) PHP/4.3.9 Server at localhost Port 80
  • ,SERVER_SOFTWARE=Apache/2.0.58 (Win32) PHP/4.3.9,SERVER_NAME=localhost,SERVER_ADDR=127.0.0.1,SERVER_PORT=80,REMOTE_ADDR=127.0.0.1,DOCUMENT_ROOT=C:/Program Files/Apache Software Foundation/Apache2/htdocs,SERVER_ADMIN=admin@ad.aol.aoltw.net,SCRIPT_FILENAME=C:/dev/psoup/lia/index.php,REMOTE_PORT=2251,GATEWAY_INTERFACE=CGI/1.1,SERVER_PROTOCOL=HTTP/1.1,REQUEST_METHOD=GET,QUERY_STRING=q=node/11,REQUEST_URI=/psoup/lia/?q=node/11,SCRIPT_NAME=/psoup/lia/index.php,PHP_SELF=/psoup/lia/index.php,PATH_TRANSLATED=C:/dev/psoup/lia/index.php,}
  • _SERVER = Array {HTTP_HOST=localhost,HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7,HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5,HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5,HTTP_ACCEPT_ENCODING=gzip,deflate,HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7,HTTP_KEEP_ALIVE=300,HTTP_CONNECTION=keep-alive,HTTP_REFERER=http://localhost/psoup/lia/?q=node/13,HTTP_COOKIE=MANTIS_PROJECT_COOKIE=5; PHPSESSID=b9fb481c4b12115c83761754702db5ae; MANTIS_STRING_COOKIE=b36c8ddd894abf6d551b90aed8552328be6ab68c73aafdf3d611d932e25c67da; userwdth=null; userfontsz=null; userbg=null; phpMyAdmin=8d176d85421e8ec646ce148c4893cbec,HTTP_CACHE_CONTROL=max-age=0,PATH=c:\\apps\\ruby\\ruby-184-17\\bin;c:\\apps;C:\\oracle\\product\\10.2.0\\db_2\\bin;c:\\beaSP2\\jdk141_05\\bin;c:\\apps\\ruby\\bin;c:\\apps\\sybase\\OCS-12_5\\lib3p;c:\\apps\\sybase\\OCS-12_5\\dll;c:\\apps\\sybase\\OCS-12_5\\bin;c:\\apps\\sybase\\SQLRemote\\dll;c:\\apps\\sybase\\RPL-12_5\\bin;c:\\apps\\sybase\\JS-12_5\\bin;c:\\apps\\sybase\\ASE-12_5\\dll;c:\\apps\\sybase\\ASE-12_5\\bin;C:\\Program Files\\ATI Technologies\\ATI Control Panel;c:\\apps\\imagemagick-6.1.5-q16;c:\\apps\\gpg\\bin;c:\\apps\\sybase\\OLEDB;c:\\apps\\cvs;c:\\apps\\sybase\\ODBC;c:\\apps\\sybase\\ASEP_Win32;c:\\apps\\sybase\\OCS-12_5\\dll;c:\\apps\\sybase\\OCS-12_5\\lib3p;c:\\apps\\sybase\\OCS-12_5\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\\ATI Technologies\\ATI Control Panel;c:\\apps\\apache-ant-1.6.2\\bin;C:\\Program Files\\Subversion\\bin;c:\\apps\\php-4.3.9-Win32;C:\\Program Files\\Common Files\\GTK\\2.0\\bin;c:\\Program Files\\MySQL\\MySQL Server 4.1\\bin;C:\\Program Files\\cvsnt;C:\\apps\\php-4.3.9-Win32;C:\\Program Files\\QuickTime\\QTSystem\\,SystemRoot=C:\\WINDOWS,COMSPEC=C:\\WINDOWS\\system32\\cmd.exe,PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.RB;.RBW,WINDIR=C:\\WINDOWS,SERVER_SIGNATURE=
  • Apache/2.0.58 (Win32) PHP/4.3.9 Server at localhost Port 80
  • ,SERVER_SOFTWARE=Apache/2.0.58 (Win32) PHP/4.3.9,SERVER_NAME=localhost,SERVER_ADDR=127.0.0.1,SERVER_PORT=80,REMOTE_ADDR=127.0.0.1,DOCUMENT_ROOT=C:/Program Files/Apache Software Foundation/Apache2/htdocs,SERVER_ADMIN=admin@ad.aol.aoltw.net,SCRIPT_FILENAME=C:/dev/psoup/lia/index.php,REMOTE_PORT=2251,GATEWAY_INTERFACE=CGI/1.1,SERVER_PROTOCOL=HTTP/1.1,REQUEST_METHOD=GET,QUERY_STRING=q=node/11,REQUEST_URI=/psoup/lia/?q=node/11,SCRIPT_NAME=/psoup/lia/index.php,PHP_SELF=/psoup/lia/index.php,PATH_TRANSLATED=C:/dev/psoup/lia/index.php,}
  • HTTP_ENV_VARS = Array {}
  • _ENV = Array {}
  • HTTP_POST_FILES = Array {}
  • _FILES = Array {}
  • _REQUEST = Array {q=node/11,MANTIS_PROJECT_COOKIE=5,PHPSESSID=b9fb481c4b12115c83761754702db5ae,MANTIS_STRING_COOKIE=b36c8ddd894abf6d551b90aed8552328be6ab68c73aafdf3d611d932e25c67da,userwdth=null,userfontsz=null,userbg=null,phpMyAdmin=8d176d85421e8ec646ce148c4893cbec,}
  • conf = Array {array_filter=1,comment_image=2,comment_page=0,comment_story=2,file_directory_temp=c:\windows\temp,filter_default_format=3,filter_html_1=1,image_help=,menu_primary_menu=2,menu_secondary_menu=2,minimum_image_size=0,minimum_page_size=0,minimum_story_size=0,nice_menus_menu_1=42,nice_menus_name_1=Nice Menu 1,nice_menus_number=1,nice_menus_type_1=down,node_options_forum=Array,node_options_image=Array,node_options_page=Array,node_options_story=Array,page_help=,story_help=,theme_default=bluemarine2,type=page,upload_image=1,upload_page=1,upload_story=1,}
  • db_url = mysql://root:@localhost/lia
  • db_prefix =
  • base_url = http://localhost/psoup/lia
  • base_path = /psoup/lia/
  • base_root = http://localhost
  • db_type = mysql
  • active_db = Resource id #6
  • HTTP_SESSION_VARS = Array {watchdog_overview_filter=all,node_overview_filter=Array,}
  • _SESSION = Array {watchdog_overview_filter=all,node_overview_filter=Array,}
  • user = Object
  • queries =
  • timers = Array {page=Array,}
  • locale = en
  • multibyte = 0
  • _menu = Array {path index=Array,items=Array,callbacks=Array,visible=Array,}
  • theme = bluemarine2
  • theme_engine = phptemplate
  • custom_theme =
  • theme_key = bluemarine2
  • sidebar_indicator =

Sunday, September 24, 2006

Wednesday, August 30, 2006

Drupal idiosyncracies

  • The always present "Create Content" menu item (even when users aren't logged in)
http://drupal.org/node/47212
In particular, simply "Reset" the menu item should fix it

  • Read More tag in postings
    http://drupal.org/node/64051
Menus
Should write module to allow new terms to be added to menu system. At moment must create terms. Then create content using those terms. As part of this you can select create menu item.

Nice Menus.
By default css only supplies styles for 1 sublevel. Thus higher sublevels autoexpand. Add the following to stop this
(see http://drupal.org/node/65482)

// Add extra layer to stop 2nd level submenus from autoexpanding
//level 2
ul.nice-menu ul,
ul.nice-menu li:hover ul ul, ul.nice-menu li.over ul ul,
ul.nice-menu li:hover li:hover ul ul, ul.nice-menu li.over li.over ul ul {
display:none;
}

ul.nice-menu li:hover ul, ul.nice-menu li.over ul,
ul.nice-menu li:hover li:hover ul, ul.nice-menu li.over li.over ul,
ul.nice-menu li:hover li:hover li:hover ul, ul.nice-menu li.over li.over li.over ul {
display:block;
}

//Level 3
ul.nice-menu ul,
ul.nice-menu li:hover ul ul, ul.nice-menu li.over ul ul,
ul.nice-menu li:hover li:hover ul ul, ul.nice-menu li.over li.over ul ul,
ul.nice-menu li:hover li:hover li:hover ul ul, ul.nice-menu li.over li.over li.over ul ul {
display:none;
}

ul.nice-menu li:hover ul, ul.nice-menu li.over ul,
ul.nice-menu li:hover li:hover ul, ul.nice-menu li.over li.over ul,
ul.nice-menu li:hover li:hover li:hover ul, ul.nice-menu li.over li.over li.over ul,
ul.nice-menu li:hover li:hover li:hover li:hover ul, ul.nice-menu li.over li.over li.over li.over ul {
display:block;

Wednesday, August 16, 2006

Java Spring and Locales

Related to my previous post. We were updating a web app and localizing it for some new countries.

The jsps used some Spring tag libs.

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />


Spring comes with an inbuilt LocaleResolver. By default it uses the AcceptHeaderLocaleResolver which detects the clients Locale from the Http headers (which are sent with the bowsers request).

In our case we didn't want the client locale to get picket up. We wanted to set it based on the servername. (To do these we added some virtual hosts to our tomcat instance).

Then to update the Spring Locale we had to use the SessionLocaleResolver . This has to be instantiated via the Spring xml file (otherwise it will default to AceptHeaderLocaleResolver).



We then simply set the Locale froma filter.

String servername = httpRequest.getServerName();
Locale locale = null;
if(servername.indexOf(".co.uk")>0){
_log.info("Setting UK locale");
locale = Locale.UK;
}else if(servername.indexOf(".fr")>0){
_log.info("Setting FR locale");
locale = Locale.FRANCE;
}else if(servername.indexOf(".de")>0){
_log.info("Setting DE locale");
locale = Locale.GERMANY;
}else{
_log.info("Cannot ascertain originating server. Defaulting to UK locale");
locale = Locale.UK;
}


HttpServletRequest

I keep forgetting these value. So I'm writing it down here to remember

Within a servlet, or Filter (or jsp) you can access the following information about the request.

httpRequest.getContextPath(); // =/webapp
httpRequest.getRequestURI(); // =/webapp/webhome
httpRequest.getServletPath(); // = /webhome
httpRequest.getRequestURL(); // = http://mybox.my:11600/webapp/webhome?q=query&r=prevPage
httpRequest.getRequestURI(); // = http://mybox.my:11600/webapp/webhome

httpRequest.getServerName(); // = mybox.my (1)
httpRequest.getRemoteHost(); // = 10.149.93.49 (2)
httpRequest.getRemoteAddr(); // = 10.149.93.49
httpRequest.getRemoteUser(); // = null ... (3)

N.B.
If you perform a RequestDispatcher.forward() then all the above methods will reflect the new forwarded values. Personally I didn't think the javadocs made this clear.

As of Servlet spec 2.4 however you can still access the original client request data using the following attributes. (see http://www.javaworld.com/javaworld/jw-03-2003/jw-0328-servlet_p.html)

  • javax.servlet.forward.request_uri
  • javax.servlet.forward.context_path
  • javax.servlet.forward.servlet_path
  • javax.servlet.forward.path_info
  • javax.servlet.forward.query_string

Inside a forwarded servlet you'll see getRequestURI() return the path to the target servlet as always, but now if you want the original path, you can call request.getAttribute("javax.servlet.forward.request_uri"). One special caveat: if forward() happens through a getNamedDispatcher() call, these attributes aren't set because, in that case, the original path elements aren't changed.

Note from servlet spec 2.2 there already exists

  • javax.servlet.include.request_uri
  • javax.servlet.include.context_path
  • javax.servlet.include.servlet_path
  • javax.servlet.include.path_info
  • javax.servlet.include.query_string
However, these work just the opposite of the forward() attributes. In an include(), the path elements don't change, so the include attributes act as the backdoor to access the target servlet's path elements. Compare this with a forward() where the path elements change so the forward attributes represent the backdoor to the original path elements.

Should filters invoke for forwarded requests? Included requests? What about for URIs invoked via the mechanism? Before Servlet 2.4, these questions were left as open issues. Now Servlet 2.4 makes it a developer's choice. There's a new element in the deployment descriptor with possible values REQUEST, FORWARD, INCLUDE, and ERROR. You can add any number of entries to a like this:


<filter-mapping>
<filter-name>Logging Filter</filter-name>
<url-pattern>/products/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>

This indicates the filter should be applied to requests directly from the client as well as forward requests. Adding the INCLUDE and ERROR values also indicates that the filter should additionally be applied for include requests and requests. Mix and match for what you want. If you don't specify any elements, the default is REQUEST.

The last RequestDispatcher change is to allow, for the first time, relative paths in request.getRequestDispatcher() calls. The path will be interpreted relative to the current request's path. It's a minor change, but comes in handy when dispatching to a sibling servlet.




Notes:
No all these method are available on the basic ServletRequest. Normally I just cast the basic ServletRequest into a HttpServletRequest, since I am normally only writting web apps.

1/ This is the server name from the Request. You can set up your web server to be multi hosted using virtual hosts. (Heres an example for tomcat). Then you can use this variable to differentiate on which host they came in on. We are using this for setting the locale on one project. (In general it is better to choose the locale based on the request,but we have specific reasons for doing it this way).

2/ This is the clients IP address. Can be used for logging.

3/I'm guess this will show a value if the page is protected by HttpAuthentication.

For Php equivilents check out this page

http://www.php.net/reserved.variables

Thursday, July 06, 2006

Updating a Windows Service..

I needed to update mysql to use the old authentication mechanism...
http://dev.mysql.com/doc/refman/5.0/en/old-client.html

This involved adding some command line parameters to mysqld when it starts to use the old authentication mechanism. Unfortunately the Windows Services tool doesn't allow this.

Thanks to http://illiniguy.wordpress.com/2006/03/17/updating-a-windows-service/

regedit to

\\HKEY_LOCAL_MACHINE\SYSTEMCurrentControlSet\Services\___YOUR_SERVICE_NAME___

and edit away...

Saturday, April 08, 2006

Browser interoperability

I've had a lot of headaches with this. In general my approach is to use and libraries/ open source functions etc that are out there since they will almost certainly work better in a cross browser environemnt than what I throw together

This doesn't always work out however and I find myself writting css pages, javascript etc...

Anyway the problem. Looks like a bug in IE. It appears that the document.getElementById() function does not work... However on further examination it turns out that the ID attribute must be the first (or before most atribute) attribute in an html element.

For example

<img class="myimg" name="myimg" src="myimg.jpg" id="12"/>

If you then try to access this in javascript it doesn't work

docuemnt.getElementById("12") returns a null.

However if you re-jig the element so id is the first attribute then it works fine.. Bizarre.

<img id="12" class="myimg" name="myimg" src="myimg.jpg" />

[tested on IE 6.02]

Thursday, October 13, 2005

DB access in word VBA

I was working on little program to extract data from a word document, and insert it into a database. Pretty straightforward VBA for a VBA developper... Except I'm not a VBA developper.

Actually it proved quite simple up to the point where I need to make an ODBC connection to the database. Then all hell broke loose.

In time honoured VBA programming practise, when you hit upon a problem, record a macro, and do the step you want to, then view and edit the code.. .

This I did and discovered the nice looking InsertDatabase [Link to msdn]
. Worked a treat.. Read data from the odbc, and displayed in it the doc. Wonderful!

Except for the teeny weeny problem thatI wanted to display the data in a userForm. Reading the docs in that link above, the InsertDatabase method can only be called on a Range object. Try as I might I couldn't find a Range object in the UserForm.

Long story short.. I found the ADO object which solved my problems.. Gives you a full API for talking to DB's. You will need to install the reference libraries Microsoft AxtiveX Data Object library (you will need your office install media for this), and include them in your references first.

I did briefly run into the infamous Error 80004005 "Data Source Name Not Found"

But with a bit of tinkering around I got this to work.

First step, create a systemDSN (userDSN should also work) of the name for the ODBC connection you want (vba in this instance)

Then the following code calls a table there and inserts the data into my UserForm (called UserInput)


Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String

Const ConnectString = "DATABASE=vba;DESCRIPTION=Vba Test;DSN=vba;OPTION=0;PORT=0;SERVER=localhost"


cn.ConnectionString = ConnectString
'cn.CursorLocation = adUseClient
cn.Open

' Find out if the attempt to connect worked.
If cn.State = adStateOpen Then
Set rs = cn.Execute("Select * From test")
If rs.EOF Then
UserInput.namesList.AddItem "No Entries returned from Database."
Else
While Not rs.EOF
UserInput.namesList.AddItem rs("data") & ":" & rs("date")
rs.MoveNext
Wend
End If
'MsgBox (rs("data") & ":" & rs("date"))
rs.Close
Else
MsgBox "Sorry there was a problem connecting to the database."
End If

cn.Close


Wonderful..

Any questions, drop me a comment,