Featured FREE Whitepapers

What's New Here?


Install Cloudera Manager 3.7.5 Free Edition

I recently installed Cloudera Manager Free Edition on my test cluster. I ran into a few problems during install so hopefully this will help you with your troubles.Cloudera Manager Free Edition will build and configure your single or multi-node CDH cluster and help you manage future changes to it. This software is free to use for up to 50 nodes with no term limit. Cloudera Documentation (PDF): https://ccp.cloudera.com/download/attachments/18779712/scm-3.7.5-free-installation-guide.pdf?version=2&modificationDate=1334944267000 To download and run the Cloudera Manager installer: 1. Download cloudera-manager-installer.bin from the Cloudera Downloads page wget http://archive.cloudera.com/cloudera-manager/installer/latest/cloudera-manager-installer.bin 2. After downloading cloudera-manager-installer.bin, change it to have executable permission. $ chmod u+x cloudera-manager-installer.bin 3. Run cloudera-manager-installer.bin. $ sudo ./cloudera-manager-installer.bin 4. Read the Cloudera Manager Readme and then click Next. 5. Read the Cloudera Manager License and then click Next. Click Yes to confirm you accept the license. 6. Read the Oracle Binary Code License Agreement and then click Next. Click Yes to confirm you accept the Oracle Binary Code License Agreement. The Cloudera Manager installer begins installing the Oracle JDK (if necessary), CDH3, and Cloudera Manager repo files and then installs the packages. The installer also installs the embedded PostgreSQL database and the Cloudera Manager Server. Note If an error message “Failed to start server” appears while running cloudera-managerinstaller.bin, exit the installation program. If the Cloudera Manager Server log file /var/log/cloudera-scm-server/cloudera-scm-server.log contains the following message, then it's likely you have SELinux enabled: Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... You can permanently disable SELinux by setting the following property in the /etc/selinux/config file on the Cloudera Manager Server host: SELINUX=disabled After editing the /etc/selinux/config file, reboot your system. 7. Click Close. 8. Click Finish to quit the installer program. Note If the installation is interrupted for some reason, you may need to clean up before you can re-run it. See Uninstalling Cloudera Manager Free Edition. Step 2: Start the Cloudera Manager Admin Console The Cloudera Manager Admin console enables you to use Cloudera Manager to configure, manage, and monitor Hadoop on your cluster. In this release, the Cloudera Manager Admin console supports the following browsers: • Internet Explorer 8 and 9 • Google Chrome • Safari 5Automated Installation of CDH by Cloudera Manager • Firefox 3.6 and later To start the Cloudera Manager Admin console: 1. In a web browser, type the following URL: http(s)://serverhost:port where: “serverhost” is the fully-qualified domain name or IP address of the host machine where the Cloudera Manager Server is installed. “port” is the port configured for the Cloudera Manager Server. The default port is 7180. For example, if you are on the host where the Cloudera Manager Server is installed, enter the following URL: http://localhost:7180/ If you are on another host, use a URL such as the following: http://myhost.example.com:7180/ The login screen for Cloudera Manager appears. 2. Log into Cloudera Manager. The default credentials are: Username: admin (you can add other admin user accounts and remove the default admin account later using Cloudera Manager after you run the wizard in the next section) Password: admin (you can change the default password later) Note You must have “ localhost” in your /etc/hosts file Test port 7180 by: telnet localhost 7180 Reference: Install Cloudera Manager 3.7.5 Free Edition CentOS 6.2 from our JCG partner Evan Conkle at the Evan Conkle’s blog blog....

Self-Service is the Future of Enterprise Software

Despite human desire to be pampered and served, there is a huge affinity to self service throughout the economy. Some samples: 1) Would you prefer to print your own boarding pass or have an agent do it for you? 2) Do you like taking your computer in for technical support or do you prefer to fix at home? 3) Do you want to call a restaurant for reservations or book it on OpenTable yourself? Given the right tools, humans prefer self service. Especially when its easy. Even more so if they get value out of doing it (ie OpenTable will learn what you like and make recommendations). If it starts to get hard, people might prefer some help. If it gets hard, people refuse self-service and at that point, forcing them into a self-service model will push them to seek alternatives. The future of enterprise software is self-service. Clients do not prefer to talk to sales people, but they have to, as a means to an end. Clients don’t like to hire consultants, but they have to when things get hard. Clients don’t want to take training classes, but they have to if the products are not intuitive. Despite the claims heard every day on Silicon Valley Radio (my term for the chatter), the future of enterprise software is not holistically SaaS/Cloud. SaaS and Cloud do not necessarily deliver self-service, but they can. Irrespective of delivery model (On-Premise, Saas, Cloud), I believe clients will migrate to software with the following attributes: 1) Available for download on a public website. 2) Intuitive use: no manuals, no training…unless desired. 3) No sales people, consultants, or meetings…unless desired. 4) Quick value, based on how the software is used. 5) The software understands what the user needs, so every usage is more valuable. Interestingly, I talk to very few companies that are focused on this. I am aware of only one that I think has done this quite well…and accordingly, they have been very successful. This is not easy, but it is the future of enterprise software. Don’t forget to share! Reference: Self-Service is the Future of Enterprise Software from our JCG partner Rob Thomas at the Rob’s Blog blog....

Spring Collection Merging

