About Me

My photo
I know the last digit of PI

Friday, January 02, 2015

Bluetooth COM port in Linux

Following tools are needed for dealing with bluetooth devices in Linux: bluetoothctl, hcitool, rfcomm, minicom

Pairing

Powering the bluetooth adapter and making it pairable
user@workstation:~$ bluetoothctl
[bluetooth]# power on
Changing power on succeeded

[bluetooth]# pairable on 
Changing pairable on succeeded
Search for new bluetooth devices - note the btaddress of the device (00:06:66:04:9E:4A). It is needed for all bluetooth commands
[bluetooth]# scan on
Discovery started
[CHG] Controller aa:bb:cc:dd:ee:ff Discovering: yes
[NEW] Device 00:06:66:04:9E:4A FireFly-9E4A

[bluetooth]# scan off
Discovery stopped
[CHG] Controller aa:bb:cc:dd:ee:ff Discovering: no
Retrieve some information about the device
[bluetooth]# info 00:06:66:04:9E:4A
Device 00:06:66:04:9E:4A
 Name: FireFly-9E4A
 Alias: FireFly-9E4A
 Class: 0x001f00
 Paired: no
 Trusted: no
 Blocked: no
 Connected: no
 LegacyPairing: yes
Optionally configure the device to be trusted - so if it automatically accepts generated PINs. However for legacy pairing manually entered PIN is required.
[bluetooth]# trust 00:06:66:04:9E:4A
[CHG] Device 00:06:66:04:9E:4A Trusted: yes
Changing 00:06:66:04:9E:4A trust succeeded
Configure the bluetoothctl to be default agent for dealing with PIN code.
[bluetooth]# agent on
Agent registered

[bluetooth]# default-agent 
Default agent request successful
Now pair with the device
[bluetooth]# pair 00:06:66:04:9E:4A
Attempting to pair with 00:06:66:04:9E:4A
[CHG] Device 00:06:66:04:9E:4A Connected: yes
Request PIN code
[agent] Enter PIN code: 1234
[CHG] Device 00:06:66:04:9E:4A UUIDs:
 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device 00:06:66:04:9E:4A Paired: yes
Pairing successful
Double check the pairing and quit
[bluetooth]# paired-devices 
Device 00:06:66:04:9E:4A FireFly-9E4A

[bluetooth]# quit

Discovering services and RFCOMM channels

For devices that support SDP - Service Discovery Protocol (UUID: 00000001-0000-1000-8000-00805F9B34FB) the following command will show available protocols and RFCOMM channels. The XX:XX:XX:XX:XX:XX is the btaddress of the device. Note that in the previos example the device 00:06:66:04:9E:4A do not support SDP protocol, so the sdptool command will produce empty result.
user@workstation:~$ sdptool browse XX:XX:XX:XX:XX:XX
Service Name: Object Push Profile
Service RecHandle: 0x1000f
Service Class ID List:
  "OBEX Object Push" (0x1105)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 2
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX Object Push" (0x1105)
    Version: 0x0100

Creating links to the remote COM port

Retrieving the bluetooth adapter name on the local machine.
user@workstation:~$ hcitool dev
Devices
        hci0    aa:bb:cc:dd:ee:ff
The adapter is called hci0 Optionally the connection could be tested with the following command
user@workstation:~$ sudo rfcomm connect hci0 00:06:66:04:9E:4A 1
Creating symlink to bluetooth serial port
user@workstation:~$ sudo rfcomm bind hci0 00:06:66:04:9E:4A 1
Verifying that the connection is established
user@workstation:~$ sudo rfcomm -a
rfcomm0: 00:06:66:04:9E:4A channel 1 connected [tty-attached]
The serial (COM) port is available as /dev/rcomm0 Any terminal program can use it. With following command will configure rootooth bluetooth device to communicate with Roomba 520 at baud rate 115200
user@workstation:~$ sudo minicom -D /dev/rfcomm0
$$$
>CMD
U,115K,N
>AOK
---
>END

Removing the symlink

In order to remove the symbolic link to the serial port the following command must be executed:
user@workstation:~$ sudo rfcomm release hci0

Unpairing the device and removing pairing configuration

user@workstation:~$ bluetoothctl

[bluetooth]# disconnect 00:06:66:04:9E:4A
Attempting to disconnect from 00:06:66:04:9E:4A
Successful disconnected

[bluetooth]# remove 00:06:66:04:9E:4A
[DEL] Device 00:06:66:04:9E:4A FireFly-9E4A
Device has been removed

[bluetooth]# power off
Changing power off succeeded

Tuesday, November 04, 2014

Jenkins deployment script with VPN establishment and SSH port forwarding

Here is a deployment script that can be run from Jenkins.
It establishes VPN connections, creates SSH tunnels and copies the WAR file to remote server. At the end the WAR is verified and a deployment script is executed.

The 192.168.0.2 is the server that gives access to other machines. The target tomcat server is 192.168.0.3, but it can be accessed only from 192.168.0.2.
The deploy.sh is responsible to stop tomcat server, delete the old artifact and start the tomcat server.

#!/bin/bash
now="$(date +'%Y%m%d%H%M')"

yes | cp /opt/hudson/jobs/WAR/lastSuccessful/archive/target/app.war ./app.war

cksumline=`cksum ./app.war`

fileChkSum=$(echo "$cksumline" | awk '{print $1}')
fileSize=$(echo "$cksumline" | awk '{print $2}')

#echo "Local Checksum:$fileChkSum"
#echo "Local FileSize:$fileSize"

sudo pon vpn-conn1
echo VPN connected
sleep 10

