Ads

Sunday, October 25, 2009

Running JBoss as SERVICE on LINUX

While working on remote servers and running JBoss AS on it, sometimes gives hard bite to manage.
What if you encounter mentioned problems after starting JBoss AS:-

Connection lost to remote server?
Power failure at your end?
Connection failure at your end?
And what if you don't want to stop JBoss AS at remote server but you have to turn off your local system from where you have given command like ./run.sh -b xxx.yyy.zzz.aaa ?

JBoss instance would be running on remote server until you force fully kill it after getting back your connectivity.

Solution for this is Create JBoss SERVICE to run and stop :)

Now how to do that

Tuesday, September 29, 2009

Devlopement testing using JPA + JUnit

After hours of fight i am able to run Unit tests using JPA

So this is how it goes.

I am using in memory DB
c3p0 is a ComboPooledDataSource more details here
and of course HSQLDB

persistence.xml


<persistence xmlns="http://java.sun.com/xml/ns/persistence"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/persistence

http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

version="1.0">

<persistence-unit name="TestDB" transaction-type="RESOURCE_LOCAL">

<provider>org.hibernate.ejb.HibernatePersistence</provider>



<properties>

<property name="hibernate.hbm2ddl.auto" value="create"/>



<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>

<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>

<property name="hibernate.connection.url" value="jdbc:hsqldb:mem:testdb"/>

<property name="hibernate.connection.username" value="sa"/>

<property name="hibernate.connection.password" value=""/>



<property name="hibernate.c3p0.min_size" value="5"/>

<property name="hibernate.c3p0.max_size" value="20"/>

<property name="hibernate.c3p0.timeout" value="300"/>

<property name="hibernate.c3p0.max_statements" value="50"/>

<property name="hibernate.c3p0.idle_test_period" value="3000"/>



</properties>

</persistence-unit>

</persistence>



Test class

Tuesday, August 18, 2009

Creating Custom Events [JAIN-SLEE]

In a tough ride of JAIN-SLEE it is hard to remember everything on tips, to overcome such Stoppers creating this blog so that can refer it further :)

Step1 -----------------------

Create a public class which implements Serializable //Serializable for your convenient

Step2 -----------------------
That class should contain following methods

a public constructor with the parameters you want to pass when you fire an event

a public boolean equals method to check your current object is equals with passed argument

a private long Id would be generated at random when ever constructor is called

a public int hashcode method to return hash code value

getter methods of constructor's parameters

Example

import java.io.Serializable;
import java.util.Random;

import org.apache.log4j.Logger;

public class XyzEvent implements Serializable {

private long id;

private boolean successfull;

private static final Logger logger = Logger.getLogger(XyzEvent.class);

public MFToneDetected(boolean successfull) {
id = new Random().nextLong() ^ System.currentTimeMillis();
this.successfull= successfull;
}

public boolean equals(Object o) {
if (o == this)
return true;
if (o == null)
return false;
return (o instanceof XyzEvent) && ((XyzEvent) o).id == id;
}

public int hashCode() {
return (int) id;
}

public long getId() {
return id;
}

public boolean isSuccessfull(){
return successfull;
}

}

Step3 ------------------------

Now create Its event-jar.xml

which would look like this

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE event-jar PUBLIC "-//Sun Microsystems, Inc.//DTD JAIN SLEE Event 1.0//EN"

"http://java.sun.com/dtd/slee-event-jar_1_0.dtd">

<event-jar>

<event-definition>

<description>Custome Event</description>

<event-type-name>XyzEvent</event-type-name>

<event-type-vendor>org.sachin</event-type-vendor>

<event-type-version>1.0</event-type-version>

<event-class-name>XyzEvent</event-class-name>

</event-definition>

</event-jar>

Description could be any thing which describes cause of this event

Where the combination of event-type-name, event-type-vendor, and event-type-version makes it unique, in other words it would be identified by these defined three fields

And class name would be the name of class for which we are creating this event



Thats all we are Done with creation of Custom event ;)

Step4 ------------------------

Now comes step how to fire it from Sbbs

1st add mentioned code in SBB from which you want to fire this event suppose FireCustomEventSampleSbb

add event in FireCustomEventSampleSbb's sbb-jar.xml

<event event-direction="Fire">
<event-name>XyzEvent</event-name>
<event-type-ref>
<event-type-name>XyzEvent</event-type-name>

<event-type-vendor>org.sachin</event-type-vendor>