Spring collection merging is a feature that I first came across as an answer to a StackOverflow question It is a way of creating a base collection (list, set, map or properties) and modifying this base collection in other beans, best explained using an example –             Consider a Person class with a field holding a list of addresses: public class Person { private List<Address> addresses; .. } Assume that all Person instances have a common set of addresses, which can be specified using an abstract person bean this way: <bean name='basePerson' class='Person' abstract='true'> <property name='addresses'> <list> <bean class='Address' p:street='Street1' p:state='State1' p:zip='001'></bean> <bean class='Address' p:street='Street2' p:state='State2' p:zip='002'></bean> <bean class='Address' p:street='Street3' p:state='State3' p:zip='003'></bean> </list> </property> </bean> Now, Person bean instances with addresses in addition to the addresses from the basePerson can be specified using Collection Merging feature this way – note the ‘merge=true’ attribute of list: <bean name='person1' class='Person' parent='basePerson'> <property name='addresses'> <list merge='true'> <bean class='Address' p:street='Street4' p:state='State4' p:zip='004'></bean> </list> </property> </bean> Collection merging also works with <set/>, <map/> and <props/> With Spring 3.1 and higher, a simpler option though could be simply to use @Configuraion and @Bean options, as then the merging can be directly handled with Java code, for eg, an equivalent @Configuration for the above xml bean configuration: @Configuration public class CollectionConfig{ private List<Address> baseAddresses(){ return Lists.newArrayList(new Address('Street1', 'State1', '001'), new Address('Street2', 'State2', '002'), new Address('Street3', 'State3', '003')); } @Bean public Person person1(){ Person person1 = new Person(); person1.setAddresses(baseAddresses()); person1.getAddresses().add(new Address('Street4', 'State4', '004')); return person1; } } Reference: Spring Collection Merging from our JCG partner Biju Kunjummen at the all and sundry blog....

JavaOne 2012: NetBeans.Next – The Roadmap Ahead

I walked the few steps necessary from Continental Ballroom 4 and one NetBeans topic (Project Easel) to Continental Ballroom 5 to see another NetBeans-oriented presentation: ‘NetBeans.Next – The Roadmap Ahead.’Ashwin Rao started the Birds of a Feather (BoF) presentation and introduced John Ceccarelli and Tinuola Awopetu. Several audience members attended yesterday’s NetBeans Community Day. Rao showed the typical Oracle disclaimer slide about outlining ‘general product direction,’ but in this case (roadmap) it did seem particularly relevant. Rao talked about the ‘Motivation for Roadmap.’ This motivation includes ‘providing best end-to-end development experience for Java platform’ and supporting various Java releases as well as ‘HTML5 and popular languages and frameworks that complement and co-exist with the Java platform.’ He added that two main forces drive the NetBeans Roadmap: ‘Industry and Technology Trends’ and the ‘Java Platform Roadmap.’ Rao introduced the topic of ways to determine industry and technology trends including market analysis and community engagement. Awopetu then talked about how the community can use bug reports and RFEs (requests for enhancements) to relay to the NetBeans team the level of priority to apply to bugs and enhancements. She added that NetCAT (NetBeans Community Acceptance Testing program) is a main driver of what they work on. NetCAT users have contributed as many as 7,000 bugs/enhancements. Awopetu also stated that user satisfaction surveys and monitoring forum posts over the past 18 months have helped give them an idea of what the community wants in NetBeans. I was pleased to hear Ceccarelli state that they will be tackling NetBeans‘s known memory issues in the same way that they have tackled the scanning issues in NetBeans 7.2. It was pointed out that there is a command-line switch that can be used with NetBeans Rich Client Platform in production. One of the main motivations I had in attending this session was a peek at the road ahead. This chart came toward the end and was titled ‘The Road Ahead.’ Rao talked about NetBeans 7.3 (advanced HTML5 tooling, Oracle Public Cloud, and Java ME 3.2 and Embedded). He also cited Java EE 7 support (Avatar) and NetBeans JDK 8 support (Lambdas, JavaFX 8, and Java ME 8 and Embedded), and NetBeans JDK 9 support (Jigsaw). One audience member expressed interest in NetBeans supporting specific cloud vendors and warning when code is not compliant with a particular cloud provider. The lack of standardization in cloud is reminiscent of the lack of standards implementation in web development in the past and even to some degree today. Therefore, it’s not surprising that this would be a desirable feature to have. Another audience member wondered about a tool for code collaboration. I was interested in this question because I would love to see a NetBeans equivalent of the Code Collaborator plugin for Eclipse. It was explained that Kenai was a sponsored project that became Java.net, but Java.net support does not include code collaboration. It was stated that it is relatively easy to write GUI for code collaboration, but the repository is what is difficult. NetBeans will support Oracle Cloud ALM tools and there is some consideration of Github support. There is no plan to add WYSIWYG support for HTML/CSS/JavaScript to NetBeans and the audience seemed to be fine (and even welcome) that. It was explained that it is easier to do this with GWT, Oracle ADF, or other known deployments. It is difficult enough to make the editor work with JavaScript. Discussion of ‘Top Feature Requests’ with no delivery plans focused on three features not anticipated for NetBeans at this time:UML Visual Web Android/IOSThere was a large percentage of those in attendance who expressed interest (even if forced by employers and clients) in UML support. Based on this support, it was stated that ‘reports of UML death are overrated.’ It was also expressed that they would like to move JDeveloper’s UML into NetBeans. The team has moved much NetBeans functionality into JDeveloper, so this would be other direction. JDeveloper UML has been heavily used, but the many complaints about it led the NetBeans team to think it wasn’t wanted in NetBeans. For times I need to create UML, I too would like to see UML support available again in NetBeans. UPDATE – Apparently IntelliJ IDEA users also use UML frequently. Although NetBeans will not provide native support for Android or iOS, it was pointed out that there is a community Android plugin for NetBeans. Also, the NetBeans team may add PhoneGap support (PhoneGap allows for HTML/CSS/JavaScript to be used to write applications to 7 native mobile device formats) for Project Easel at some point in the future. Ceccarelli stated that his ‘job now is not to make NetBeans successful, but to make Java successful.’ He added that the ‘Java IDE wars are over.’ Each of the IDEs has pieces of other IDEs in it now. One of the compelling things for NetBeans in the short-term future will be the availability of HTML5 support in NetBeans with Project Easel. Reference: JavaOne 2012: NetBeans.Next – The Roadmap Ahead from our JCG partner Dustin Marx at the Inspired by Actual Events blog....

