Sorry, I forgot to say the reason why the classes needed by the MDB are in the war file (web-inf/classes) is that the war application also uses that classes.
If you package the classes with the message driven bean jar instead of the war then both should be able to see the classes.
An EJB tier should not have visibility of the web application so in theory different clients could be used.
Thanks for your answer, but it seems that it didn't solve the problem. I moved one of the shared classes (due to a ClassNotFoundException) from the war file to the jar. Now the war can't find the moved class. If instead of moving I try to copy the file, the problem seems to be solved, but another one arises, the jar ask for another class, but instead of throwing a ClassNotFoundException it throws a NoClassDefFoundError. In this case, the trick of moving/copying classes doesn't work.
Any suggest? By the way, can anybody tell me what's the difference between a ClassNotFoundException and a NoClassDefFoundError?
Thanks in advance.
It works! Your answer was right, what I did was making a JAR with my classes, and put my JAR in the EBJ. All works fine.
The main difference between a ClassNotFoundException and a NoClassDefFoundError is that in the first case, the classLoader can't find the class. In the second case, the classLoader can find the class, but can't find any other classes used by the first class.