echo Creating tunnel
sshpass -p $pass ssh -f -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no user@192.168.0.2 -L 1234:192.168.0.3:22 'sleep 30' &
sleep 10
echo Tunnel created


echo Copyng WAR file...
sshpass -p $pass scp -oStrictHostKeyChecking=no -P 1234 ./app.war user@localhost:webapps/app.war.$now
echo WAR file copied.

cksumline2=`sshpass -p $pass ssh -oStrictHostKeyChecking=no -p 1234 user@localhost cksum webapps/app.war.$now`
echo "Checksum execution on remote machine: $cksumline2"




fileChkSum2=$(echo "$cksumline2" | awk '{print $1}')
fileSize2=$(echo "$cksumline2" | awk '{print $2}')

if [[ "$fileChkSum" != "$fileChkSum2" ]]; then
  echo "Checksum differs! local: $fileChkSum, remote: $fileChkSum2"
  sudo poff vpn-conn1
  echo VPN disconnected
  exit -1
fi

if [[ "$fileSize" != "$fileSize2" ]]; then
  echo "Size differs! local: $fileSize, remote: $fileSize2"
  sudo poff vpn-conn1
  echo VPN disconnected
  exit -1
fi


sshpass -p $pass ssh -oStrictHostKeyChecking=no -p 1234 user@localhost cp webapps/app.war.$now webapps/app.war
sshpass -p $pass ssh -oStrictHostKeyChecking=no -p 1234 user@localhost ./deploy.sh


sudo poff vpn-conn1
echo VPN disconnected

Resizing VirtualBox HDD

Original post from here https://forums.virtualbox.org/viewtopic.php?f=35&t=50661

Steps:
  1. Resize the Virutalbox HDD VBoxManage modifyhd <absolute path to file> --resize <size in MB>>
  2. Use GParted liveCD to resize the partition http://sourceforge.net/projects/gparted/

Thursday, May 22, 2014

Reverse proxy with apache

Creating reverse proxy with appache is quite easy. The common scenario is that you want to redirect entire domain to internal application server. Steps: 1) install apache 2) Edit APACHE_HOME/conf/httpd.conf with following content:
Listen 80
#Listen 1080

LogLevel debug
#ProxyHTMLLogVerbose On

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule xml2enc_module modules/mod_xml2enc.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule deflate_module modules/mod_deflate.so

<VirtualHost *>
 ProxyRequests OFF
 ProxyPreserveHost On
 
 ProxyPass / ajp://127.0.0.1:8009/
 ProxyPassReverse / ajp://127.0.0.1:8009/

 #ProxyPass /app/ ajp://127.0.0.1:8009/app/
 #ProxyPass /app/ ajp://127.0.0.1:8009/app/
 #ProxyHTMLURLMap  / /app/ 

</VirtualHost>
3) On the application server (Tomcat/JBoss) deploy your app in the root context. For JBoss use jboss-web.xml with following content:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/</context-root>
</jboss-web>
Also do not forget to disable the default root application from JBOSS_HOME/standalone/configuration/ set enable-welcome-root to false
<virtual-server name="default-host" enable-welcome-root="false">

Friday, April 11, 2014

UPS under Linux

The following steps are tested on Fedora 20, but generally should work on every other system with few modifications.

Step1. Install NUT


yum install nut*

Step2. Configure UPS

Execute
nut-scanner
It should output something like this:
[nutdev1]
driver = "blazer_usb"
port = "auto"
vendorid = "0001"
productid = "0000"
product = "STD UPS MON V1.0"
bus = "006"

Add the nut-scanner output to the end of /etc/ups/ups.conf file. You can change the [nutdev1] to something more meaningful e.g. [myUps1] or [InformGuardUPS]. In the examples bellow we will use the default name [nutdev1].

Change /etc/ups/upsd.conf and add "LISTEN 127.0.0.1 3493" (without quotes)

Change /etc/ups/upsd.users and add a new admin user

[admin]
password = mypassword
actions = SET
instcmds = ALL

Change /etc/ups/upsmon.conf and add following lines:

RUN_AS_USER root
MONITOR nutdev1@localhost 1 admin mypassword master


Step3. Manually test everything

upsdrvctl start
The command should output something similar to:
Network UPS Tools - Generic HID driver 0.34 (2.4.1)
USB communication driver 0.31
Using subdriver: MGE HID 1.12
Detected EATON - Ellipse MAX 1100 [ADKK22008]
If you face a problem like "libusb couldn't open usb device /dev/usb/XXXXXX: permission denied", then use google to find a way how to solve it nicely. I used very brutal method:
chmod -R 777 /dev/bus/usb/
Then try to start UPS driver again Start the upsd:
upsd
And the result should be similar to:
Network UPS Tools upsd 2.4.1
listening on 127.0.0.1 port 3493
listening on ::1 port 3493
Connected to UPS [eaton]: usbhid-ups-eaton
List your ups names with
upsc -L
Try to query the UPS status with.
upsc nutdev1@localhost
or just
upsc nutdev1
Depending on your UPS capabilities it should return various variables and their values. See http://www.networkupstools.org/docs/user-manual.chunked/apcs01.html for more details. If you want to check if is it working on battery right now execute
upsc nutdev1 ups.status
and the output should be OL (online) or OB (on battery), LB (low battery), etc. You can also play around with some of the UPS commands/settings
upscmd nutdev1 beeper.toggle

After that reboot the system (or stop all daemons)



Step4. Starts UPS daemons automatically

Execute following commands:
systemctl enable nut-server
systemctl start nut-server
systemctl enable nut-monitor.service
systemctl start nut-monitor.service
Restart the system, and if check if everything is ok, by executing the UPS status with upsc command. Now the UPS monitoring system is configured and in case of power loss, the computer will shutdown, when the UPS battery is low. If you don't want to shutdown the computer before the 'battery low' signal follow proceed with the step

