Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.

icon.linkedin.jpgicon.twitter.jpg

  • Subscribe to this RSS Feed
  • Accessing an EJB 3.1 Singleton Bean with @Startup from a Servlet in the Same JVM Instance
    02/23/2011 9:49PM

    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
    02/23/2011 3:53PM

    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
    02/21/2011 2:02PM

    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
    02/13/2011 10:19PM

    ?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
    02/13/2011 10:11PM
    • 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.

Advanced Search

Categories

Archives