Android: Leaf fall-like animation using property animators

In the previous tutorial we explained how property animations work in general. Now we’ll go even further and explain how to create a property animation that would create leaf-falling-like effect for an ImageView in which we’ll, apparently put images of leaves. For that purpose we need few images that represent leaves. We found the ones we use in the example somewhere on the net, hopefully not infringing any designer’s work:If you don’t have anything better, get this images and use them. When you imagine a falling leaf represented in digital context you can notice three things:the leaf is falling down the leaf is rotating around its axes at some angle the leaf is making curve movementThese three properties would make the effect of a leaf falling down flown by the wind, taken off the tree. One thing that at this point we won’t implement is the curvic transformation since we plan to create separate tutorial about it, as extension to this one. So we would need to create translation and rotation, putting some more logics here and there. In Android sense, as we mentioned earlier the leaves would be ImageView objects. They would be created randomly and added to the root layout right before the animation starts. So we’ll need some timer that would knock-off the animation of a single leaf. Let’s say that we want new leaf every 5 seconds. So we’ll need timer that would send empty message, handled by a Handler object. When the message is handled (received), we get random leaf from a set of leaves (Drawables), create ImageView object and put the drawable as its contents, and add the imageview to the root layout of the activity. Then we call a method which in our case is named ‘startAnimation’ that would accept one ImageView object as parameter which will be animated. We do this in this way so that we leave space in the ‘startAnimation’ method where the ViewAnimator would be create, initialized and started, and also its listener. Let’s go again step by step. Let’s create the Handler object first: private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); int viewId = new Random().nextInt(LEAVES.length); Drawable d = getResources().getDrawable(LEAVES[viewId]); LayoutInflater inflate = LayoutInflater.from(FallAnimationActivity.this); ImageView leafImageView = (ImageView) inflate.inflate(R.layout.ani_image_view, null); leafImageView.setImageDrawable(d); mRootLayout.addView(leafImageView); LayoutParams animationLayout = (LayoutParams) leafImageView.getLayoutParams(); animationLayout.setMargins(0, (int)(-150*mScale), 0, 0); animationLayout.width = (int) (60*mScale); animationLayout.height = (int) (60*mScale); startAnimation(imageView); } }; The leafImageView object is inflated from XML so that we don’t have to create it programmatically, mScale is global field holding the density of the screen (used on few other places in the code, that’s why globally declared). After we add the leafImageView to the root layout we’ll programmatically set its top margin to 150dp in minus only to position it above the visible area of the screen. We create TimerTask like this: private class AnimTimerTask extends TimerTask { @Override public void run() { mHandler.sendEmptyMessage(0x001); } } and the TimerTask is executed like this, in our case in the onCreate method of the Activity: new Timer().schedule(new AnimTimerTask(), 0, 5000); This means, create new imageview every 5 seconds, add it to the root layout and start animation on it. Now back to the logic of the animation. As we previously mentioned we need a to translate to the bottom and side (x/y) and minor rotate animation. Both pivots (x and y) are the center of the axis, so the center of the leaf imageview. The delay before the animation starts is again calculated randomly as value between 0 and 6000 (milliseconds). The animator would be ofFloat from 0 to 1. For now, we set the animation to last for 10 seconds (10000 ms). That might be little fast so you can increase this value as you wish. What happens in the AnimatorUpdateListener is the following: The final ‘x’ position of the leaf imageview would be calculated as random value from 0 (left of the screen) and display’s width (right of the screen). Any point between this would be the ‘x’ final position. The final ‘y’ position of the leaf imageview would be display’s height/bottom, plus 150dp just to make the view not stop in the visible area. I like to make it fall to some point of display’s height + 10dp which would look just as if the leaf has fallen on the ground. This time, we make the leaf dissapear in the void of the screen. So now we have an imageview that goes from top to bottom where the x final position is random. But we miss 2 more things (rotation + curve animation) out of which we decided to implement only one more, the rotation. Let’s imagine the wind is not that strong so we need tremble-like effect for the leaf. An angle of 50 to 100 would be enough for this to take effect. One general rule to implement this would be this practice: Min + (int)(Math.random() * ((Max - Min) + 1)) In our case that’d be: 50 + (int)(Math.random() * 101) onAnimationUpdate is called till every last frame is done. Rotation and Translation are set here. Lastly we start the animator. Here is the whole method: public void startAnimation(final ImageView leafImageView) {leafImageView.setPivotX(leafImageView.getWidth()/2); leafImageView.setPivotY(leafImageView.getHeight()/2);long delay = new Random().nextInt(6000);final ValueAnimator animator = ValueAnimator.ofFloat(0, 1); animator.setDuration(10000); animator.setInterpolator(new AccelerateInterpolator()); animator.setStartDelay(delay);animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { int movex = new Random().nextInt(mDisplaySize.right); int angle = 50 + (int)(Math.random() * 101); @Override public void onAnimationUpdate(ValueAnimator animation) { float value = ((Float) (animation.getAnimatedValue())).floatValue(); leafImageView.setRotation(angle*value); leafImageView.setTranslationX((movex-40)*value); leafImageView.setTranslationY((mDisplaySize.bottom + (150*mScale))*value); } });animator.start(); } When we run this application we’re supposed to see something like this:We use this animation for our latest project which is in its latest polishing process. Also, download the sources and see if we’ve missed something or made a mistake explaining the code. Reference: Android: Leaf fall-like animation using property animators from our JCG partner Aleksandar Balalovski at the 2Dwarfs blog....