<event-type-version>1.0</event-type-version>
</event-type-ref>
</event>

event-direction should be Fire here

2nd add mentioned code to fire event in FireCustomEventSampleSbb

define abstract declaration of event

public abstract void fireXyzEvent(XyzEvent event,
ActivityContextInterface aci, javax.slee.Address address);

add this code from where you want to fire it

XyzEvent xyzEvent = new XyzEvent(true); //pass the values mentioned in XyzEvent class's cunstructor
fireXyzEvent(xyzEvent, this.getCustomEventACI(), null); //reffer SLEE API for parameter details

Step5 ------------------------

Sbb which is Listening to this custome event suppose ListenCustomEventSampleSbb

add event in ListenCustomEventSampleSbb's sbb-jar.xml

<event event-direction="Receive" initial-event="False">
<event-name>XyzEvent</event-name>
<event-type-ref>
<event-type-name>XyzEvent</event-type-name>

<event-type-vendor>org.sachin</event-type-vendor>

<event-type-version>1.0</event-type-version>
</event-type-ref>
</event>

add event listener ListenCustomEventSampleSbb

public void onXyzEvent(XyzEvent event,
ActivityContextInterface aci) {
}

Friday, July 17, 2009

Installing JEdit on ubuntu 8.04

Sometime i found much difficulty in opening JBoss's log files to solve it i came to know through my seniors about JEdit, which makes life easier to read Bcoded files to open at its ease ;)

jEdit is a mature programmer's text editor with hundreds (counting the time developing plugins) of person-years of development behind it. To download, install, and set up jEdit as quickly and painlessly as possible.

So here is the simplest way of installing JEdit text editor on ubuntu

sudo gedit
Hit the password

@gedit
open /etc/apt/sources.list

Add following lines at last

deb http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/j/je/jedit/ ./

deb-src http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/j/je/jedit/ ./

Save it and close it :)

now open console (command prompt) and do

sudo apt-get update

sudo apt-get install jedit

thats it done

on console type jedit it should be open and ready to serve

Cheersssss

Wednesday, July 15, 2009

Configuration between Mobicents Diameter Server and Client

Today after a long fight i am able to configure Mobicents Diameter Server and Client, thanks to Alex for his continues support ;)

So lets start with configuring with the provided details



@Server




Deployed Contents


Jain-Slee.x.y.z(mobicents.sar)
mobicents-diameter-mux-x.y.z.sar
diameter-base-ra-DU-x.y.z.jar
diameter-base-example-DU-x.y.z.jar

Configuration file settings

Sunday, July 12, 2009

Installing Flash For Linux (f4l-0.2.1) -Ubuntu 8.04

Flash for Linux project is a development environment for Macromedia Flash, a format widely used for web applications and vector animation.

More Details and Download it from

here

Extract tar file

cd f4l-0.2.1/

on make you may get this error
make
make: *** No rule to make target `/usr/share/qt3/mkspecs/default/qmake.conf', needed by `Makefile'. Stop.

try to install

sudo apt-get install qt3-dev-tools

this will resolve your problem :)

After that go for

make install

you may come across this error

In file included from FSDefineSound.cpp:22:
FSDefineSound.h:140: error: extra qualification ‘transform::FSDefineSound::’ on member ‘FSDefineSound’
make[1]: *** [FSDefineSound.o] Error 1


To resolve this error

Search FSDefineSound.h file open it with any Text Editor
go to line 140 find mentioned line there

FSDefineSound::FSDefineSound(int anIdentifier, int encoding, int rate, int channels, int sampleSize, int count, byte* bytes, size_t length);

make it to

FSDefineSound(int anIdentifier, int encoding, int rate, int channels, int sampleSize, int count, byte* bytes, size_t length);

then save the file and run it again (i.e. make install)

After that you may come across this error

In file included from canvasItem.cpp:18:
canvasItem.h:21:21: error: qcanvas.h: No such file or directory
canvasItem.h:22:25: error: qpointarray.h: No such file or directory
canvasItem.cpp:19:22: error: qpainter.h: No such file or directory
canvasItem.cpp:65:8: warning: "/*" within comment
In file included from canvasItem.cpp:18:

To resolve this problem try to install
sudo apt-get install libqt3-mt-dev

Do
make clean
make all

Hope Its install now Go bin directory and call
./f4l



Cheers

Tuesday, March 10, 2009