Step5. Fine tuning

This step is optional, but gives you more control over the UPS events handling. If you want to trunoff the computer before the low battery signal, then use following steps:
1. Edit /etc/ups/upsmon.conf and add following lines:
NOTIFYCMD /usr/sbin/upssched
NOTIFYFLAG ONLINE     EXEC
NOTIFYFLAG ONBATT     EXEC
NOTIFYFLAG LOWBATT    EXEC
NOTIFYFLAG FSD        EXEC
NOTIFYFLAG COMMOK     EXEC
NOTIFYFLAG COMMBAD    EXEC
NOTIFYFLAG SHUTDOWN   EXEC
NOTIFYFLAG REPLBATT   EXEC
NOTIFYFLAG NOCOMM     EXEC
NOTIFYFLAG NOPARENT   EXEC
2. Edit /etc/ups/upssched.conf and add following lines (it will allow you shutdown the computer after 15 seconds, after working on battery)
PIPEFN /var/run/nut/upssched.pipe
LOCKFN /var/run/nut/upssched.pipe
AT ONBATT * START-TIMER executeShutdown 15
AT ONLINE * CANCEL-TIMER executeShutdown
AT ONBATT * EXECUTE onBattery
AT ONLINE * EXECUTE onLine
AT NOCOMM * EXECUTE noComm
AT COMMBAD * EXECUTE commBad
AT COMMOK * EXECUTE commOk
3. Edit /usr/bin/upssched-cmd (see the exact file name from /usr/bin/upssched-cmd variable CMDSCRIPT) and add executeShutdown section similar to:
case $1 in
        upsgone)
                logger -t upssched-cmd "The UPS has been gone for awhile"
                ;;
        executeShutdown)
                shutdown -h now
                ;;
        onBattery)
                logger -t upssched-cmd "UPS is on battery!"
                ;;
        onLine)
                logger -t upssched-cmd "UPS is back online!"
                ;;
        noComm)
                logger -t upssched-cmd "No communication with the UPS device"
                ;;
        commBad)
                logger -t upssched-cmd "Communication with UPS device lost"
                ;;
        commOk)
                logger -t upssched-cmd "Communication with UPS device restored"
                ;;
        *)
                logger -t upssched-cmd "Unrecognized command: $1"
                ;;
esac

Tuesday, April 08, 2014

PermGen space leaks

The causes of PermGen space leaks:
  1. Thread left running after web-app undeployment - the context class loader of the thread is usually the class loader of the web application, so it contains all webapp classes.
  2. Using ThreadLocal with thread created by the web server - web app class is assigned to web server thread (e.g. HTTP worker thread) - the web app class holds a reference to the classloader, even if the web app is undeployed.
  3. Database driver leak - every database driver should register in  java.sql.DriverManager
    the web-app must deregister it from the there, otherwise it hold a reference to the web-app class loader, if the web app is undeploye

Wednesday, February 26, 2014

Fedora 20 remote desktop (vncserver)

In order to enable VNC access to Fedora 20 you must install vino
yum install vino
gsettings list-recursively org.gnome.Vino
Will give you all available vino configurations Not all VNC clients supports encrypted connections, so you may need to disable it.
gsettings set org.gnome.Vino require-encryption false
Also disable the prompt when somebody tries to connect
gsettings set org.gnome.Vino prompt-enabled false
Login in gnome shell go to Settings > Share and enable Screen sharing

Thursday, December 05, 2013

Establishing VPN connection under Linux

Installation

You need to install the package
sudo apt-get install pptp-linux

Configuration

Create new VPN connection:
sudo pptpsetup --create <tunnel> --server <my-vpn-server-ip> --username <vpn-user-name> --encrypt
Create routing for the connection - you need to create a new file in the directory /etc/ppp/ip-up.d/ that contains the route. The content of the file should looks similar to:
#!/bin/bash

# This script is called with the following arguments:
# Arg Name
# $1 Interface name
# $2 The tty
# $3 The link speed
# $4 Local IP number
# $5 Peer IP number
# $6 Optional ``ipparam'' value foo

ip route add 10.42.0.0/16 dev $1
You can take a look of the parameters in /etc/ppp/ip-up script

Establishing connection

sudo pon <tunnel>

Disconnecting

sudo poff <tunnel>

Debugging issues

Start the connection in debug mode
sudo pon <tunnel> debug dump logfd 2 nodetach
Show pon/poff log:
sudo plog

Manually adding route

sudo ip route add 10.42.0.0/16 dev ppp0

Adding new user from shell

To add new use execute following commands:

Creates the new user

sudo adduser <username>

Add the user to existing group

sudo usermod -aG <groupname> <username>

Create new group

sudo addgroup <groupname>

Sunday, September 15, 2013

F19 post installation steps

Gnome shell 3

Tweak tool

Install gnome-tweak-tool
sudo yum install gnome-tweak-tool
Then start it, go to Desktop and enable "Have file manager handle the desktop" Go to Shell and select "Show date in clock", and for "Arrangement of buttons on the titlebar" choose "All"

Themes

sudo yum install gnome-shell-extension-user-theme.noarch
sudo yum install gnome-themes
Then logout, login start gnome-tweak-tool go to Themes tab and select Crux for "Icon theme". Go to Shell extensions and enable "User themes". Close and open the gnome-tweak-tool. Now under Theme tab you have the "Shell theme" enabled.

Nautilus

Show hidden files

gsettings set org.gnome.nautilus.preferences show-hidden-files true

