Exception in thread "main" javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.ejb3.JBossProxy (no secu

Exception in thread "main" javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.ejb3.JBossProxy (no security manager: RMI class loader disabled)]

Cause:
Client library missing

Solution:
Add jbossall-client.jar to classpath

NoInitialContextException when calling an EJB from a java client

Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at helloworldclient.Main.main(Main.java:34)

Cause
:
The initial context is not set.

Solution:
Set the initial context via jndi.properties or programatically:
properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.provider.url","jnp://localhost:1099");
Context ic = new InitialContext(properties );

How to run JBoss 5.1 within Netbeans 6.5 and Netbeans 6.7

  1. Download JBoss 5.x and extract it to C: (Don't put it inside 'Program Files')
  2. In the Services tab, select Servers..Add Server and select JBoss


  3. Leave everything at the default setting
  4. JBoss should be registered with netbeans
  5. Right click on JBoss and click start server
  6. If there were no issues, JBoss will start within Netbeans BUT it is never that simple is it? :)
Ok so here are some of the issues I encountered and how I went about solving them.
  1. First make sure your JBOSS_HOME environment variable is pointing to the correct path. I upgraded from JBoss 4.05 and had to update this. Check your PATH variable as well
  2. On trying to register JBoss with Netbeans I kept getting this error:
    ALL [null]: Cannot rename file J2EE/InstalledServers/.nbattrs~ in C:\Documents and Settings\g\.netbeans\6.7\config to J2EE/InstalledServers/.nbattrs
    This is basically netbeans trying to create a file called .nbattrs but not being able to do so. In XP a file name cannot begin with a dot. Go ahead try it! But Netbeans tries to create one. Slopppy implementation by Netbeans (or Netbeans engineers are not big windows fans!). Here's what I did. Went to DOS (cmd) and renamed it. Yeah Microsoft, consistency is not thy forte! (No pun intended - Netbeans used to be called Forte)
  3. Close Netbeans and start is again. You should be able to see JBoss listed under servers
  4. When I tried to start Netbeans, the first error I got was:
    Port already in use: 8080
  5. To fix this, I went to C:\jboss-5.1.0.GA\server\default\deploy\jbossweb.sar\server.xml and changed the port from 8080 to 7075 (select any unused port).
  6. Once that was fixed the next error on a restart was:
    java.rmi.server.ExportException: Port already in use: 1098; nested exception is: java.net.BindException: Address already in use: JVM_Bind

  7. To fix this, I edited C:\jboss-5.1.0.GA\server\default\conf\bindingservice.beans\META-INF\bindings-jboss-beans.xml and updated 1098 to 11098
  8. In the same xml file I updated Remote classloading service port as well as this too was giving a port already in use error
  9. Now a restart of JBoss was successful!

You are welcome!

NullPointerException during authentication in JSecurity

WARNING: Authentication failed for token submission [org.jsecurity.authc.UsernamePasswordToken - lonestarr, rememberMe=true]. Possible unexpected error? (Typical or expected login exceptions should extend from AuthenticationException).
java.lang.NullPointerException
at org.jsecurity.realm.SimpleAccountRealm.doGetAuthenticationInfo(SimpleAccountRealm.java:141)
at org.jsecurity.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:170)
at org.jsecurity.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:213)
at org.jsecurity.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:303)
at org.jsecurity.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:180)
at org.jsecurity.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:209)
at org.jsecurity.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:314)
at org.jsecurity.subject.DelegatingSubject.login(DelegatingSubject.java:239)
at Quickstart.main(Quickstart.java:71)


Cause:
Probably a bug in JSecurity. I'm using version 0.9. This might've been fixed in the latest release. JSecurity is looking for
the cache manager but is unable to find one.

Solution:
Try downloading the latest version
Place ehcache.jar and backport-util-concurrent.jar in the classpath and run again

How to resolve UnresolvedExternal exceptions while deploying jni apps in Tomcat

Cause:
UnresolvedExternal errors are caused in JNI applications when the class files tries to reference a native method in a shared object or dll and is unable to find the dll.

Solution:
  • Find out Tomcat's current java.library.path
  • Copy your application dlls to this path
  • The jars would remain within the application's war file
  • The dlls need not be along with the application jars

What is tcnative.dll in Tomcat?

The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.16\lib;
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.core.AprLifecycleListener.init(AprLifecycleListener.java:135)
at org.apache.catalina.core.AprLifecycleListener.lifecycleEvent(AprLifecycleListener.java:80)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:770)
at org.apache.catalina.startup.Catalina.load(Catalina.java:530)
at org.apache.catalina.startup.Catalina.load(Catalina.java:550)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
Caused by: java.lang.UnsatisfiedLinkError: no tcnative-1 in java.library.path, no libtcnative-1 in java.library.path(C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.16\lib;)

Cause:
You get this message when you start Tomcat. Tomcat is looking for a shared object call tcnative (dll or so depending on the platform). If it doesn't find it, it'll revert to java libs. Either way, this shouldn't affect your application. tcnative dll is needed to address scalability in Tomcat.

Solution:
  1. Turn down debugging level for Tomcat or
  2. Get tcnative from http://tomcat.apache.org/native-doc/ (windows users can download the binary) and place it in your library path.
  3. Lib path is usually: C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.16\lib; for windows

Exception loading sessions from persistent storage java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException

IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException:com.test java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.test

SEVERE: Exception loading sessions from persistent storage
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.test

Cause:

You get this error on restarting tomcat. This is caused by classes that are not serializable. Tomcat tries to serialize objects on shutdown and deserialize on a restart.

Solution:

Make your classes serializable or

Turn off this feature in Tomcat by adding this in your webapp's context.xml

<Manager pathname=""></Manager>