All about Diameter



Diameter is an Authentication, Authorization and Accounting (AAA) protocol developed by the Internet Engineering Task Force (IETF). Diameter is used to provide AAA services for a range of access technologies. Instead of building the protocol from scratch, Diameter is loosely based on the Remote Authentication Dial In User Service (RADIUS)1 [RFC2865], which has previously been used to provide AAA services, at least for dial-up and terminal server access environments.

The final Diameter protocol is actually split into two parts: Diameter Base Protocol and Diameter applications. The base protocol is needed for delivering Diameter data units, negotiating capabilities, handling errors and providing for extensibility. A Diameter application defines application-specific functions and data units. Each Diameter application is specified separately.

Diameter protocol uses both TCP and SCTP with IPsec(IP security) and TLS(Transport lavel security).

* Any node here can initiate request, since its a peer to peer protocol
* Each diameter node maintains peer tables (contains list of known peers)

Diagram Which shows Sh and Cx interface interaction using Diameter Protocol taking IMS in consideration



Base Message Code

274 Abort-Session-Request ASR
274 Abort-Session-Answer ASA
271 Accounting-Request ACR
271 Accounting-Answer ACA
257 Capabilities-Exchange-Request CER
257 Capabilities-Exchange-Answer CEA
280 Device-Watchdog-Request DWR
280 Device-Watchdog-Answer DWA
282 Disconnect-Peer-Request DPR
282 Disconnect-Peer-Answer DPA
258 Re-Auth-Request RAR
258 Re-Auth-Answer RAA
275 Session-Termination-Request STR
275 Session-Termination-Answer STA

Sh Message Code

306 User-Data-Request UDR
306 User-Data-Answer UDA
307 Profile-Update-Request PUR
307 Profile-Update-Answer PUA
308 Subscriber-Notification-Request SNR
308 Subscriber-Notification-Answer SNA
309 Push-Notification-Request PNR
309 Push-Notification-Answer PNA


Sip Message Code

283 User-Authorization-Request UAR
283 User-Authorization-Answer UAA
284 Server-Assignment-Request SAR
284 Server-Assignment-Answer SAA
285 Location-Info-Request LIR
285 Location-Info-Answer LIA
286 Multimedia-Authorization-Request MAR
286 Multimedia-Authorization-Answer MAA
287 Registration-Termination-Request RTR
287 Registration-Termination-Answer RTA
288 Push-Profile-Request PPR
288 Push-Profile-Answer PPA


AVP Codes with little description

Code Description References

