Java compiler level does not match the version of the installed Java project facet: Faceted Project Problem (Java Version Mismatch)

Standard

This means the version of a project facet does not match the version of the compiler. I was getting this error on Eclipse Mars. I did the following to fix this:

  1. Open the project properties.
  2. Select “Project Facet” from the left¬†pane.

post1

3. Click on the version beside “Java” facet. Select the one that matches your compiler version.

post2.jpg

For me it was Java 7, so I selected 1.7.

That’s it. The error was gone.

 

When Jboss scheduler throws InstanceNotFoundException: ayeshaSilvia’s Blog

Standard

The Jboss service was running just fine when triggered from JMX-Console. But when it was run by the scheduler, it was throwing InstanceNotFoundException. I found the solution on StackOverflow,

2014-02-18 00:15:00,002 1097696 ERROR [org.jboss.varia.scheduler.Scheduler$Listener] (Timer-1:) Invoke of the Schedulable MBean failed
javax.management.InstanceNotFoundException: abc.service:name=BlahFile is not registered.
at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:508)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:638)
at org.jboss.varia.scheduler.Scheduler$MBeanListener.handleNotification(Scheduler.java:1316)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:138)
at $Proxy10.handleNotification(Unknown Source)
at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java:257)
at javax.management.NotificationBroadcasterSupport$SendNotifJob.run(NotificationBroadcasterSupport.java:322)
at javax.management.NotificationBroadcasterSupport$1.execute(NotificationBroadcasterSupport.java:307)
at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:229)
at javax.management.timer.Timer.sendNotification(Timer.java:1237)
at javax.management.timer.Timer.notifyAlarmClock(Timer.java:1206)
at javax.management.timer.TimerAlarmClock.run(Timer.java:1289)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

Turned out, the jboss-service had following entry:

<mbean code=”aa.bb.cc.dd.BlahFile” name=”abc.service:name=SoBlahFile”>
</mbean>
<!– Data loading to the Touch system is scheduled daily at 02:00 (CET/CEST). –>
<mbean code=”org.jboss.varia.scheduler.Scheduler” name=”abc.scheduled:name=SoBlahFile”>
<attribute name=”StartAtStartup”>false</attribute>
<attribute name=”SchedulableMBean”>abc.service:name=BlahFile</attribute>
<attribute name=”SchedulableMBeanMethod”>startService()</attribute>
<attribute name=”SchedulePeriod”>86400000</attribute>
<attribute name=”InitialRepetitions”>-1</attribute>
<attribute name=”DateFormat”>HH:mm:ss</attribute>
<attribute name=”InitialStartDate”>02:00:00</attribute>
</mbean>

So the culprit was this line:

<attribute name=”SchedulableMBean”>abc.service:name=BlahFile</attribute>

The service name should have been SoBlahFile. So I fixed it and the jboss-service entry was like:

<mbean code=”aa.bb.cc.dd.BlahFile” name=”abc.service:name=SoBlahFile”>
</mbean>
<!– Data loading to the Touch system is scheduled daily at 02:00 (CET/CEST). –>
<mbean code=”org.jboss.varia.scheduler.Scheduler” name=”abc.scheduled:name=SoBlahFile”>
<attribute name=”StartAtStartup”>false</attribute>
<attribute name=”SchedulableMBean”>abc.service:name=SoBlahFile</attribute>
<attribute name=”SchedulableMBeanMethod”>startService()</attribute>
<attribute name=”SchedulePeriod”>86400000</attribute>
<attribute name=”InitialRepetitions”>-1</attribute>
<attribute name=”DateFormat”>HH:mm:ss</attribute>
<attribute name=”InitialStartDate”>02:00:00</attribute>
</mbean>

This fixed my issue. Hope this post saves me time next time! ūüôā

Run the hiccup away!

Standard

I was having hiccups this morning, it went for like an hour! I was fasting ( it being the month of Ramadan), so could not drink any water. So I tried taking long breath, short breath, no breath!! That is all kind of breathing combinations. Didn’t help! It reached such a limit that my throat, chest and stomach started burning. Then I started for office, and found that the next train is 2 mins away, so I ran for my life! And voila.. my hiccup was gone! ūüėÄ ..

But, after another hour or so, while I was working and just going tell my hubby how I fixed my hiccup, it started again! What a pain! I got out of office, but this time since I had no train running away from me, I became self conscious and was unable to run. Then I found out an almost empty street, went to the end of it and then ran for my life. If there was anyone noticing me, surely would have got some *impression* about me! So, anyway, the run did it’s magic again! ūüėĬ†

Thought I would share it, might come handy for someone in need ūüôā

How to catch all the exceptions in Java?

Standard

Because some exceptions don’t derive from¬†Exception¬†– e.g.¬†Throwable¬†and¬†Error.

Basically the type hierarchy is:

       Object
         |
      Throwable
     /         \
Exception      Error

Only Throwables and derived classes can be thrown, so if you catch Throwable, that really will catch everything.

Any exception deriving from¬†Exception¬†(or¬†Exception¬†itself)¬†other¬†than those derived fromRuntimeException¬†count as¬†checked exceptions¬†– they’re the ones that you have to declare you’ll throw, or catch if you call something that throws them.

Credit: http://stackoverflow.com/a/1375121/1258249

Install an external jar into local Maven repository

Standard

Sometimes, you project will have dependency on a jar which is not in official maven repository, and maybe it is propriety jar file which will never be part of maven repository. In this case, you have to put it to your local repository your self to solve the dependency.

There is a install plug in to do this job, which is something like:

mvn install:install-file -DgroupId=<your_group_name>  \
-DartifactId=<your_artifact_name>  \
-Dversion=<snapshot>  \
-Dfile=<path_to_your_jar_file>  \
-Dpackaging=jar \
-DgeneratePom=true

For example, you want to install the danga’s memcached client plugin, you can do:

mvn install:install-file -DgroupId=com.danga \
-DartifactId=memcached \
-Dversion=2.0.1 \
-Dfile=java_memcached-release_2.0.1.jar \
-Dpackaging=jar \
-DgeneratePom=true

This will add the memcache jar into your local Maven2 repository under groupId com.danga and artifactId memcached, you can then edit your pom.xml adding this dependency.

However, the maven eclipse can not recognize it since it always search from public repository.

Credit: http://jeff.langcode.com/archives/27