Tips for identifying and debugging problems

It seems that some/many developers haven’t developed (pun intended) a good set of techniques to identify and resolve problems. And problems always occur, even in simple programs. Recently I’ve been answering a lot of questions on StackOverflow and those questions confirmed my suspicions. Some of the advice here may sound like advice for newbies, but pactice shows they are needed. I’m a Java developer, but the tips below may be considered language-agnostic. Note that the steps are often regarding Exceptions, but in case there is no exception – just an undesired behaviour, those steps are skipped.Exception stacktraces – these are so often ignored and even considered irrelevant. Stacktraces are the place to start looking for the problem. Not only the exception message, but the line of code at which the exception occurred (in your code, in the library code). The code in question – after seeing what line of code causes the exception, immediately go to that line and see if the problem won’t become obvious. Try understanding the behaviour of the code (even if it is your code!). In case there is no exception, but an undesired behaviour, identify the code that is relevant Google – if it doesn’t become obvious, or the exception/problem occurred somewhere in a framework you are using, rather than in your code, then google the exception message or the problem description. Google it for 15 minutes, trimming various parts of the exception message – most importantly your package and class names. Most of the common exceptions occurring in popular frameworks are explained many times (because people skipped this step) Read the documentation – this is not always applicable, but in cases when the problem/exception regards a concrete component of the framework used, read the documentation about it. As the saying goes – 5 hours debugging save 20 minutes reading documentation Debugger – if there isn’t an obvious solution from the previous steps, use the debugger of your IDE. Put breakpoints at relevant places and trace the flow of the program. This will help you understand how exactly the program functions (again, even if it is your code). You will be able to monitor variables and fields, and see if their values are not the ones you expect Decompiler / framework source code – I’m always having a decompiler plugin installed on my IDE. It extends the process of looking at your own code to looking at all the code that’s involved. Alternatively, you can download/check-out the sources of the framework you are using (if it’s open-source) and add them to your IDE. Debugging with either the decompiled sources or the real sources can provide even more beneficial information about the problem, if you look at the appropriate places Finally, if you haven’t solved the problem – ask a question. In the forums of the framework/tool, in general forums (JavaRanch, Sun forums, etc), or in dedicated Q & A sites like StackOverflow. State the question clearly, show what have you already done in order to find/fix it, and give the appropriate information (setup, version of the framework, the code in question, the whole stacktrace, etc). At the same time try not to make the question too long and try to emphasize the main points – people that aren’t paid to answer will be reading it after all It sometimes happens that you have discovered a bug. This is a rare case with popular and mature frameworks/tools (yes!), but if you are sure it is a bug, go to the issue tracker and file a detailed bug report. They will either instruct you how to use a workaround, or will fix it eventuallyI’ve used words like “relevant” or “appropriate”. The degree of benefit from each step will depend on your experience, and each time you will get better at each of the steps. Don’t forget to share! Reference: Tips for Identifying and Debugging Problems from our JCG partner Bozhidar Bozhanov at the Bozho’s tech blog blog....

Spring3 + JPA2 + Java EE6 App Server = Confusion Over Configuration

