JBoss 7.x : Retrieve Datasource properties ( username, database name, password) at runtime, using JMX

Introduction

Working with database connections, on enterprise application servers like JBoss, is in 99.9% very simple and well standardized. After configuring your environment, you can use JPA in order to handle all database interactions. In that way, you do not need to create any database connections or bother what is the name of: database, username/password as well as datasource name. However, there is this 0.1% of cases in which your application is extraordinary (been there ;-) ) and you need to have some more information and control over your database connections. If you do, in this post you will find how to retrieve properties describing predefined Datasources and will also get idea how to call mbeans methods or get other attributes.

If you just need a list of available datasources, without their properties, you can read this post: list available datasources on JBoss 7. 
If you work on JBoss 6, then follow this article: Datasource Properties on JBoss 6.x

Read more of this post

Advertisements

JBoss 7: Retrieve list of configured datasources at runtime

Introduction

Working with database connections on enterprise application servers like JBoss is in 99.9% very simple and well standardized. After configuring your environment, you can use JPA in order to handle all database interactions. In that way, during coding, you do not need to create any database connections or bother what is the name of database as well as datasource name. However, there is this 0.1% of cases in which your application is extraordinary (been there ;-) ) and you need to have some more information and control over your database connections. If you do, in this post you will find how to retrieve a list of available datasources.
Read more of this post

JBoss 6.x : Retrieve Datasource properties ( username, database name, password) at runtime, using JMX

Introduction

Working with database connections on enterprise application servers like JBoss is in 99.9% very simple and well standardized. After configuring your environment, you can use JPA in order to handle all database interactions. In that way, you do not need to create any database connections or bother what is the name of: database, username/password as well as datasource name. However, there is this 0.1% of cases in which your application is extraordinary (been there ;-) ) and you need to have some more information and control over your database connections. If you do, in this post you will find how to retrieve properties describing predefined Datasources.

If you just need a list of available datasources, without their properties, you can read this post: list available datasources on JBoss 6.

Read more of this post

JBoss 6 : Retrieve list of configured datasources at runtime

Introduction

Working with database connections on enterprise application servers like JBoss is in 99.9% very simple and well standardized. What one needs to do is:

  1. Configure datasources (*-DS.xml files)
  2. Configure persistence units in persistence.xml file
  3. Use dependency injection (@PersistenceContext(unitName=”pUnit”)) in order to obtain EntityManager

, and voilà: you are ready to work with defined databases. In your code you do not need to create any database connections or bother what is the name of database, username/password as well as datasource name. However, there is this 0.1% of cases in which your application is  extraordinary (been there 😉 ) and you need to have some more information and control over db-layers or you just simply need it for some reason I cannot even imagine 🙂 If you do, in this post you will find how to retrieve a list of available datasources.

Read more of this post

gwt 2.0.x gilead hibernate tutorial

UPDATE: 05.08.2013

If you came to this blog in order to learn how to manage Data transfer from Server layer to the GWT layer, please note that since 2010 GWT team has introduced new and comfortable way to do that. The mechanism is called Request Factory and you can read more about it here:  http://www.gwtproject.org/doc/latest/DevGuideRequestFactory.html.

If you run to any problems you can check my other blog post where I explain how the most common update/save workflow works in Request Factory: exciting life of entity proxies.

UPDATE: 14.10.2010 – official GWT 2.1 .RC release with Request Factory

When I was writing this tutorial, there was no official GWT support for sending Entities from server to client side.  Since GWT 2.1.rc is officially released the suggested way to connect JPA or Hibernate with GWT is to use RequestFactory. Read more on : http://code.google.com/webtoolkit/doc/trunk/DevGuideRequestFactory.html.
If you are interested in gilead with gwt 2.0.4 anyway you can still read my tutorial:)
afd

GWT Gilead tutorial – what for?

Writing client code in GWT is very nice way to produce user layout fast and easy. But when you need to get some data from the database.. debate begins. GWT has some restrictions which don’t allow you to use every framework in  every way you want. Especially if you are using object relational mapping frameworks you need to make some workaround if you want to send your entities to the client side.  E.g. you can use Data Transfer Objects (DTO) – which in some cases may be good because they encourage you to send only this information which you really need to show. But still you have to take care of cloning all your entities..
Another solution is using Gilead framework, which takes care about serializing your entities also handling lazy loaded parameters. There are some examples on the web how to use it but I haven’t found any example with the newest version of gilead and gwt as well with annotated hibernate entities.  That is why I have decided to share the steps I have made to configure such a project.
I will present you already working GWT project example which doesn’t have Gilead support. Then I will describe steps you need to take to add Gilead framework to it. If you are lazy you can just download the final version of project which is configured and ready to go.

GWT 2.0 + chrome = Unsafe JavaScript attempt to access frame with URL …

Problem description

Some time ago I have made some application in GWT 2.0, then I have compiled it and wanted to test it under Chrome browser. The effect was suprising.. google product does not work with another google product. … I have got an error message from Chrome Console:

Unsafe JavaScript attempt to access frame with URL file:///C:/workspace/war/Blog_Demonstrations.html       from frame with URL file:///C:/workspace/war/blog_demonstrations/3AA8DD86E4E2DF30F0E5F461485CF698.cache.html.  Domains, protocols and ports must match.

followed by:

Uncaught TypeError: Property ‘gwtOnLoad’ of object [object DOMWindow] is not a function

Anyway I have uploaded my application on a web-server and it appeared to work.

Why there is an error

Today I had the same problem so I’ve investigated it a little bit more.. What I have found out is : this is Chrome problem (calling it bug may be to harsh). It happens because Chrome has stricter Same-Origin-Policy than another browsers.  This policy doesn’t allow web-applications to open (via JavaScirpt) files from the file-system (they apparently are not from the same origin;] ).

Workaround solution    for testing your application on local enviroment

Solution for this problem may be sending your static HTML page files to web server. You can even use your local Server (like Jetty).

I am using temporary solution to test my compiled GWT applications under Chrome browser:

0)  launch Launch your project in development mode ( Ctrl+ F11 in Eclipse). ( The point is just to launch the server)

1)  add folder In war directory of your application create folder “chrome-test

2) gwt icon Compile your GWT project . ( all static output should be created )

3) copy Copy all output to chrome-test directory. But remember NOT TO copy WEB-INF directory. My war folder after doing this operation looks like this:war directory

4) go to web site go to  http://127.0.0.1:YOUR_PORT_NUMBER/chrome-test/YOUR_INDEX.HTML

What you will see, will be compiled static gwt-page.  You can see difference between compiled page and page hosted by server by calling

GWT.isScript()

Method. If it will return true it means that page you are viewing was generated by JavaScript, otherwise what you are looking at was generated by bytecode (so it is hosted java code).

Links

bug trace from chrome dev site: http://code.google.com/p/chromium/issues/detail?id=31068


GWT balloon widget

What is Balloon widget

It is a simple widget which shows up with some information for the user. Its appearance is proceeded by some user action, like filling a form or choosing some option from the menu. It can e.g. look like this:

balloon example Read more of this post

GWT Animation – small review

Since GWT 1.5 developers can use simple animated objects. Animation is a useful tool to change properties of widget  components in continuous way. (which seems to be more friendly to end-user, when using for rational purposes).

Animation is very easy to use, you just have to extend Animation class and override onUpdate() method. Let’s see how it works in simple example

Update 1013.10.11: If you would like to see more modern way to add animations to your project, read my post about Animations with GQuery

Read more of this post