Show address bar instead of buttons for file path

gsettings set org.gnome.nautilus.preferences always-use-location-entry true

Ask what to do with executable files

gsettings set org.gnome.nautilus.preferences executable-text-activation 'ask'

Configuration

Admin rights

Add sudo capabilities to current user:
usermod -a -G wheel MY_USER

Transparent terminal

sudo yum install terminator

Grub theme

sudo yum install grub2-starfield-theme
Open /etc/default/grub file sudo gedit /etc/default/grub Make entry in /etc/default grub GRUB_THEME="/boot/grub2/themes/starfield/theme.txt" Update grub sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Additional software

RPMfusion repos

Go to http://rpmfusion.org/ and download corresponding version

Music player - XMMS

sudo yum install xmms xmms-faad2 xmms-mp3 xmms-pulse xmms-skins

Video players

mplayyer

sudo yum install mplayer gecko-mediaplayer mplayer-gui mencoder

VLC

sudo yum install vlc

Thursday, April 11, 2013

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object

C:\>java -version
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
First thing is to find out which java is used
c:\>where java.exe
C:\Windows\System32\java.exe
Ok this is the java wrapper that reads the registry and sets the JAVA_HOME from there. Open registry editor and go to the keys (replace 1.7 with the latest major version) HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.7 HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.7.0_17

Change the JavaHome to point to correct path.
Currently it is pointing to C:\Program Files\java\jre7. Alternativly you can use C:\Program Files\java\jdk1.7.0_17\jre
You can create a java.reg file and import it into registry.
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.7]

"JavaHome"="C:\\Program Files\\Java\\jdk1.7.0_17\\jre"
In my case the problem was faulty installation of the JRE.
I have two options:
  1. either live with alternative path C:\Program Files\java\jdk1.7.0_17\jre
  2. I can repair the JRE installation.

I choose option 2, so I copied everything from C:\Program Files\Java\jdk1.7.0_17\jre to C:\Program Files\java\jre7 (overriding the files).

Tuesday, November 22, 2011

Toplink throws NullPointerException in method _toplink.getXXX_vh()

If you persist JPA entities from another JVM sometimes Toplink throws very strange exception like:
Caused by: javax.persistence.EntityExistsException: 
Exception Description: The method [_toplink_getscore_vh] on the object [com.mycompany.data.GameEntity] triggered an exception.
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.NullPointerException
Mapping: oracle.toplink.essentials.mappings.OneToOneMapping[score]
Descriptor: RelationalDescriptor(com.mycompany.data.GameEntity --> [DatabaseTable(GAME_TABLE)])
 at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist(EntityManagerImpl.java:224)
 at com.sun.enterprise.util.EntityManagerWrapper.persist(EntityManagerWrapper.java:440)
 at com.mycompany.MyEjbBean.create(MyEjbBean.java:1647)
 ... 26 more
Caused by: Exception [TOPLINK-99] (Oracle TopLink Essentials - 2.1 (Build b31g-fcs (10/19/2009))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: The method [_toplink_getscore_vh] on the object [com.mycompany.data.GameEntity] triggered an exception.
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.NullPointerException
 at oracle.toplink.essentials.exceptions.DescriptorException.targetInvocationWhileGettingValueThruMethodAccessor(DescriptorException.java:1598)
 at oracle.toplink.essentials.internal.descriptors.MethodAttributeAccessor.getAttributeValueFromObject(MethodAttributeAccessor.java:98)
 at oracle.toplink.essentials.mappings.DatabaseMapping.getAttributeValueFromObject(DatabaseMapping.java:372)
 at oracle.toplink.essentials.mappings.ForeignReferenceMapping.getAttributeValueFromObject(ForeignReferenceMapping.java:322)
 at oracle.toplink.essentials.mappings.ObjectReferenceMapping.cascadeRegisterNewIfRequired(ObjectReferenceMapping.java:676)
 at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.cascadeRegisterNewForCreate(ObjectBuilder.java:1294)
 at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:3228)
 at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist(EntityManagerImpl.java:221)
 ... 28 more
Caused by: java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at oracle.toplink.essentials.internal.security.PrivilegedAccessHelper.invokeMethod(PrivilegedAccessHelper.java:322)
 at oracle.toplink.essentials.internal.descriptors.MethodAttributeAccessor.getAttributeValueFromObject(MethodAttributeAccessor.java:91)
 ... 34 more
Caused by: java.lang.NullPointerException
 at com.mycompany.data.GameEntity._toplink_getscore_vh(GameEntity.java)
 ... 40 more
javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
 java.rmi.RemoteException: null; nested exception is: 
 java.lang.RuntimeException: 
 at com.mycompany._MyEjbBean_Wrapper.create(com/mycompany/_MyEjbBean_Wrapper.java)
 at com.mycompany.GameTest.testGameScores(GameTest.java:62)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
 at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
The solution I found is to change the score property to be eager "@ManyToOne(fetch = FetchType.EAGER)" What I belive happens beneath is that Toplink uses bytecode to creates some additional methods for entity classes - see oracle.toplink.essentials.internal.weaving.TopLinkClassWeaver. For each field that is in relation, Toplink creates a new method called _toplink.getFIELDNAME_vh() and a class field called _toplink.getFIELDNAME_vh. VH stands for ValueHolder. I guess this additional methods/fields are used for fetching related objects later. If you examine the exception more closely it is thrown from inside _toplink.getscore_vh() which according to the javadoc in TopLinkClassWeaver should looks like:
public WeavedAttributeValueHolderInterface _toplink_getscore_vh(){
  if (_toplink_score_vh.isCoordinatedWithProperty() || _toplink_score_vh.isNewlyWeavedValueHolder()){
    EntityC object = getScore();
    if (object != _toplink_score_vh.getValue()){
      setScore(object);
    }
  }
  return _toplink_score_vh;
}
Obviously the only way to throw an exception is if _toplink_score_vh is null which after debuging is confirmed to be null. My guess is that because this is entity is transferred from another JVM (the JUnit test) and you are persisting it inside server JVM the value of _toplink_score_vh is not correctly transfered, which causes the above exception. I didn't dig up too much into the problem but the solution I found is - just make the field (in my case the "score") eager and the exception will go away.