Spring is great, JavaEE6 is great and latest JavaEE6 Application servers are also great. This post is not a rant on Spring Vs JavaEE6, but my experience of porting a Spring3+JPA2(Hibernate) application on JBoss AS-7.1 App Server. My application requirement is very simple: Developing a couple of SOAP based webservices using Spring3.1 and JPA2(Hibernate) and host it on JBoss AS 7.1. So I started creating a multi-module maven project with one jar module containing the service implementations using Spring & JPA and another war module which exposes those services as SOAP based webservices. But the key part is services needs to talk to multiple databases for some of the service methods. I am aware of JPA2 integration support from Spring without persistence.xml and cool packagesToScan attribute which makes life a bit easier. I configured 2 dataSources, 2 LocalContainerEntityManagerFactoryBeans, registered 2 JpaTransactionManagers and enabled Annotation based Transaction Management Support. <tx:annotation-driven transaction-manager='txnManager1'/> <tx:annotation-driven transaction-manager='txnManager2'/> <bean class='org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor'/> <bean class='org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor'/><!-- This will throw error because it found multiple EntityManagerFactory beans --> <bean id='txnManager1' class='org.springframework.orm.jpa.JpaTransactionManager' p:entityManagerFactory-ref='emf1'/> <bean id='txnManager2' class='org.springframework.orm.jpa.JpaTransactionManager' p:entityManagerFactory-ref='emf2'/> <bean id='emf1' class='org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'> <property name='persistenceUnitName' value='Sivalabs1PU'></property> <property name='dataSource' ref='dataSource1'></property> <property name='jpaVendorAdapter'> <bean id='jpaAdapter' class='org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter' p:showSql='${hibernate.show_sql}'/> </property> <property name='jpaProperties'> <props> <prop key='hibernate.dialect'>${hibernate.dialect}</prop> <prop key='hibernate.hbm2ddl.auto'>${hibernate.hbm2ddl.auto}</prop> </props> </property> <property name='packagesToScan' value='com.sivalabs.springdemo.entities'></property> <property name='loadTimeWeaver'> <bean class='org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver'/> </property> </bean> <bean id='emf2' class='org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'> <property name='persistenceUnitName' value='Sivalabs2PU'></property> <property name='dataSource' ref='dataSource2'></property> <property name='jpaVendorAdapter'> <bean id='jpaAdapter' class='org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter' p:showSql='${hibernate.show_sql}'/> </property> <property name='jpaProperties'> <props> <prop key='hibernate.dialect'>${hibernate.dialect}</prop> <prop key='hibernate.hbm2ddl.auto'>${hibernate.hbm2ddl.auto}</prop> </props> </property> <property name='packagesToScan' value='com.sivalabs.springdemo.entities'></property> <property name='loadTimeWeaver'> <bean class='org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver'/> </property> </bean> <bean id='dataSource1' class='org.apache.commons.dbcp.BasicDataSource'> <property name='driverClassName' value='${node1.jdbc.driverClassName}'></property> <property name='url' value='${node1.jdbc.url}'></property> <property name='username' value='${node1.jdbc.username}'></property> <property name='password' value='${node1.jdbc.password}'></property> </bean> <bean id='dataSource2' class='org.apache.commons.dbcp.BasicDataSource'> <property name='driverClassName' value='${node2.jdbc.driverClassName}'></property> <property name='url' value='${node2.jdbc.url}'></property> <property name='username' value='${node2.jdbc.username}'></property> <property name='password' value='${node2.jdbc.password}'></property> </bean> After this I realized to bind Entitymanager with the correct PersistenceUnit I need to give persistenceUnitName to LocalContainerEntityManagerFactoryBean. <bean class='org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor'> <property name='persistenceUnits' > <map> <entry key='unit1' value='Sivalabs1PU'/> <entry key='unit2' value='Sivalabs2PU'/> </map> </property> </bean> <bean id='emf1' class='org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'> <property name='persistenceUnitName' value='Sivalabs1PU'></property> <property name='dataSource' ref='dataSource1'></property> .... .... </bean> <bean id='emf2' class='org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'> <property name='persistenceUnitName' value='Sivalabs2PU'></property> <property name='dataSource' ref='dataSource2'></property> .... .... </bean> Then in my Service Bean EntityManagers and transaction managers are glued together as follows: @Service public class AdminUserService implements UserService { @PersistenceContext(unitName='Sivalabs1PU') private EntityManager sivalabs1EM; @PersistenceContext(unitName='Sivalabs2PU') private EntityManager sivalabs2EM; @Override @Transactional('txnManager1') public List<User> getAllUsersFromSivalabs1DB() { return sivalabs1EM.createQuery('from User', User.class).getResultList(); }@Override @Transactional('txnManager2') public List<User> getAllUsersFromSivalabs2DB() { return sivalabs2EM.createQuery('from User', User.class).getResultList(); } }With this setup now I got the Exception saying ‘ No persistence unit with name ‘Sivalabs1PU’ found’. Then after some googling I created META-INF/persistence.xml file as follows: <persistence><persistence-unit name='Sivalabs1PU' transaction-type='RESOURCE_LOCAL'> </persistence-unit> <persistence-unit name='Sivalabs2PU' transaction-type='RESOURCE_LOCAL'> </persistence-unit> </persistence> Now the persistence unit name error got resolved and got other Exception saying ‘ User is not mapped [from User]‘. The User class is annotated with @Entity and is in ‘ com.sivalabs.springdemo.entities‘ package which I configured to ‘ packagesToScan‘ attribute. I didn’t understand why ‘packagesToScan’ attribute is not working which is working fine without persistence.xml. So for time being I configured entity classes in persistence.xml file. <persistence><persistence-unit name='Sivalabs1PU' transaction-type='RESOURCE_LOCAL'> <class>com.sivalabs.springdemo.entities.User</class> </persistence-unit> <persistence-unit name='Sivalabs2PU' transaction-type='RESOURCE_LOCAL'> <class>com.sivalabs.springdemo.entities.User</class> </persistence-unit> </persistence> Finally when I ran my JUnit Test which invokes AdminUserService methods everything looks good and working fine. Then I deployed the war file on JBoss AS 7.1 Server then again got a bunch of errors. JBoss is complaining that ‘Connection cannot be null when ‘hibernate.dialect’ not set’ …. ‘[PersistenceUnit: Sivalabs1PU] Unable to build EntityManagerFactory’. After thinking for a couple of minutes, I understood that JBoss server is trying to do what it is supposed to do with ‘Convention Over Configuration’ rules. JBoss is trying to create EntityManagerFactory because it found META-INF/persistence.xml in classpath. But as it doesn’t contain jdbc connection details its throwing Error. Again after some googling I found we can rename persistence.xml to something else(spring-persistence.xml) and hook up this new name with Spring as follows: <bean id='emf1' class='org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'> <property name='persistenceUnitName' value='Sivalabs1PU'></property> <property name='persistenceXmlLocation' value='classpath:META-INF/spring-persistence.xml'/> <property name='dataSource' ref='dataSource1'></property> .... .... </bean> <bean id='emf2' class='org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'> <property name='persistenceUnitName' value='Sivalabs2PU'></property> <property name='persistenceXmlLocation' value='classpath:META-INF/spring-persistence.xml'/> <property name='dataSource' ref='dataSource2'></property> .... .... </bean> Finally I got this application working on my JBoss AS 7.1 successfully(Still I don’t know how many other holes are there that I haven’t yet found). But here I didn’t understand few Spring concepts: 1. When I try to give persistenceUnitName why Spring is checking for that name to be existed in persistence.xml? Anyway that persistence.xml doesn’t contain anything exception the unit-name!!2. Why packagesToScan mechanism is failing when used with persistence.xml? Is it a Spring Bug? Everything seems to be working fine except one thing is missing, a smile on my face which usually I have when working with Spring and Tomcat :-( I like Spring framework very much and I am using it since 2006 and I do enjoy while writing Spring code. That doesn’t mean I don’t like CDI, EJB3, JAX-RS :-) Anyway, with all the above exercise I feel like Spring3+JPA2+JavaEE6AppServer=Confusion Over Configuration and it is my(an average java developer) opinion only. Again say one more time : Spring is great, JavaEE6 is great and latest JavaEE6 Application servers are also great :-). Reference: Spring3+JPA2+JavaEE6AppServer = Confusion Over Configuration from our JCG partner Siva Reddy at the My Experiments on Technology blog....

