Setting the Screen Resolution of a Linux Guest in VMWare vSphere Client

I am currently working with virtual machines via Vmware vSphere on a Windows 2008 server. Initially I was unable to get the guest to render full screen and did not have all of the screen resolutions that I would have thought I should. What I was trying to do was have the guest Linux (in this case RedHat Enterprise Linux 6) run full-screen. It was not as straight forward as setting the screen resolution in the VM guest settings dialog.

After much trial and error the way to do it is to crank up the amount of ram allocated for the virtual video card. The guest will then have enough resources to render at full screen and you will have a wide array of screen resolution choices.

Accessing an EJB 3.1 Singleton Bean with @Startup from a Servlet in the Same JVM Instance

I am building a project whereby I have a Singleton Bean that I want to fire up when the .jar is deployed in the EJB container, thus I have it annotated as follows:

package com.ryanchapin.ejbTest

@Startup
@Singleton

public class SingletonTest{}

Of course, I have the requisite Local and Remote interfaces set, up, I’ve just left that off for brevity. I am attempting to do a JNDI lookup, from a Servlet in the same JVM using the Local interface which results in:

22:14:31,481 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/TestWebProject].[ChartData]]
Allocate exception for servlet TestServlet: java.lang.ClassCastException:
$Proxy188 cannot be cast to com.ryanchapin.ejbTestLocal
?at com.ryanchapin.TestServlet<init>(TestServlet.java:51) [:]
?at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.6.0_17]
?at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)[:1.6.0_17]
?at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.6.0_17]
?at java.lang.reflect.Constructor.newInstance(Constructor.java:532)[:1.6.0_17]
?at java.lang.Class.newInstance0(Class.java:372) [:1.6.0_17]
?at java.lang.Class.newInstance(Class.java:325) [:1.6.0_17]
?at org.jboss.web.tomcat.service.TomcatInjectionContainer.newInstance(TomcatInjectionContainer.java:280)[:6.0.0.Final]
?at org.jboss.web.tomcat.service.TomcatInjectionContainer.newInstance(TomcatInjectionContainer.java:264)[:6.0.0.Final]
?at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1162)[:6.0.0.Final]
?at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:955)[:6.0.0.Final]
?at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188)[:6.0.0.Final]
?at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)[:6.0.0.Final]
?at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)[:6.0.0.Final]
?at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)[:1.1.0.Final]
?at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)[:1.1.0.Final]
?at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)[:6.0.0.Final]
?at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)[:6.0.0.Final]
?at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)[:6.0.0.Final]
?at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)[:6.0.0.Final]
?at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)[:6.0.0.Final]
?at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)[:6.0.0.Final]
?at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)[:6.0.0.Final]
?at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)[:6.0.0.Final]
?at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)[:6.0.0.Final]
?at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654)[:6.0.0.Final]
?at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)[:6.0.0.Final]
?at java.lang.Thread.run(Thread.java:636) [:1.6.0_17]

When I lookup the Remote interface JNDI name in the Servlet it works just fine. This only occurs if I have the bean annotated with @Startup. If I remove the @Startup annotation I can access the EJB via the local interface without a problem.

Perhaps a bug in Jboss-6.0.0, I’m not sure. For the time-being I am just going to use the remote interface.

?

Disabling JavaScript Validation in Eclipse Helios 3.6.1

The Helios JavaScript validator does not seem to like the jquery-1.5.min.js (or for that matter a number of other know good js libraries). As a result Eclipse complains a lot when building a project.

The quick fix that I found was to disable JavaScript validation under the Builder preferences, for your project:

Project/Properties/Builders

Simply, uncheck the “JavaScript Validator” and you should be all set.

Simple Network Speed Command Line Test for Linux

Let’s say that all that you have access to is the command line on a Linux box and you want to know what the network throughput is. If you have another Linux box you can use netcat to do a quick test:

On box a:? Set up netcat to listen to a given port:

nc -l 12345 > /dev/null

Fire up netcat to listen on port 12345 and to dump the output to /dev/null.

On box b:? Send data via netcat to the listening machine:

dd if=/dev/zero bs=16000 count=50000 | nc -v boxa 12345

This will use dd to generate a ‘file’ with 50000 blocks that are 16000 bytes in size and invoke netcat in verbose mode. When invoked you will get something like:

Connection to boxa 12345 port [tcp/*] succeeded!
50000+0 records in
50000+0 records out
800000000 bytes (800 MB) copied, 6.85282 seconds, 117 MB/s

Installing Java SE Source Files and Linking to Eclipse on CentOS 5

?When I first set up a developoment VM with CentOS I must have forgotten to install the Java source because I could not navigate to Java SE method declarations in my Eclipse IDE.

To have access to the Java source I did the following:

  • yum install java-1.6.0-openjdk-src
  • A src.zip file was placed in:
  • /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/src.zip

I created a src dir in the aforementioned containing dir and unpacked the zip
I then linked to the source from Eclipse by:
Right-clicking on some java.lang.* method in a class and selecting “view source”
Originally it presented me with a view of the .class file
Clicking on the Add Source button, I navigated to the /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/src/ dir

Installing JBoss AS 6 Tools in Eclipse Helios

  • Go to Help > Install New Software
  • Set Work with to http://download.jboss.org/jbosstools/updates/development/
  • In the results, unfold “All JBoss Tools” and check JBoss AS Tools. When last I checked the description indicates only 4.x and 5.x for JBoss, but it does include JBoss AS 6 Tools
  • Next, etc, Finish.

When I then ran through the Eclipse add server wizard the 6.0 version of JBoss AS was available.

Including libraries in WAR files in Eclipse

By default, the newer versions of Eclipse do not include the libraries that you add to the build path in .war files. There are three approaches to solving this problem:

  • Declare your libraries/jar files to be module dependencies for your war file; essentially forcing Eclipse fo treat the lib the same way it would a dependent project. I found a web page describing how to do this for an older version of Eclipse and couldn’t readily figure out how to do it with Helios. This one is an excersize for the reader.
  • Add the library to your directory of shared libraries on your app server.
  • Either copy, or symlink the jar files directly into your WEB-INF/lib directory on your file system and then do a refresh for your project in Eclipse.

Disabling Autodeploy in Eclipse for Web and JavaEE Projects

In some cases it is helpful to have your Java project automatically built and deployed for you by Eclipse. For me, when working on a dynamic web or JavaEE project I’d much rather run it on the server through the IDE manually, as I tend to save often and I end up having to wait for a previous deployment to finish on a regular basis.

To disable the feature:

  • Go to: Window/Show View/Servers
  • Double-click on the server that you associated with Eclipse
  • On the right-hand side, should be a collapsed menu titled “Publishing”
  • Expand the menu and you will see the radio buttons with the various auto-deploy options.

You will need to shutdown the server before you can save the change.