Thursday, September 15, 2011

Forget to add administrators group to SQL server 2008

Yep shit happens...
If you forget to add the administrator group (or at least the current user) to admin groups, and do not know the SA password then you have only two options
- reinstall SQL server
- use single-user-mode to add the accounts

Ok now the single-user-mode procedure.
0) login with Administrator (exactly the Administrator user, with another administrator account there will be problems)
1) open services.msc
2) go the "SQL Server (xxx)" service and stop it
3) open "Sql server configuration manager" from the start menu and make sure that the protocols "Shared memory", "Named pipes", "TCP/IP" are enabled
4) Go back to the services console right click "SQL Server (xxx)" and select properties and then enter "-m" as parameter. Click start
5) Now the server is started in single-user mode
6) Open command prompt and execute following command "sqlcmd -S \ -E", where -S specifies server and instance name, -E specifies to use windows credentials

sqlcmd -S MYMACHINE\SQLEXPRESS -E

7) Execute following commands for each windows account that you want to add

CREATE LOGIN [MYMACHINE\Administrator] FROM WINDOWS
GO
exec sp_addsrvrolemember @loginame='MYMACHINE\Administrator', @rolename = 'sysadmin'
GO

8) Stop the SQL service and restart it without -m parameter.
9) Now you are able to log-in with Administrator user and you do have administrator rights on SQL server

Monday, September 12, 2011

Using older Java on Windows

When JDK 7 is installed it became the default java on the machine. However if you try to set different JDK (by JAVA_HOME and PATH variables) it won't change. The reason is that there is a c:\windows\system32\java.exe wrapper that reads the system registry and executes the java. If you try to change
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion to 1.6 you will get the following error:


C:\Windows\System32>java -help
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'

has value '1.6', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.


I found two solutions on this problem:
1) use -version:1.6 as parameter

java -version:1.6 -jar myprogram.jar

It will run the jar with version 1.6
Of course you can set it into some system property like JAVA_OPT (for tomcat)

2) Add JAVA_HOME environment variable, and put %JAVA_HOME%\bin before %SystemRoot%\system32.
So the JAVA_HOME\bin\java.exe will be found before the c:\windows\system32\java.exe wrapper.

Friday, August 26, 2011

Java 7 - project coin

Java 7 language syntax changes in nutshell (Project coin).


  • Strings in switch

  • Binary integral literals and underscores in numeric literals

  • Multi-catch and more precise rethrow

  • Improved type inference for generic instance creation (diamond)

  • try-with-resources statement

  • Simplified varargs method invocation





Strings in switch


public static boolean getBoolean(String s) { 

switch(s.toLowerCase()) {
case "true" : return true;
case "false" : return false;
default: throw new IllegalArgumentException("Invalid value. Only strings 'true' and 'false' are acceptable");
}
}


Binary integral literals and underscores in numeric literals



public static final int binaryNumber = 0b11111111_11111111;// 65535
public static final int hexNumber = 0xFF_FF;// 65535


Multi-catch and more precise rethrow



Multi-catch



try {
Class<?> c = Class.forName("java.lang.String");
Object o = c.newInstance();
Method m = c.getMethod("length");
System.out.println("Length = " + m.invoke(o));
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException
| InvocationTargetException | IllegalArgumentException | NoSuchMethodException ex ) {
ex.printStackTrace();
}


ReflectiveOperationException



try {
Class<?> c = Class.forName("java.lang.String");
Object o = c.newInstance();
Method m = c.getMethod("length");
System.out.println("Length = " + m.invoke(o));
} catch (ReflectiveOperationException ex ) {
// Now all reflection exception have super class ReflectiveOperationException
ex.printStackTrace();
}


more precise rethrow



public static class Exception1 extends Exception {}
public static class Exception2 extends Exception {}

public void morePreciseExceptionRethrow() throws Exception1, Exception2 {
try {
if (1==2) {
throw new Exception1();
} else {
throw new Exception2();
}
} catch (Exception ex) {
// here the compiler knows that only Exception1 and Exception2 are thrown from the code above. In JDK 1.6 you need to declare that the method is throwing Exception, but in JDK 1.7 you may declare only the exceptions really thrown.
throw ex;
}
}


Improved type inference for generic instance creation (diamond)



List list = new ArrayList<>();
Map> map = new TreeMap<>();


try-with-resources statement



public void copy(String srcFileName, String destFileName) throws IOException {
try(InputStream in = new FileInputStream(srcFileName); OutputStream out = new FileOutputStream(destFileName)){
byte[] buff = new byte[1024];
int n;
while ((n = in.read(buff)) != -1) {
out.write(buff, 0, n);
}
}
// here the in and out are closed
}



Simplified varargs method invocation


More details

Monday, July 04, 2011

Creating GIT projects based on SVN dumps

Following script will create new GIT projects based on SVN dump files.
As prerequisite you must have setup Gerrit codereview system. You need to allow the Gerrit user to directly push to master branch, otherwise all SVN commits need to be reviewed/verified, and for existing project this could means hundreds of commits.

Script:

#!/bin/bash
#!/bin/bash
GERRIT_IP=10.1.1.1
GERRIT_USER=xxx
GERRIT_PORT=29418

if [ -z "$1" ]; then
echo "Provide SVN dump file as first argument"
exit -1
fi

if [ ! -f $1 ]; then
echo "SVN dump $1 doesn't exists"
exit -1
fi

if [ -z "$2" ]; then
echo "Provide project name (that will be created in GIT) as second argument"
exit -2
fi

if [ -e $2 ]; then
echo "File or directory with name $2 already exists"
exit -2
fi


CURR_DIR=`pwd`

rm -Rf svnrepo
svnadmin create svnrepo/

svnadmin load svnrepo/ < $1
git svn clone file://$CURR_DIR/svnrepo/ $2
ssh -p $GERRIT_PORT -l $GERRIT_USER $GERRIT_IP gerrit create-project --name $2

# add origin
echo -e "[remote \"origin\"]" >> $2/.git/config
echo -e "\tfetch = +refs/heads/*:refs/remotes/origin/*" >> $2/.git/config
echo -e "\turl = ssh://$GERRIT_USER@$GERRIT_IP:$GERRIT_PORT/$2" >> $2/.git/config
echo -e "\tpush = HEAD:refs/for/master" >> $2/.git/config

# add originmaster
echo -e "[remote \"originmaster\"]" >> $2/.git/config
echo -e "\tfetch = +refs/heads/*:refs/remotes/origin/*" >> $2/.git/config
echo -e "\turl = ssh://$GERRIT_USER@$GERRIT_IP:$GERRIT_PORT/$2" >> $2/.git/config
echo -e "\tpush = HEAD:refs/heads/master" >> $2/.git/config

# add master branch config
echo -e "[branch \"master\"]" >> $2/.git/config
echo -e "\tremote = originmaster" >> $2/.git/config
echo -e "\tmerge = refs/heads/master" >> $2/.git/config


cd $2
git push originmaster
cd ..


In nutshell The script creates a dummy SVN repository, then use git-svn command to create local git project, creates a new project in Gerrit, adds Gerrit as remote repository to the local GIT configuration and finally pushes the changes to Gerrit

In order to use the script you need to provide a SVN dump file as first argument, and GIT project name as second argument

Saturday, July 02, 2011

Install Gerrit

1) Install tomcat.

2) Download/build gerrit.war to tomcat websapps directory

3) Create gerrit directory
mkdir /usr/share/gerrit


4) Initialize gerrit configurations
java -jar gerrit.war init -d /usr/share/gerrit


- Choose default values for all configuration except
- Choose authentication method HTTP
- Enter tomcat as "run-as user"
- Choose to Update/copy gerrit.war
- Choose to use Bouncy Castle

5) Edit /usr/share/gerrit/etc/gerrit.conf
and it modify it to looks like this:

[gerrit]
basePath = git
[database]
type = H2
database = db/ReviewDB
[auth]
type = LDAP
[sendemail]
smtpServer = localhost
[container]
user = tomcat
javaHome = /usr/lib/jvm/jdk1.6.0_26/jre
[sshd]
listenAddress = MYIP:8418
[httpd]
listenUrl = http://*:8282/
[cache]
directory = cache
[ldap]
server = ldap://MYIP:10389
username = uid=gerrit,ou=users,ou=system
password = gerrit
accountBase = ou=Users,dc=MYHOST
accountPattern = (&(objectClass=person)(uid=${username}))
accountFullName = displayName
accountEmailAddress = mail

groupBase = ou=Groups,dc=MYHOST
groupMemberPattern = (&(objectClass=groupOfUniqueNames)(uniquemember=${dn}))


Where you need to replace MYIP, MYHOST with the IP and the host name of the machine.
Note the LDAP configuration. We need to add gerrit user to ou=system and create the MYHOST domain structure.

6) Install ApacheDS LDAP server for user management. (There is a RPM package for Fedora, so just download and follow installation instructions).

7) We need to configure ApacheDS.
Open /var/lib/apacheds/default/conf/server.xml and add new partition
<jdbmPartition id="MYHOST" suffix="dc=MYHOST" optimizerEnabled="true" syncOnWrite="true" cacheSize="100"/gt;

Replace MYHOST with machine hostname.

Remove anonymous access
<defaultDirectoryService ... allowAnonymousAccess="false" ... >



7) Start the service
service apacheds start default



8) Install and Apache Directory Studio and connect to LDAP server
ldap://MYHOST:10389

where MYHOST is the hostname/IP address of the machine
The default username is "uid=admin,ou=system" and password is "secred"

Go to ou=system, and select uid=admin. Change the userPassword attribute with new password


9) Add new user to ApacheDS. Open Apache Directory Studio and import following LDIF

dn: uid=gerrit,ou=users,ou=system
objectClass: organizationalPerson
objectClass: person
objectClass: inetOrgPerson
objectClass: top
cn: gerrit administrator
sn: gerrit
displayName: Gerrit administrator
uid: gerrit
userPassword:: e1NIQX1PNWNIRFViTTFtUWlxT2U0UG1sbjdZUjRCVGc9

It contains a user gerrit and password gerrit

9) Create init.ldif file containing

#########################################################
# Root node for domain
#########################################################
dn: dc=MYHOST
objectClass: domain
objectClass: extensibleObject
objectClass: top
dc: MYHOST

#########################################################
# Root node for Users
#########################################################
# The node contains all users
dn: ou=Users,dc=MYHOST
objectClass: organizationalUnit
objectClass: top
ou: Users