Things Great Engineers (almost) Never Say

My job as a recruiter of software engineers and my 12 years as a user group leader have provided me the opportunity to speak with many talented technologists since entering the business in 1998, and through my interactions I’ve been able to notice several behavioral patterns shared by those that are considered to be the most skilled. To develop a profile of a candidate I ask many questions that can lead to a variety of answers, and I pay close attention to responses. Beyond behaviors, there are things that you hear in conversations with less skilled engineers that you don’t hear in talks with the best. Here is a list of quotes I sometimes will hear, but that I almost never hear from the engineers that are most coveted.“I’ve used _____ but I have no idea how it works” – Great engineers gained their skills through probing and curiosity. They go ‘under the hood’ of the products they use just to understand how things work, even if that information will never be very useful to them. It is unclear whether this need to dig deeper is a choice or a compulsion, but it seems that it is a trait of the best talent. “______ works, I just don’t know how to explain it” – Not only do the greats know how things work, but most of them derive genuine pleasure in telling others why and how things work. This is often true even if the other person doesn’t care to know. Over the course of my career I’ve listened to engineers talk for thousands of hours, and in almost all cases my conversations with the most talented go much longer. I actually made a point of scheduling an extra fifteen to twenty minutes on my calendar when I will be speaking to someone who appears to be great on paper, as I know that the person will go deep into some technical details and nuances that will come up in conversation. “I will need ______ (tool/condition) to complete this task” – The masters of development will have the ability to improvise and adjust on the fly to arrive at a solution in non-ideal conditions. When you hear of engineers being compared to MacGyver they are speaking of this very rare skill. Greats will figure out a way based on minimal resources and will be aware of alternatives to their first choice of tool. “I’ve learned all I want/will ever need to know about ________ “ – Continuous learning and improvement is probably the most obvious differentiation between the good and the great. They don’t just get to a high level and then rest. The best engineers understand that industry progress causes them to never stop learning, and if they are not gaining enough new knowledge in their day jobs they will invest the time to learn during off hours. “There is no solution” – The greats will continue looking at a problem different ways to come up with an answer instead of conceding. This characteristic can be both a blessing and a curse. “I hate programming” - At times a great engineer will hate their job or employer, but their love of solving problems with code is what brought them to this skill level. “I’m an expert in _____” (when it’s not true, and even sometimes when it is true) – The strongest engineers have no need or desire to lie or exaggerate the depth of their skills. Much of the great talent will be reluctant to say they are an expert in anything, as they are aware others could know more. “I don’t understand the business” – The stronger engineers will always want to know how their code impacts the employer and is able to describe their contribution and value to the organization. “I don’t pay particular attention to industry trends” – Being both great and relevant (in demand) is only possible if you keep an eye on where the industry is headed. When speaking to talented engineers, the topic of which new technologies are actually viable and which are a passing phase will often come up.If you find yourself using any of these lines on a regular basis, give some thought to why. Quoting one of these lines in a job interview could be a serious mistake. Reference: Things Great Engineers (almost) Never Say from our JCG partner Dave Fecak at the Job Tips For Geeks blog....

Using Hudson/Jenkins to diagnose that intermittent failure

I have been working on one of those intermittent bugs that just won’t reproduce on my machine; but will reproduce intermittently on other machines while they are running automated testing. I filled the code with trace statements, now I suspect the problem is in code that I don’t control and doesn’t appear to have much in the way of diagnostics in the place I am working on. So I did the obvious thing which is to run the tests on a loop on my machine overnight, 12 hours later and 8 test iterations later, no test failures and I am no further forward. Since the tests are failing in the Hudson farm, it make sense to try to connect the debugger up to those jobs; but I don’t want to hang around to attach the remove debugger to each. Thankfully there is a workaround that will allow me to set suitable breakpoints and manage the debugger connection for me. First of all you need to configure you IDE to accept incoming debugger connections, here are some notes on configuring JDeveloper for a listening debugger, in Netbeans you need to use the Debug->Attach menu item and select ‘SocketListen’ as the connector and configure as per JDeveloper. In Eclipse you need to configure the debug type as ‘Socket Listen’. The second step is modifying your build system so that there is a target you can call that will start the test cases in debug mode. This is an example of the parameters for one of our CI jobs that passes in the right information. Note of course the blacked out text the the name of then machine you are trying to connect back to. (The java tests are started with the parameter -agentlib:jdwp=transport=dt_socket,address=xxxx.oracle.com: 5000 ,server=n) Make sure that you don’t have any firewalls running on that machine that will block the in-coming connections.You probably will want to run to run multiple jobs at the same time if you have the nodes available, so consider checking this concurrent build box. Always a good idea to bring cakes / cookies into the office if you are going to tie up all the preflight nodes for the day.And then all that remains is to run a bunch of jobs and wait for your breakpoint to be hit, might take a little while; but it is going be quicker than running these jobs in series on your own machine. And if your farm is Heterogeneous so much the better for reproducing intermittent failures.You can sit back and then wait for your code to fail….. may I suggest some sessions from JavaOne while you wait? Reference: Using Hudson/Jenkins to diagnose that intermittent failure from our JCG partner Gerard Davison at the Gerard Davison’s blog blog....