--------------------------------------------
1
-
255 Radius attributes. RFC2865
--------------------------------------------
256 TBE
257 Host-IP-Address. RFC 3588
258 Auth-Application-Id. RFC 3588
259 Acct-Application-Id. RFC 3588
260 Vendor-Specific-Application-Id. RFC 3588
261 Redirect-Host-Usage. RFC 3588
262 Redirect-Max-Cache-Time. RFC 3588
263 Session-Id.
264 Origin-Host.
265 Supported-Vendor-Id.
266 Vendor-Id.
267 Firmware-Version.
268 Result-Code.
269 Product-Name.
270 Session-Binding.
271 Session-Server-Failover.
272 Multi-Round-Time-Out.
273 Disconnect-Cause.
274 Auth-Request-Type.
275 TBE
276 Auth-Grace-Period.
277 Auth-Session-State.
278 Origin-State-Id.
279 Failed-AVP.
280 Proxy-Host.
281 Error-Message.
282 Route-Record.
283 Destination-Realm.
284 Proxy-Info.
285 Re-Auth-Request-Type.
286 TBE
-
290
291 Authorization-Lifetime.
292 Redirect-Host.
293 Destination-Host.
294 Error-Reporting-Host.
295 Termination-Cause. RFC 4005
296 Origin-Realm.
297 Experimental-Result.
298 Experimental-Result-Code.
299 Inband-Security-Id.
300 Globallee unique Address
301 Address Realm
302 Logical Access Id
303 Initial Gate Setting
304 QoS Profile
305 IP Connectivity Status ES 283 034
306 Access Network Type
307 Aggregation Network Type
308 Maximum Allowed Bandwidth UL
309 Maximum Allowed Bandwidth DL
310 Maximum Priority
311 Transport Class
312 Application Class ID
313 Physical Access ID
314 Initial-Gate-Setting-ID
315 QoS-Profile-ID
------------------------------------------------------------------
316
-
349 Reserved for future use in ES 283 034
------------------------------------------------------------------
350 Location Information
351 RACS Contact Point
352 Terminal Type
353 Requested Information ES 283 035
354 Event-Type
355 Civic-Location
356 Geospatial-Location
500 Line-Identifier
-----------------------------------------------------------------
357
-
399 Reserved for future use in ES 283 035
----------------------------------------------------------------
400 Session Bundle Id
--------------------------------------------------------------------
401
-
439 Reserved for future use in ES 283 026
-------------------------------------------------------------------
440 Privacy-Indicator
------------------------------------------------------------------
441
-
449 Reserved for future use in TS 183 020 TS 183 020
-------------------------------------------------------------------
450 Binding information
451 Binding input list
452 Binding output list
453 V6 transport address
454 V4 transport address TS 183 017
455 Port number
456 Reservation class
457 Latching indication
458 Reservation priority
459 Service-Class
460 Overbooking-indicator
---------------------------------------------------------------------
461
-
499 Reserved for future use in TS 183 017
---------------------------------------------------------------------
501 ETSI-SIP-Authenticate
502 ETSI-SIP-Authorization
503 ETSI-SIP-Authentication-Info
504 ETSI-Digest-Realm
505 ETSI-Digest-Nonce
506 ETSI-Digest-Domain
507 ETSI-Digest-Opaque
508 ETSI-Digest-Stale
509 ETSI-Digest-Algorithm
510 ETSI-Digest-QoP
511 ETSI-Digest-HA1
512 ETSI-Digest-Auth-Param TS 183 033
513 ETSI-Digest-Username
514 ETSI-Digest-URI
515 ETSI-Digest-Response
516 ETSI-Digest-CNonce
517 ETSI-Digest-Nonce-Count
518 ETSI-Digest-Method
519 ETSI-Digest-Entity-Body-Hash
520 ETSI-Digest-Nextnonce
521 ETSI-Digest-Response-Auth
-------------------------------------------------------------------------
522
-
549 Reserved for future use in TS 183 033
------------------------------------------------------------------------
550 TBE
-----------------------------------------------------------------------
551
-
599 Reserved for future use in TS 183 060
------------------------------------------------------------------------
600 CNGCF-Address
601 SIP-Outbound-Proxy/Public-Identity
602 Server-Name
603 ACS-Server
604 Location-Data
------------------------------------------------------------------------
605
-
628 Supported-Features
629 Feature-List-ID
630 Feature-List
631 Supported-Applications

619 Reserved for future use in(remaining) TS 183 059
-----------------------------------------------------------------------
620 TBE
-----------------------------------------------------------------------
620
-
649 Reserved for future use
-------------------------------------------------------------------------
700 User-Identity/MSISDN
702 User-Data
701 TBE
703 Data-Reference
704 Service-Indication
705 Subs-Req-Type
706 Requested-Domain
707 Current-Location
708 Identity-Set


RFCs can be used for detailed study

Diameter Base Protocol RFC3588

The Diameter base protocol is intended to provide an Authentication,
Authorization and Accounting (AAA) framework for applications such as
network access or IP mobility. Diameter is also intended to work in
both local Authentication, Authorization & Accounting and roaming
situations. This document specifies the message format, transport,
error reporting, accounting and security services to be used by all
Diameter applications. The Diameter base application needs to be
supported by all Diameter implementations.

Diameter Session Initiation Protocol (SIP) Application RFC4740

This document specifies the Diameter Session Initiation Protocol
(SIP) application. This is a Diameter application that allows a
Diameter client to request authentication and authorization
information. This application is designed to be used in conjunction
with SIP and provides a Diameter client co-located with a SIP server,
with the ability to request the authentication of users and
authorization of SIP resources usage from a Diameter server.

IP Multimedia (IM) Subsystem Sh interface Signalling flows and message contents
3GPP TS 29.328 V5.9.0 (2005-03)

This document presents the Sh interface related functional requirements of the communicating entities.
It gives a functional classification of the procedures and describes the procedures and message parameters.
Error handling flows, protocol version identification.


Sh Interface based on the Diameter protocol details

3GPP TS 29.329 V5.8.0 (2004-12)

The Diameter Base Protocol as specified in IETF RFC 3588 [4] shall apply except as modified by the defined support of the methods and the defined support of the commands and AVPs, result and event codes specified in clause 6 of this specification.