#########################################################
# Root node for Groups
#########################################################
# Each group contains the user Ids assigned to the group
dn: ou=Groups,dc=MYHOST
objectClass: organizationalUnit
objectClass: top
ou: Groups

#########################################################
# Groups
#########################################################
dn: cn=admins,ou=Groups,dc=MYHOST
objectClass: groupOfUniqueNames
objectClass: top
cn: admins
description: Administrators group
uniquemember: uid=user1,ou=Users,dc=MYHOST

dn: cn=developers,ou=Groups,dc=MYHOST
objectClass: groupOfUniqueNames
objectClass: top
cn: developers
description: Developers group
uniquemember: uid=admin,ou=system
uniquemember: uid=user1,ou=Users,dc=MYHOST
uniquemember: uid=user1,ou=Users,dc=MYHOST

dn: cn=guests,ou=Groups,dc=MYHOST
objectClass: groupOfUniqueNames
objectClass: top
cn: guests
description: Guests group
uniquemember: uid=admin, ou=system

#########################################################
# Users
#########################################################
dn: uid=user1,ou=Users,dc=MYHOST
objectClass: organizationalPerson
objectClass: person
objectClass: extensibleObject
objectClass: uidObject
objectClass: inetOrgPerson
objectClass: top
cn: John Smith
givenname: John
sn: Smith
displayName: John Smith Jr.
mail: johnsmith@MYHOST
ou: Users
uid: user1
userpassword:: e1NIQX1zOXFuZTB3RXFWVWJoNEhRTVpIK0NZOHlYbWM9

dn: uid=user2,ou=Users,dc=MYHOST
objectClass: organizationalPerson
objectClass: person
objectClass: extensibleObject
objectClass: uidObject
objectClass: inetOrgPerson
objectClass: top
cn: Joe Doe
givenname: Joe
sn: Doe
displayName: terminator
mail: JoeDoe@MYHOST
ou: Users
uid: user2
userpassword:: e1NIQX1vWWdjQnU3SmJibVFISHUvNUJ4Q28vQ09uTFE9


Replace MYHOST with the name of the host. If your host have full domain name, then replace dc=MYHOST, with dc=mysubdomain,dc=mydomain,dc=com

The file describes a simple Groups/User hierarchy with 3 groups: admins,developers,users and 2 users: user1 (password:user1) and user2 (password:user2)

10) Using Apache Directory Studio import init.LDIF into LDAP server

11) Start tomcat service
service tomcat7 start


12) Stop tomcat service
service tomcat7 stop


13) Copy Bouncy castle jars to /usr/share/tomcat7/webapps/gerrit/WEB-INF/libs
cp /usr/share/gerrit/lib/bcprov-jdk16-144.jar /usr/share/tomcat7/webapps/gerrit/WEB-INF/lib


14) Start tomcat service and now you must be able to login to gerrit system with user1/user1 or user2/user2

15) Generating public/private keys.
Windows:
Download puttygen.exe and use it to generate a new private/public key. Use the menu Conversion / Export OpenSSH key to export the private key. Copy the OpenSHH public key (from the textbox)

Linux:
ssh-keygen -t rsa

Will generate /home/user/.ssh/id_rsa and /home/user/.ssh/id_rsa.pub
Copy the content of id_rsa.pub

16) Login into gerrit go to settigs, SSH key and paste the OpenSSH key (generated from the puttygen or ssh-keygen). Don't forget to click "Add"

17) Testing ssh connection. From Linux shell (or cygwin on windows boxes)
ssh -p 8418 -i <path to the private key> <gerrit IP/host>


18) Creating new project.
ssh -p 8418 -i <path to the private key> <gerrit IP/host> gerrit create-project -n <project name>


19) Go to Gerrit, choose "Admin" / "Projects" and select the newly created project.
Go to "Access" and add Submit,Push,Read permissions to "Registered Users" group

20) Cloning the newly created project for the first time.

git config --global user.name "Your Name"
git config --global user.email you@example.com
git config --global core.autocrlf false

git clone ssh://GERRIT_HOST:8418/PROJECT_NAME.git
cd PROJECT_NAME
git config remote.origin.push HEAD:refs/for/master
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
echo Hello > readme.txt
git add readme.txt
git commit -m "Initial commit"
git push

After that the warning messages "You appear to have cloned an empty repository." or "remote HEAD refers to nonexistent ref, unable to checkout." will disappear.

Monday, May 30, 2011

FC15 post installation steps

Gnome shell 3

Showing date in taskbar

gsettings set org.gnome.shell.clock show-date true

Showing date in taskbar

gsettings set org.gnome.shell.calendar show-weekdate true

Show week numbers in calendar

gsettings set org.gnome.shell.calendar show-weekdate true

Show minimize, maximize buttons

gconftool-2 -s -t string /desktop/gnome/shell/windows/button_layout "menu:minimize,maximize,close"

Always show power off in menu

yum install gnome-shell-extensions-alternative-status-menu
More info about available extensions can be found here

Tweak-tool

yum install gnome-tweak-tool
Then use start it go to Desktop and enable "Have file manager handle the desktop"

Taskbar

yum install tint2
Then use gnome-session-properties utility to add tint2 to gnome auto start programs (/usr/bin/tint2)

Nautilus

Show hidden files

gsettings set org.gnome.nautilus.preferences show-hidden-files true

Show address bar instead of buttons for file path

gsettings set org.gnome.nautilus.preferences always-use-location-entry true

Configurations

Additional repositories

Add RPM fusion repos:
su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm'

Admin rights

Add sudo capabilities to current user:
usermod -a -G wheel `whoami`

Startup theme

Change the startup theme:
sudo yum install plymouth-theme*

sudo plymouth-set-default-theme --list

sudo plymouth-set-default-theme solar -R

Keyboard mappings

Install gconf-editor:
sudo yum install gconf-editor
Now open gconf-editor from command line and do following modifications:

windows + D to show desktop

Find the key "/apps/metacity/global_keybindings/show_desktop" and set the value to "<mod4>D"

windows + R to run command

Find the key "/apps/metacity/global_keybindings/panel_run_dialog" and set the value to ""<mod4>R"

windows + L to lock screen

Find the key "/apps/metacity/global_keybindings/run_command_1" (or any other number and set the value to ""<mod4>L". Find the key "/apps/metacity/keybinding_commands/command_1" and set the value to "gnome-screensaver-command -l"

Windows aliases

notepad

sudo alternatives --install /usr/bin/notepad notepad /usr/bin/gedit 1

explorer

sudo alternatives --install /usr/bin/explorer explorer /usr/bin/nautilus 1

cmd

sudo alternatives --install /usr/bin/cmd cmd /usr/bin/gnome-terminal 1

Installing additional software

Music player - XMMS

sudo yum install xmms xmms-faad2 xmms-mp3 xmms-pulse xmms-skins

Video players

mplayyer

sudo yum install mplayer gecko-mediaplayer mplayer-gui mencoder

VLC

sudo yum install vlc

Gnome-tweak-tool

sudo yum install gnome-tweak-tool
It can be used to change variety of options. Go to "Windows" and change "Current theme" to "Crux". Go to "File manager" and change "Have file manager handle desktop" to "Yes".

MS fonts

sudo yum install rpm-build cabextract ttmkfdir wget xfs

sudo rpm -ih http://dl.atrpms.net/all/chkfontpath-1.10.1-2.fc14.x86_64.rpm

sudo wget http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec

sudo rpmbuild -ba msttcorefonts-2.0-1.spec

sudo yum install --nogpgcheck /root/rpmbuild/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm

Chrome

Go to www.google.com/chrome and follow instructions

Flash

Go to Adobe flash and choose linux 64 (Step1) and YUM 64 (Step2) Install the downloaded RPM it will add the adobe YUM repos. Install the real flash player with:
yum install flash-plugin nspluginwrapper.x86_64 nspluginwrapper.i686 alsa-plugins-pulseaudio.i686 libcurl.i686
Now Firefox should be able to play flash video (try it with youtube) In order to make Chrome playing flash videos executes following commands:
mkdir /opt/google/chrome/plugins
ln -s /usr/lib64/mozilla/plugins/libflashplayer.so /opt/google/chrome/plugins/libflashplayer.so

Skype

Go to http://www.skype.com/intl/en/get-skype/on-your-computer/linux/downloading.fedora and follow instructions

Show system information as background - conky

sudo yum install conky
Then use gnome-session-properties utility to add conky to gnome auto start programs (/usr/bin/conky)A simple configuration file /etc/conky/conky.conf
alignment top_right

background no

border_width 1

cpu_avg_samples 2

default_color white

default_outline_color white

default_shade_color white

draw_borders no

draw_graph_borders yes

draw_outline no

draw_shades no

use_xft yes

xftfont DejaVu Sans Mono:size=12

gap_x 5

gap_y 60

minimum_size 5 5

net_avg_samples 2

no_buffers yes

out_to_console no

out_to_stderr no

extra_newline no

own_window_transparent yes

own_window yes

own_window_class Conky

own_window_type desktop

stippled_borders 0

update_interval 1.0

uppercase no

use_spacer none

show_graph_scale no

show_graph_range noTEXT

#${scroll 32 $nodename - $sysname $kernel on $machine | }

$nodename - $sysname $kernel

$hr

${color grey}Uptime:$color $uptime

${color grey}Frequency (in GHz):$color $freq_g

${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}

${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}

${color grey}CPU Usage:$color $cpu% ${cpubar 4}

${color grey}Temperature:$color $acpitemp% ${color grey}Fan speed:$color $acpifan

${color grey}Processes:$color $processes  ${color grey}Running:$color $running_processes

$hr

${color grey}File systems:

/ $color${fs_used /}/${fs_size /} ${fs_bar 6 /}

${color grey}Networking:

Up:$color ${upspeed eth0} ${color grey} - Down:$color ${downspeed eth0}

$hr

${color grey}Name              PID   CPU%   MEM%

${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}

${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}

${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}

${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}

All the information is found by googling. You can find some very useful tips here and here and here
Thanks guys!

Tuesday, March 29, 2011

VNC server under F14

1) Install the vnc server by suing following command:
yum install tigervnc tigervnc-server


2) Under the user that will be used to login execute:
vncpasswd

This is the password that you will use to connect to the server

3) Configure the displays by editing /etc/sysconfig/vncservers
nano /etc/sysconfig/vncservers

Make sure that you have something like this
VNCSERVERS="1:the_user_that_is_used_for_vnc"
VNCSERVERARGS[1]="-geometry 1280x1024"


4) Then start the service for the first time:
service vncserver start


5) And make sure that the service is starting everytime you restart your machine:
chkconfig vncserver on


6) also don't forget to add firewall rules - use gnome tools from System / Administration / Firewall... Allow connections to port 5901

7) Now you can connect to the VNC server with ip and the display number e.g.: 192.160.0.254:1

Tuesday, March 01, 2011

How to list registered EJB beans in Glassfish

http://www.myeclipseide.com/PNphpBB2-viewtopic-t-18850.html

1) Open the Glassfish Admin Console
2) Select the "Application Server" tree node
3) In the "General" tab under "General Information" choose JNDI browsing
4) Under the "ejb" tree you can find all registered EJB beans