Bad developer – good boss

While I am typing this, some developer is creating his kick-off application that will make him a millionaire. Well ok, wealthy enough to sustain his small business and motivate him to create more. At this moment some other developer is publishing his revolutionary application or game on Google Play store or Apple’s Appstore or a website out there. High hopes and hard work. Might change their lives. These small ways to make money or become popular do change our lives. Not only from perspective that the new software innovations ease our lives, but also from the perspective of the changer, of those that build things for which people would say “thank you for this!!” or “you saved me so much time!”. “Sliding tackle” beginning But developers at some point have to start somewhere. They have to learn to solve the easy-to-bypass problems the hard way. And most probably they’ll do it in the first company that will give them an offer. And so it begins their professional life as developers. In my experience, it’s been quite a long road so far. I’ve seen much and committed lots of lines of code (out of which only small percentage on distributed VCS). So I figured out that maybe I need to share that experience. Not that I want to warn someone about something or show-off infront of the other developers. Simply, because I miss those days when I was at the beginning of my learning process. Curvy and edgy. Well this might sound a bit old and cliche, but I have to say it again. Software development at home has nothing to do with corporate-driven software development. When the developer goes into corporate environment, he’s simply thrown into the boiling oil. Into the pan. If he does not jump off the pan there is big chance that he will survive the process afterwards. The problem is what comes afterwards and why would most of the developers allow treatment that they do not deserve? Not because they are developers, but because they are humans. When we go behind the cubicle we need to understand at the beginning, there is a big chance that behind those walls are money hungry people that look at you as their resource (or body ). Not much space for love (ok, not in that sense). This sounds bad and aggressive. It seems that it puts every manager, boss or supervisor in the same basket. While I believe that there are pretty nice and caring bosses, I also know that out of 5 companies I have worked with, only 1 had the characteristic to be polite enough so that I felt comfortable whenever I got sick, had to finish something at the bank or had a bike accident. Of course there are good and nice bosses to which we offer our humble appreciations, but also there is other side.Knowing it Not sure if your boss knows it, but you know it. They are doing it wrong. And should you be quiet about it. You go at work, see all those mistakes they make, get your salary, do your thing, go home, eat, sleep, live with the disease until you notice that it has eaten all of your career. Ok. No. Just go and tell them about the problem. They will not agree and there is a fat chance they’ll change their opinion about the calm and obedient employer they talked to yesterday. But would you care? From this perspective I cannot care less. Why? Because when you quit your position in few years, well again there is big chance that nobody will remember you. Maybe painful, but it’s true. Ok, if you didn’t invent the next big thing out there on the web or assembled the best Android tablet the human eye has seen, then you are forgotten in two days. And no one cares. Being honest about what you consider wrong in your environment is crucial and you should always talk to your boss(es). It’s not that personal thing rather than it’s general for the good of the company. The company would benefit, you would also, and what’s most important, the collective will. And those that come after you. People should always point to the mistakes other people do. Not by making fun of them but by talking with them about it. On your way to being the best developer the solar system has known, you’ll be seeing things like bad business strategy, bad logistics within the company, ugly project management and lots of milk in the coffee. And showing your opinion in public is the best tool to change that. It’s much better than complaining on your breaks and not taking any action. ( hitting the drums while jumping on your desk yelling about the problem is not something I also suggest ). While working on one of my first big projects as C++ developer, which happened to be a multi-platform desktop application and my first serious project I worked on as junior developer, I had the feeling that the leading project manager was underestimating the things that everyone else except the team-lead (senior developer) was proposing. Why that behaviour, I might guess, but that didn’t make me be silent. At some points I was trying to organize meetings on which I’d openly mention the problems I thought were hanging over the project. Not always was I right, but as the time passed, it turned out that on some occasions I really was. The thing that the less experienced observer sees is pretty hard for the experienced executor to notice. Always try to appreciate everyone’s opinion just as you’d like yours to be appreciated. If you have an idea on the project, on the business plan or the project management share it even if it’s not considered at all. After all, that way you build your professional inclusion in the decision making for the good of the company. Punishment Punishment is so 2012. BC . Punishment creates rage and rage turns into resentment. Why would you like to make the employees dissatisfied? No idea. But I know why you should make your developers satisfied. Because they are the final key in the chain of production. Keep your camel slaked in the desert. Working for the same company mentioned earlier I was once called at the .. well, let’s say boss’ office and told to remove a retweet about other company’s job opportunity. I even got warned that if I don’t do that I might be suspended or even fired for destroying company’s reputation on the social networks. That, I might add, was one of the last drops in the glass of reasons to quit that job. Few weeks later I resigned. And why? Because I was fed with the ignorance of the people, with their superiority complex and the way they were resolving situations. Never tolerate punishment as a way to force proper way of work. Managers should talk to their employees before doing anything stupid that would make them feel less valuable in the collective. Of course, I don’t say that developers or any other employee does not make mistakes. But guessing we are people, I bet there are much civilized ways to solve similar situations. An estimation is something you create so that you get the general idea behind the project by disassembling the requirements. Also you make use of an estimation to protect the business value of the company’s attempt to finish a certain project successfully by estimating its costs for delivery. That said, the primary purpose of the estimation is to serve the developer and then the company.Estimation Estimation is something that the developer must do and the employer must respect. It’s simple math. If I can walk from point A to point B with a pot full of water in 10 minutes, where the main rule is not to pour more than 10% from the content of the pot, than the two-way walk would most probably take me at about 20 minutes. Of course I can run on the way back and get at the final destination in 12 minutes, but the thing is that most probably I’d lose half of the water running. And that might not be a problem again, if the company doesn’t mind lousy software and spaghetti code, developer should be fine with that. The problem comes when the developer is forced to run with a pot full of water from Washington to Los Angeles in 2 days, without pouring 50% of the water from the pot. That would be the same as when working on delivering a software solution. People tend to cut off developers estimations or even give an estimation for themselves for a project that would not be carried by them which is something the developer, regardless to his level of experience should not allow. Let’s not get this idea wrong and say that there should never be a case when the developer should not hurry and try to accomplish something which is urgent and suddenly popped up as problem (“shoot for the stars and hit the moon”-kind of bullshit). I am trying to highlight that the general practice is not to take into consideration the estimation given by the guy or team that would create the final product. And that unfortunately is commonly seen in most of the companies out there. And in reality the process of estimation and delivery is something totally different. When someone gives you an estimation try to see if there are any overestimates or underestimates, if not try to respect that estimation. Because it’s a way of telling you I can deliver this in x days, anything before that would be forced and with poor quality. Also, when someone gives you an estimation for a project it’s because you asked for it. If you can modify it and adapt the estimation to the business needs then you should’ve never asked for an estimation from technical perspective. What you might need in that case is a project management estimation where the development estimate would be mentioned as time in some range. And after all, you never take things off the estimation. If you remove an estimate, do tell the one that created the estimation. Your need for business value hunting time over quality has nothing to do with the developer. If you want to play it that way, figure out how to do it by yourself. Most often the thing that is taken out of the estimation is the QA time the developer or the QA engineer has estimated. The developer should not allow this. QA is important process and not only helps the delivery of the project it validates the abilities of the developer(s) to deliver bug-free solution, something all developers should aim to.Clients from hell How to handle clients that request from you to build proper software solution but do not give the proper requirements list or specification? Well it’s quite simple and there are two ways to do that. The first would be if you work for a company where the client has been negotiating with your bosses about the nature of the project and the requirements that need to be fulfilled. In that case, you as developer have the buffer between you and the client. And trust me about something when I say that in that case the client should not be aware of who is the lead developer of the project, has his Skype, Email or GTalk contacts. Why? Because the first time some angry client sends feedback about something that you’ve messed up (regardless whose fault it is) would be you. And your bosses in CC. So the first step in keeping your client satisfied in corporate-driven environment is making clear about everything you need to do and getting everything you need before he changes his mind. And document every single communication, every meeting (yes, create MoM and forward it to your boss after you finish) that you have with the client. That way you’ll skip the nonsense you’ll have to go through when the client points his finger at someone. Another advice on avoiding a bad client when you don’t work in a company and do your staff at home as freelancer or company of your own is not choosing a bad client in the first place. Bad clients would occupy your time, would make you lose money (since you lose time) and demotivate you to finish the project properly. And motivation is 90% of the work. The first symptoms for a bad client that your bosses can’t handle is change with the wind directives (just as Mark Berry would say) and not providing specification. One of the clients that comes first in mind when thinking about such situations has delivered a specification to me (on my email to be precise) which was actually a Powerpoint file (.ppt) that had screenshots of another application, photoshopped with red-text explanations. That was the first specification I received in the company where I worked at that time and the first specification of that kind. However, being inexperienced and trying to prove myself in the new environment I got into, I accepted the document as SRS. The initial estimation was month and a half. It took 11 months to finish the project. Because of two things. The development finished right on time, but then begun the fixing (QA) phase where the client would report 10 issues today and 120 tomorrow. At some point his fixing process turned into feature/change-requests where we had to do additional development and then by changing his mind, get everything back to its place just like it used to be before. 11 months for something that I, personally would have made thousands of dollars if I have released it in the first 3 months. I might have received negative feedback from the users, but I like to stick to release early, release often philosophy, delivering period updates with fixes to problems reported by real users and not by the imaginary friends in my client’s head. After all, the whole company, the client and me as developer lost so much time, motivation, money and temper to work further on new projects. Always request specification, features-list or whatever that defines the project.Unhealthy growth Companies grow and get filled with dirt every single day. The expensive entrepreneur to whom you gave this month’s salary would say that is natural process of every company but what I think it is, it’s unhealthy development of the company. Let’s put ourselves in the general idea of a small company. We have 5 developers and 3 project managers, we have 2 bosses (let’s say CTO and CEO). Project managers should do one simple task called measurement. They get the specifications, estimations, risks and measure it all together. They might control the behaviour of the employers that they lead but at no point (if not precisely said) project managers are developer’s bosses. And most of us have the opposite experience, project managers behaving as bosses. And this is not the real problem regarding the growth of the company. The problem comes when the mentioned CTO and CEO decide that it’d be quite easier if they employ 2 more project managers, making them equal with the number of developers. And then the games begin. These 2 managers will be the lead managers, the others are just project coordinators, and yet every developer would have single project manager. Nonsense! Let’s face it. Developers are tough category to handle. You cannot pressure them with your stupid egos and complexes from home. You do what you need to do and don’t bother the others with less important issues. Project managers should stop being proxies between the developers and the top management. Forwarding an email to few more people in the company is something everyone can do. Developers don’t need secretaries to resend their emails, they need managers to handle the changes, risks and constraints in the development process. And yes, development process is quite a magic and shit happens. Putting more project managers in one company makes the things worse. What the project managers commonly do in the software-development world is something 70% of the developers can do themselves. You cannot say the opposite. Don’t forget to share! Reference: Bad developer – good boss (I), Bad developer – good boss (II) from our JCG partner Aleksandar Balalovski at the 2Dwarfs blog....
Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below: