Over a million developers have joined DZone.

Mail Of The Week: What I Can And Cannot Do With Java EE 6

DZone's Guide to

Mail Of The Week: What I Can And Cannot Do With Java EE 6

· Java Zone
Free Resource

Are you joining the containers revolution? Start leveraging container management using Platform9's ultimate guide to Kubernetes deployment.

I got an interesting email with questions regarding Java EE restrictions. Here are some of my answers:

>"I have installed Glassfish 3.0.1 and am using NetBeans 6.9.1 for implementing stuff"
Congrats - you saved about 5h :-).

  1. I have a web service running on Glassfish. What can I do now to access an RMI based server? Can I do this: HelloWorldRMI hdl = (HelloWorldRMI) Naming.lookup("rmi://localhost:2000/HelloWorldRMI"); String helloString = hdl.sayHello("WS");

    Yes you can. It works perfectly with all servers I know. This is what I do with greenfire.dev.java.net to access the native driver.
  2. Can I also open a socket from the same web service to another C++ based server?

    You can open client sockets, but not server sockets. I did it in the past with JBoss, Glassfish and WLS. The spec is a bit fluffy here.
  3. Can I write something to a file?

    It will work on most application servers, but it isn't compliant. It is also problematic regarding consistency and concurrency.
    You could write a JCA connector for transactional file access. It is easier, than you may think. I wrote a JCA-File connector in my book Real World Java EE Patterns - Rethinking Best Practices See page 181 - Generic JCA connector. My transactional example is comprised of ...4 classes and one XML file.
  4. Can I create my own classloader and load classes through there?

    It will mostly work, but is not compliant."...Allowing the enterprise bean to access information about other classes and to access the classes in a manner that is normally disallowed by the Java programming language could compromise security..."

  5. Can I dynamically create classes like this: MyClass myClass = (MyClass) Class.forName("...my.MyClass").newInstance(); String returnString = myClass.sayHello(className);

    This is perfect - except obtaining EJBs and CDI managed beans that way :-)
From http://www.adam-bien.com/roller/abien/entry/mail_of_the_week_what

Using Containers? Read our Kubernetes Comparison eBook to learn the positives and negatives of Kubernetes, Mesos, Docker Swarm and EC2 Container Services.


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}