welcome to my blog !

My name is Aleksey Maksimov. I am Software Architect with many years of IT experience and architecture experience. I work for a global IT consulting company and live in the United Kingdom. This is my software rants blog. I also have blog about my life happenings, in Russian. I also registered in almost all social networks, usually as ctpeko3a, sometimes as lechat and rarely as drunkenfly. Here is my FriendFeed and View my profile on LinkedIn.

January 06 2010

Recursive Linux “Find Files Containing”

find . -name "*.ext" -exec grep -i -H -n "texttofind" {} \;

June 22 2009

Make Home/End/Delete keys work in Solaris bash

Tagged Under : , , ,

This is most frustrating thing that I experience when I encounter Solaris bash prompt: the Home, End and Delete keyboard keys will not work because for some reason Solaris doesn’t understand them as useful keys. But there is the way to enable those keys!

Add following lines to your ~/.bashrc file:

# home key
bind ‘"\e[1~":beginning-of-line’
# del key
bind ‘"\e[3~":delete-char’
# end key
bind ‘"\e[4~":end-of-line’
# pgup key
bind ‘"\e[5~":history-search-forward’
# pgdn key
bind ‘"\e[6~":history-search-backward’

Save and source file. Now keys will work as they should.

May 08 2009

VMWare DHCP service wont’start – SOLVED

Tagged Under : , , ,

I use VMWare to run a bunch of different Linux VMs on my home PC, which is running Vista SP1. Today I encountered strange thing: Linux VM won’t get an IP address from VMWare DHCP. I’ve opened VMWare Virtual Networks management console (as Administrator, of course, or it won’t let you make and save any changes) just to find out that DHCP service is not started. I tried to start it from there, but it failed to do so.

So I went to Vista Services console and tried to start “VMWare DHCP service from there”. Again, failed to start with no explanation, even cryptic one. So I went to Windows Events viewer and there, under Windows Logs-System, I found a lot of messages from VMNetDHCP:


The description for Event ID 2 from source VMnetDHCP cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

Can’t open C:\ProgramData\VMware\vmnetdhcp.conf: Access is denied.

/ The data is invalid

the message resource is present but the message is not found in the string/message table

Though the message says that the message is not found, it has enough information to fix the problem.

So, I’ve taken a look at the security properties for C:\ProgramData\VMWare folder and found that SYSTEM account somehow is not in a list of permitted users. The only account, who was permitted to access that folder, was my Windows user account. So I added SYSTEM account with all permissions to this folder, waited when Windows propagated my change to all files and tried to start VMWare DHCP service again. It worked!

Then I simply restarted network within Linux VM (sudo /etc/init.d/networking restart) and got back to work.

May 07 2009

JBOSS Seam 2.1.1GA on JBOSS AS 5.0.1GA: Table is not mapped

Tagged Under : , , , , , ,

I created sample JBOSS Seam project in Eclipse and decided to generate entity code from  existing database. It worked fine, but when I try to run it, it shows me that Hibernade is not able to map entity beans to the corresponding tables. The error message is like this:

org.hibernate.hql.ast.QuerySyntaxException: <your table> is not mapped

I spent around three hours trying to read all available information on it, but most of it just useless – it looks like people don’t know whats happening, so they recommend bizarre tricks. Like, for example, having empry seam.settings file in each folder, meh.

Finally, I found the solution in Seam Jira: https://jira.jboss.org/jira/browse/JBSEAM-3821

They rocemmend to to force Hibernate to use Seam’s EntityManager by changing two files:

1. components.xml

    <persistence:entity-manager-factory name="bookingDatabase" installed="false"/>
    <!– If Seam loads the persistence unit (JBoss 4.x), the EntityManagerFactory will be resolved from #{bookingDatabase}.
         On JBoss AS 5, the EntityManagerFactory is retrieved from JNDI (the binding occurs during application deployment). –>
    <persistence:managed-persistence-context name="em" auto-create="true"
       entity-manager-factory="#{bookingDatabase}" persistence-unit-jndi-name="java:/bookingEntityManagerFactory"/>

2. persistence.xml

<!– Binds the EntityManagerFactory to JNDI where Seam can look it up.
              This is only relevant when the container automatically loads the persistence unit, as is the case in JBoss AS 5. –>
         <property name="jboss.entity.manager.factory.jndi.name" value="java:/bookingEntityManagerFactory"/>

Hope that Google will find that page and the proper solution would be much more easily found!

August 28 2007

How to reveal stored passwords and let browser remember them

There is all so common situation when you have to go to once a week to a website, and you have to login to it and your browsers is not asking you about remembering that password. So you have to remember that password and its getting out of your head and you have to spend some time trying to get it into your head again.

If you are using Firefox you are lucky. There is a way to let your browser to remember the password and even reveal what you have typed correct password.

Here are the steps for a freedom:

  1. You will need to install Greasemonkey extension for Firefox from here. This extension allows you to use special JavaScript programs, which change the behaviour and/or look of the web sites. Don’t worry if you don’t know JavaScript, that knowledge is not required unless you want to write something completely new.

    Perhaps you want to bookmark this page before the required Firefox restart, so you could easily return to this small guide. Press Ctrl-D to do that.

  2. After Greasemonkey is installed and you restarted the Firefox you will need to install Force Autocomplete script, which will enable password saving feature on all pages.

    You don’t have to restart Firefox, to get Greasemonkey scripts working. If the script is not working – just refresh the page (Press F5).

  3. Next step is to install password revealing script: Passwords on MouseOver

Now you all set. Your form data will be remembered and you could verify that you are typing correct password.

You could get many more additional scripts here: http://userscripts.org/

December 03 2006

Subversion and branching

Excellent article on branching in Subversion. One thing missing is the branch timeline chart. Something like this:

Where horisontal line is the trunk timeline and angled lines are releases. Based on my experience, that chart often helps developers to understand when branches are created and how to deal with them.

January 20 2006

Creating WebSphere 6 application MBeans

This is a little step by step guide on how to create and register custom service with JMX interface on WebSphere:

1. Create class, which implements two interfaces:

[java]
com.ibm.websphere.runtime.CustomService
com.ibm.websphere.management.JMXManageable
[/java]

2. Implement “initialize” method (inherited from CustomService)
This method has a parameter, Properties, which will contain properties defined via WS Administration console. We are interested in one property: externalConfigURLKey. This property contains path to external configuration file (if any is needed).

This is how to get the path:

[java]
public void initialize(Properties configProperties) throws Exception {
readConfig(configProperties.getProperty(externalConfigURLKey));
}
[/java]

3. shutdown() method may be left blank.

4. implement getType() method (inherited from JMXManageable):

[java]
public String getType() {
return “MyMBean”;
}
[/java]

Remember the name you returned here!

5. implement getMBeanProperties:

[java]
public Properties getMBeanProperties() {
Properties props = new Properties();
props.put(“SpecialProperty”, “value”);
return props;
}
[/java]

I think this will return a list of properties, not declared in MBean descriptor. Read only, of course, since there is no setMBeanProperties() method.

6. implement getters and setters for properties you want to expose:

[java]
public String getUserName() {
return this.userName;
}

public void setUserName(String param) {
this.userName = param;
}
[/java]

7. Create MBean descriptor file, for example myTest.xml.

[xml]





[/xml]

IMPORTANT: Make sure that type matches the value you remembered on the step 4!

8. Compile and package. Create .jar, having descriptor in the root. Place .jar somewhere accesible for WebSphere.

9. Start WebSphere and open Administration console.

10. Go to Servers – Application Servers – yourserver – Server Infrastructure – Administration – Administration Services

11. Click on “Extension MBean providers”

12. Click on “New”

13. In the “Classpath” entry type the full path and name of your jar (created on step 8)

14. Type something memorable in two other fields and click Apply.

15. Click on “Extension MBeans” (on the left)

16. Click on “New”

17. Enter the name of MBean descriptor file (see step 7.)

for example:
myTest.xml

18. Enter the type name of your MBean. IMPORTANT: must be the same name as it was on steps 4 and 7.

19. Click Apply.

20. Go to Servers – Application Servers – yourserver – Server Infrastructure – Administration – Custom Services

21. Click New

22. Place check on “Enable service at server startup”.

23. Enter full class name (with package) of your MBean class (the one we created on step 1) into “Classname” field.

24. Enter something memorable in “Display Name”

25. Enter fill path and file name of the jar file (step 8) into “Classpath”.

26. If your service requires configuration file (step 2) enter full path to it into ” External Configuration URL”

27. Click on Apply.

28. Click on Save (on top)

29. Click Save.

30. Restart the server.

Here are the commands, used to verify MBean from admin console:

To run console:
wsadmin.bat -conntype SOAP -port 8881

To make sure that MBean started:
$AdminControl queryNames *:*,type=>

Store MBean in Tcl variable:
set mybean [$AdminControl queryNames *:*,type=MBeanName]

See MBean description:
$Help all $mybean

See MBean attributes and values:
$AdminControl getAttributes $mybean

Set specific attribute:
$AdminControl setAttribute $mybean UserName mike