NoClassDefFoundError extending class in separate JAR

I have a class Foo which gets called from my servlet (extends HttpServlet) class. Both Foo and the servlet class are located in WEB-INF/classes and are deployed as part of the war file. Class Foo extends class Bar, which is a different .jar file located in the /WEB-INF/lib directory of the webapp. When I attempt to create an instance of Foo, I get the following exception:
java.lang.NoClassDefFoundError: /general/client/common/beans/Bar
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
     at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
     at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1267)
     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
     at server.DBServlet.createFoo(DBServlet.java:236)
     at server.DBServlet.processInput(DBServlet.java:333)
     at server.DBServlet.doGet(DBServlet.java:154)
     at server.DBServlet.doPost(DBServlet.java:205)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
     at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:419)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
     at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
     at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
     at java.lang.Thread.run(Thread.java:595)
I'm running this on Windows, and found if I added the classpath the the jar file where the Bar class is located, that it worked fine. But my expectation is that the jar file should have been found because it is in the /WEB-INF/lib dir. There is a line the Tomcat docs that says:
"Last, any JAR containing servlet API classes will be ignored by the classloader. All other class loaders in Tomcat 5 follow the usual delegation pattern."
So maybe I need to do something special to load the Bar class, or there's something strange about the way the classes and jars are being loaded that I don't fully understand. I was able to instantiate the Bar class directly from w/in my servlet class, I just can't create an instance of the Foo class that is in /WEB-INF/classes along with the servlet class. So I'm not convinced that the Bar class or associated jar file isn't being loaded.
I don't want to have to set the classpath explicitly, so I'm looking for advice on why I'm getting this exception and how best to dynamically load the classes I need.
Thanks.
ab.

Thanks for hanging in there so far. Here's the specifics if you want to try to re-create this.
I have a webapp, which contains the class DBServlet:
package com.hm.dhca.server;
public class DBServlet extends HttpServlet
// Stuff
     public void processInput()
          Foo foo = new Foo();
The webapp also contains the class Foo:
package com.hm.dhca.common;
import com.general.client.common.beans.Bar;
public class Foo extends Bar
     public Foo()
          super();
          System.out.println("Foo");
Both of the classes are located in webapps\DHCA\WEB-INF\classes...
The Bar class is in a separate jar called HMJCommon.jar in the webapps\DHCA\WEB-INF\lib dir.
Class Bar looks like this:
package com.general.client.common.beans;
public class Bar
     public Bar()
          System.out.println("Bar");
DBServlet creates an instance of Foo as:      
Foo foo = new Foo();
Which throws the Exception:
java.lang.NoClassDefFoundError: com/general/client/common/beans/Bar
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
     at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
     at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1267)
     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
     at com.hm.dhca.server.DBServlet.processInput(DBServlet.java:236)
     at com.hm.dhca.server.DBServlet.doGet(DBServlet.java:154)
     at com.hm.dhca.server.DBServlet.doPost(DBServlet.java:205)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
     at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:419)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
     at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
     at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
     at java.lang.Thread.run(Thread.java:595)
Clues:
1. All three classes exist in the locations specified above - I have checked this manually.
2. Within DBServlet, I can create an instance of Bar. But I cannot create an instance of Foo without the exception.
3. If I move the Foo class from package com.hm.dhca.common to package com.hm.dhca.server (same package as DBSerlvet), everything works fine.
4. If I modify Tomcat's classpath to include the HMJCommon.jar, it works fine (as previously discussed).
Theory:
I have a vague theory that what is happening is that two different webappclassloaders are loading the Foo and Bar classes, for whatever reason. As a result, they can't see each other, because neither is up the hierarchy tree from the other.
This does not explain how I can instantiate Bar from DBServlet, but not Foo.
Hope this helps. I think I've corrected previous mistake w/ removing too much from package naming. I'm resorting to the workaround in clue #3 for the moment. But it's not the correct solution, and it's showing that I don't really understand what's going on here.

Similar Messages

  • Common classes across separate EJB jars

    What is the best way to package classes that are common across separate EJB jar files? IE, i have an object that is passed between the 2, or a utility that is used by both. Is it customary to package the classes within the EJB jar file? This seems silly to me because
    now you have 2 versions of the same class that could possibly change in one of them. Or should I put the classes into the classpath of the J2EE container? Thanks for any advice.

    Both ways will work, we prefer the first one (packaging the classes in both jars). We are using BEA WebLogic 6.x and putting it in the containers classpath would mean to restart the server every time we changed this classes. Mabe you should consider making a single jar for both EJBs if they will always be used together.
    Regards,
    hedtfeld.

  • Dinamyc class loading and jar files

    I'm new to java. I would like to load some plugins in my application (it's going to be packaged as a jar at the end). I managed to find some dinamyc class loading examples but they search for the classes to load in a directory.
    This is the code:
        public static void main(String[] args) {
            File pluginDirectory = new File("src/pluginsreloaded/plugins");
            if (!pluginDirectory.exists()) {            // the plugin directory does not exist
                System.out.println("The plugins directory does not exist!");           
                return;
            FilenameFilter filter = new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".class");
            String[] pluginFiles = pluginDirectory.list(filter);
            for (int i = 0; i < pluginFiles.length; i++) {
                if (pluginFiles.indexOf("$") == -1) {
    System.out.println("Loading: " + pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    IPlugin plugin = pm.loadPlugin(pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    System.out.println(plugin.description());
    protected static IPlugin loadPlugin(String name) {
            // Query the plugin list for the plugin
            PluginFactory _plugin = (PluginFactory) pluginList.get(name);
            if (_plugin == null) {          // the plugin is not loaded
                try {
                    Class.forName("pluginsReloaded.plugins." + name);
                    // The plugin makes an entry in the plugin list
                    // when loaded
                    _plugin = (PluginFactory) pluginList.get(name);
                    if (_plugin == null) {
                        return null;
                } catch (ClassNotFoundException e) {
                    System.out.println("Plugin " + name + " not found!");
            return _plugin.create();
        }IPlugin is an interface. I am using netbeans 5.0. The error I get is this:
    Exception in thread "main" java.lang.NoClassDefFoundError: pluginsReloaded/plugins/plugin1 (wrong name: pluginsreloaded/plugins/plugin1)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:164)
            at pluginsreloaded.PluginManager.loadPlugin(PluginManager.java:30)
            at pluginsreloaded.Main.main(Main.java:44)
    Java Result: 1As far as I can see it can't find the class. My question is how can I load the class/where can I find it?
    Thanks.

    You can use the java.util.jar.JarFile class to enumerate the contents of a jar. It's not good practice to search for plugins in this way though. A plugin may well involve serveral classes, which don't all have to be internal. Furthermore its wise to avoid any comitment about the mechaism by which class files are to be fetched. You might want to do it remotely, some time, or load them from a database.
    What seesms to be the standard approach is to put a list of plugin classes into the jar as a text file.
    Plugins for a given purpose usually implement some specified interface, or extend some abstract class to which their objects can be cast once loaded (without this they aren't really much use).
    Say your plugins implment org.myorg.WidgetFactory then you put a list of them, one fully qualified name to a line, in a file or jar entry called META-INF/services/org.myorg.WidgetFactory. You framework picks up all such files from the classpath using ClassLoader.getResources() and loads all the classes whose names if finds, hence you can add new sets of plugins just by adding a new jar or class directory to the class path.

  • Packages in separate Jars causes classpath error

    For the purposes of easy-updating and allowing developers to work on one part of a system without interfering with others, I have created separate Jar files for the main packages in my application. So;
    com.me.pack1 is in Pack1.jar
    com.me.pack2 is in Pack2.jar
    An ant build takes care of building and packaging these up. The Jar files have the correct directory structure i.e.;
    jar $ $JAVA_HOME/bin/jar tf /users/jmcparla/jar/Pack1.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/me/
    com/me/pack1/
    com/me/pack1/MainClass.class
    jar $ $JAVA_HOME/bin/jar tf /users/jmcparla/jar/Pack2.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/me/
    com/me/pack2/
    com/me/pack2/OtherClass.classHowever when I run it;
    jar $ $JAVA_HOME/bin/java -cp /users/jmcparla/jar/Pack2.jar -jar /users/jmcparla/jar/Pack1.jar
    Entered main
    Created MainClass instance
    Exception in thread "main" java.lang.NoClassDefFoundError: com/me/pack2/OtherClass
            at com.me.pack1.MainClass.main(MainClass.java:13)The classes are;
    MainClass.java
    package com.me.pack1;
    import com.me.pack2.OtherClass;
    public class MainClass
        public static void main(String[] args)
            System.out.println("Entered main");
            new MainClass();
            System.out.println("Created MainClass instance");
            new OtherClass();
            System.out.println("Created OtherClass instance");
    }OtherClass.java
    package com.me.pack2;
    public class OtherClass
    }and the build file is;
    build.xml
    <project name="JarProblem" default="buildJars" basedir=".">
      <property name="classdir" value="classes"/>
      <target name="compile" depends="clean" description="compile the code">
          <mkdir dir="${classdir}"/>
          <javac debug="on" debuglevel="vars,lines,source" srcdir="."
                 destdir="${classdir}" encoding="ISO-8859-1">
          </javac>
      </target>
      <target name="buildJars" depends="compile" description="build the jar files">
        <antcall target="buildPack2"/>
        <antcall target="buildPack1"/>
      </target>
      <target name="buildPack2" description="build the Pack2 jar">
        <tstamp>
          <format property="time" pattern="hh:mm aa dd/MM/yyyy"/>
        </tstamp>
        <jar destfile="Pack2.jar" update="false">
          <fileset dir="${classdir}">
            <!-- Only include the package we're building -->
            <include name="com/me/pack2/*"/>
          </fileset>
          <manifest>
            <attribute name="Built" value="${time}"/>
          </manifest>
        </jar>
      </target>
       <target name="buildPack1" description="build the Pack1 jar">
        <tstamp>
          <format property="time" pattern="hh:mm aa dd/MM/yyyy"/>
        </tstamp>
        <jar destfile="Pack1.jar" update="false">
          <fileset dir="${classdir}">
            <!-- Only include the package we're building -->
            <include name="com/me/pack1/*"/>
          </fileset>
          <manifest>
            <attribute name="Main-Class" value="com.me.pack1.MainClass"/>
            <attribute name="Built" value="${time}"/>
          </manifest>
        </jar>
      </target>
      <target name="clean" description="clean up the compiled source files">
        <delete verbose="false" failonerror="false">
          <fileset dir="${classdir}"/>
        </delete>
      </target>
    </project>The build completes with no problems. So why can't the java command see OtherClass?

    johnmcparlald wrote:
    However when I run it;
    jar $ $JAVA_HOME/bin/java -cp /users/jmcparla/jar/Pack2.jar -jar /users/jmcparla/jar/Pack1.jar
    Entered main
    Created MainClass instance
    Exception in thread "main" java.lang.NoClassDefFoundError: com/me/pack2/OtherClass
    at com.me.pack1.MainClass.main(MainClass.java:13)
    I can't help you with ant but I can tell you that the command you entered looks wrong. If you use the -jar option with the java command, the only classpath that is used is the one specified by the Class-Path entry in the manifest - other classpaths are ignored.
    So you either need to leave off the -jar, include the Pack1.jar file and specify the main class, or include the Class-Path: Pack2.jar entry in the manifest. (At least, it looks to me like there is no Class-Path in the manifest.)

  • Applet inside a JAR: Cannot access other classes within the JAR

    Hello,
    Description
    Web app + applet (packaged in a JAR)
    I have followed this tutorial
    JAR contents
    package mypackage
    SimpleApplet.class
    SimpleObj.class
    _"SimpleApplet" uses "SimpleObj"_
    package mypackage;
    public class SimpleApplet extends JApplet {
        @Override
        public void init() {
            SimpleObj obj = new SimpleObj();
    HTML code
    <applet archive="SimpleApplet.jar" codebase="." code="mypackage.SimpleApplet.class" width="800" height="600" />
    SimpleObj cannot be found (Java Console)
    java.lang.NoClassDefFoundError: mypackage/SimpleObj
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: mypackage.SimpleObj
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 8 more
    Caused by: java.io.IOException: open HTTP connection failed:*http://localhost:8080/SimpleApp/mypackage/SimpleObj.class*
    at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 12 more
    Exception: java.lang.NoClassDefFoundError: mypackage/SimpleObj
    It looks like JRE does not search for the SimpleObj class inside the JAR, but tries to get it from the server...
    Any ideas?
    Thanks in advance,
    Gerard
    Edited by: gsoldevila on Dec 10, 2008 2:05 AM

    misread, deleted
    Edited by: atmguy on Dec 10, 2008 1:12 PM

  • Loading separate JAR files.

    Hello.
    I have an application that loads functionality from separate jar files so that the application has a "hot deploy" feature. This means that the application reloads a certain functionallity if a new jar is deployed to that folder. This also means that the jars containing this functionality must be in a separate forlder than the jars for the application framework, or the system would try to load this as a functionallity as well.
    In my JNLP file, I load the whole application framework at startup, but none of the functionality jars as these are loaded after the application has logged the user in and so on. I use URLClassLoader to load the funtionality classes but in these classes, I import from the allready loaded framework, and the functionalities I try to load throw an excaption that they do not find the classes in the framework.
    Any ideas as to how the externally loaded jars can find classes loaded into the framework? This works perfectly well when I don't use web start, so there must be some class loading issues I am not aware of.
    Thank you.
    -r

    OK, I am making some progress, but now I have a different problem: Some of the framework for loading was written by someone else and I would really like access to the debug information it prints without having to rewrite a lot to print it all to files. Is there any way to get access to everything that is being printed on System.out from web start. Been looking around but I can't find anything on the subject.

  • How to deploy 2 EJB's in separate jars

    Hi,
    I have successfully deployed 2 session ejb's in the same jar file, i.e. with one ejb-jar.xml and one weblog-ejb-jar.xml. And get get the ejb's to communicate with each other.
    Now I want to be able to compile and deploy the 2 ejb's in separate jar files as part of an ear file.
    My method so far is this:
    I have split the ejb-jar.xml file into two, for each ejb, and also the weblogic-ejb-jar.xml file into two for each ejb.
    I then compiled the ejb source files and packaged each ejb up with its respective deployment descriptors into two separate .jar files.
    I then want to run weblogics ejbc on each .jar file in turn so that the resultant .jar files (with newly created stubs/skels) can be packaged into an .ear to be easily deployed into weblogic.
    I try and run the ejbc command on the first of the .jar files and i get the error:
    ERROR: Error from ejbc:
    In ejb-jar.xml, the EJB 'SessClient' contains an invalid ejb-link in ejb
    -ref 'ejb/SessLogHome'. No EJB with ejb-name 'IntellectStateless.jar#SessLog' co
    uld be found.
    ERROR: ejbc found errors
    My ejb-jar.xml file for this ejb is:
    <ejb-jar>
      <enterprise-beans>
        <session>
          <ejb-name>SessClient</ejb-name>
          <home>intellectsession.sessiontwo.SessClientEntHome</home>
          <remote>intellectsession.sessiontwo.SessClientEnt</remote>
          <ejb-class>intellectsession.sessiontwo.SessClientEntBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
          <ejb-ref>
            <ejb-ref-name>ejb/SessLogHome</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <home>intellectsession.stateless.SessLogHome</home>
            <remote>intellectsession.stateless.SessLog</remote>
            <ejb-link>IntellectStateless.jar#SessLog</ejb-link>
          </ejb-ref>
        </session>
      </enterprise-beans>
      <assembly-descriptor>
        <container-transaction>
          <method>
         <ejb-name>SessClient</ejb-name>
         <method-name>*</method-name>
          </method>
          <trans-attribute>Required</trans-attribute>
        </container-transaction>
      </assembly-descriptor>
    </ejb-jar>and both of my .jar files are in the same directory when I run the ejbc command.
    I'm sure this can be done but I just think i'm not doing it in the right order maybe??
    Anyway pointers will be gr8ly appreciated.
    Cheers
    T

    Okay here is the solution to how to achieve the problem I encountered above:
    I am compiling my ejb.jar files using the weblogic.ejbc compiler, obviously I am deploying on weblogic here.
    This section:
    <ejb-ref>
      <ejb-ref-name>ejb/SessLogHome</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
    <home>intellectsession.stateless.SessLogHome</home>
      <remote>intellectsession.stateless.SessLog</remote>
      <ejb-link>IntellectStateless.jar#SessLog</ejb-link>
    </ejb-ref>must have JUST the <ejb-link/> tag removed from the ejb-jar.xml file. And then the weblogic-ejb-jar.xml file MUST look like this:
    <weblogic-ejb-jar>
        <weblogic-enterprise-bean>
            <ejb-name>SessClient</ejb-name>
            <reference-descriptor>
              <ejb-reference-description>
                <ejb-ref-name>ejb/SessLogHome</ejb-ref-name>
                <jndi-name>SessLog</jndi-name>
              </ejb-reference-description>
            </reference-descriptor>
            <jndi-name>SessClient</jndi-name>
        </weblogic-enterprise-bean>
    </weblogic-ejb-jar>Note the <refererence-descriptor> tag as the important part.
    After these changes, the 2 ejb.jar files can be compiled using the weblogic.ejbc tool, thus supplying the stubs/skels, and then the resultant two ejb.jar files can be added to the EAR file and deployed to weblogic.
    Result: 2 ejb's in separate jars, in one EAR file, talking to each other.
    T

  • Java class uses another class in a Jar file (How do I make Java see it)?

    I am trying to figure out how do I make Javac see the thinlet.class in the thinlet.jar.
    I have developed an XUL xml interface and a java program that calls the interface shown below:
    //package thinlet.demo;
    import thinlet.*;
    public class UI extends Thinlet
    { public UI () throws Exception {add(parse("UI.xml"));}
    public static void main(String[] args) throws Exception
    { new FrameLauncher("UI", new UI(), 600, 600); }}
    when I do the normal compile, I get an error:
    UI.java:4: cannot find symbol
    symbol: class Thinlet
    public class UI extends Thinlet {
    ^
    UI.java:7: cannot find symbol
    symbol : method parse(java.lang.String)
    location: class thinlet.demo.UI
    add(parse("UI.xml"));
    ^
    UI.java:12: cannot find symbol
    symbol : class FrameLauncher
    location: class thinlet.demo.UI
    new FrameLauncher("UI", new UI(), 600, 600);
    ^
    3 errors
    This thinlet class should be in the thinlet.jar that I have added the directory to the path, the directory and jarfile name to the System CLASSPATH and it couldn't see it. So finally I tried putting the thinlet.jar in the same directory to no avail. I've searched the web for some time an cannot find anything that specifically speaks to compiling a program that has parent classes in a Jar.
    Any help is definitely appreciated.

    This thinlet class should be in the thinlet.jar that I have added the directory to the path, the directory and jarfile name to the System CLASSPATH and it couldn't see it. So finally I tried putting the thinlet.jar in the same directory to no avail. I've searched the web for some time an cannot find anything that specifically speaks to compiling a program that has parent classes in a Jar.
    Any help is definitely appreciated.You just still haven't provided the jar in the classpath, or you're not using the right class name. Is the class really named thinlet.Thinlet? Or are you thinking "import thinlet.*" means to import all classes in a jar named thinlet.jar? Because the latter is not true. You need to import classes, not jar file names.

  • Problem deploying related EJBs in separate JARs

    I have 2 entity EJBs, User and Address, in separate JAR files. The User bean
    has business methods to get and set its related address as follows:
    void setAddressPK(AddressPK newAddress) throws java.rmi.RemoteException;
    AddressPK getAddressPK() java.rmi.RemoteException;
    When I try and load User.jar in the EJB Deployment tool it complains that it
    can't find the AddressPK class. However, I can get round this by explicitly
    adding Address.jar to the classpath.
    When I actually deploy and use the User bean I do NOT need Address.jar on
    the classpath, although I do get warnings during deployment.
    So my question is how do I package and deploy related EJBs. I don't want to
    have to have all my EJBs in the same JAR, nor do I want to have the same
    classes in more than one JAR. Is what I'm doing correct - am I supposed to
    have Address.jar on the classpath? And what about an utility classes that
    are shared between EJBs - where do I put those?
    Thanks in advance,
    Steve.

    I resolved the problem be making sure that my deployment
    jars don't appear in my servlet classpath....
    Jason
    Jeff Wang <[email protected]> wrote in message news:[email protected]...
    In general, if two beans are related (i.e. you can not compile one
    without the other being on the classpath) and they are both deployed
    they should be in the same jar file. If you do not deploy one of them,
    then the undeployed bean can be in the weblogic.class.path with no
    problem.
    I suspect that you are getting a ClassCastException because you have the
    deployment jars in your weblogic.class.path (or java classpath.) Remove
    them, and see if the error is resolved.
    Jeff Wang
    WLCS 2.0 Software Engineer
    Jason Rosenberg wrote:
    Does the same apply for beans of different types? In other words, do
    I need to have an entity bean and a session bean which wraps the entity
    bean in the same jar file?
    I am having a problem accessing a session bean from a JSP servlet. I get
    the dreaded ClassCastException. I don't get this problem, however, if
    I access the session bean directly from a stand-alone java client. It's
    only when I access the session bean via JSP....
    Any ideas?
    Jason
    Jeff Wang <[email protected]> wrote in message news:[email protected]...
    What you should have in the .jar files are:
    the home (say it is called <bean>home.class)
    the remote (say it is called <bean>.class)
    the impl (say it is called <bean>impl.class)
    These are the only ones that should be in the .jar file. (not even the
    PK should be there, for an entity bean.) All the support classes should
    be in weblogic.class.path If you have cross jar dependencies,
    unfortunately, you will have to specify the jar in the
    weblogic.class.path... However, this is not a good idea, as you will
    have 2 class files in memory. At the very least, you will not be able
    to do hot deploy. Depending on your code, you'll have a "class cast
    exception <bean> can not be casted to an object of <bean>" (Something
    like that, I don't have the exact error in front of me.) In your
    example it is probably better to put User and Address in the same jar.
    Jeff Wang
    WLCS 2.0 Software Engineer
    Steve Ward wrote:
    I have 2 entity EJBs, User and Address, in separate JAR files. The User bean
    has business methods to get and set its related address as follows:
    void setAddressPK(AddressPK newAddress) throws java.rmi.RemoteException;
    AddressPK getAddressPK() java.rmi.RemoteException;
    When I try and load User.jar in the EJB Deployment tool it complains that it
    can't find the AddressPK class. However, I can get round this by explicitly
    adding Address.jar to the classpath.
    When I actually deploy and use the User bean I do NOT need Address.jar on
    the classpath, although I do get warnings during deployment.
    So my question is how do I package and deploy related EJBs. I don't want to
    have to have all my EJBs in the same JAR, nor do I want to have the same
    classes in more than one JAR. Is what I'm doing correct - am I supposed to
    have Address.jar on the classpath? And what about an utility classes that
    are shared between EJBs - where do I put those?
    Thanks in advance,
    Steve.

  • Classes in added jar on classpath not found

    Hi there,
    The javafx compiler seems to have trouble finding classes from a jar that was added to the lib directory of a javafx project. I experience this trouble when working with the Netbeans 6.5.1 IDE and javafx version 1.2.
    When trying to import a single class in a javafx file from a manually added jar, a compiler error occurs stating that the class cannot be found. Package names, however, do get recognized when importing classes, and therefore star import are possible. The actual classes from a package that was imported by means of a star import, don't get recognized.
    Does anyone have an idea what causes this problem and how to resolve it?
    Kind regards and thanks in advance,
    Rienk

    Can I refer classes in embedded jar's? I thought that did not work. It wasn't working so I tried putting the same jars into the same directory as the main class.
    Let me try again with less information.
    My jar with the main class is: testpojo.jar
    The class path inside the manifest is
    Class-Path: swing-layout-1.0.03.jar AbsoluteLayout.jar
    The directory with the external jar is:
    Directory of C:\DOCUME~1\MDARR\WORKSP~1\TESTPO~1\TARGET
    9/11/2008 10:44 PM <DIR> .
    9/11/2008 10:44 PM <DIR> ..
    9/11/2008 10:44 PM 2,850 AbsoluteLayout.jar
    9/11/2008 10:44 PM 118,103 swing-layout-1.0.3.jar
    9/11/2008 10:56 PM 51,660 testpojo.jar
    Unless I've missed something the the swing-layout-1.0.3.jar jar file is in the same relative directory as testpojo.jar.
    When I execute the main class should be able to reference classes in that file.
    But it gets,
    Exception in thread "main" java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group
    What's happening? It's a little confusing because the same jar is also stored inside testpojo.jar. I read that Java can't load from embedded jar's so I tried putting them in the same directory as testpojo.jar and setting the class path inside the manifest.
    And yes, I understand about the main class name. That was just me goofing around trying to label things. At this I'm a rookie.
    Tia,
    Maurice

  • Don't know package of class in a jar using URLClassLoader

    Hello,
    i want to load a class out of a jar file but the only thing i know is the classname its the same as the jarname. the problem now is i packed the plugin as nice with packages and my Loader won't find the class without package, what can i do to know the package?
    i don't have any main method because it's a plugin loading. i know der should be a possibility to loop through all classes?! or even to find a class implementing an interface (but that was something with ServiceLoader)...how can i do it?
    for(int i = 0; files != null && i < files.length; i++) {
         MyClassLoader pluginLoader = null;
         try {
              pluginLoader = new MyClassLoader(MyConstants.MODULES_PATH+files);
         } catch(MalformedURLException e) {
              System.out.println("Exception: " + e.getMessage());
         // cut off extension for className
         int dot = files[i].lastIndexOf(MyConstants.MODULE_EXTENSION);
         String className = files[i].substring(0, dot);
         MyPluginInterface plugin = null;
         try {
              plugin = (MyPluginInterface)pluginLoader.findClass(className).newInstance();
         } catch(Exception e) {
              System.out.println("Exception: " + e.getMessage());
    this works (for one of the jars with this package then):plugin = (MyPluginInterface)pluginLoader.findClass("my.package.in.jar."+className).newInstance();
    public class MyClassLoader extends URLClassLoader {
         public MyClassLoader (String filenName) throws MalformedURLException {
              super(new URL[]{new File(filenName).toURI().toURL()}, MyClassLoader.class.getClassLoader());
         public Class<?> findClass(String name) throws ClassNotFoundException {
              return super.findClass(name);
    thx for you help!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    YES! just a bit of work and it's running nice :-)
    if(!(Constants.MODULES_PATH.endsWith("/"))) Constants.MODULES_PATH = Constants.MODULES_PATH + "/";
    File path = new File(Constants.MODULES_PATH);
    if(path.exists() && path.isDirectory()) {
         // find all .jar files
         String[] files = path.list(new FilenameFilter() {
              public boolean accept(File d, String name) { return name.endsWith(Constants.MODULE_EXTENSION); }
         for(int i = 0; files != null && i < files.length; i++) {
              // create class loader for jar
              MySystemClassLoader classLoader = null;
              try {
                   classLoader = new MySystemClassLoader(Constants.MODULES_PATH+files);
              } catch(MalformedURLException e) {
                   System.out.println("Exception: " + e.getMessage());
              // load service(s)/module(s) (can be more than one in a jar!)
              ServiceLoader<ModuleInterface> moduleLoader = ServiceLoader.load(ModuleInterface.class, classLoader);
              for(ModuleInterface module : moduleLoader) {
                   System.out.println("load module: "+module.getClass().getName()+"!");
    }and this as class loader (given to the service loader)public class MySystemClassLoader extends URLClassLoader {
         public MySystemClassLoader(String filenName) throws MalformedURLException {
              super(new URL[]{new File(filenName).toURI().toURL()}, MySystemClassLoader.class.getClassLoader());
         public Class<?> findClass(String name) throws ClassNotFoundException {
              return super.findClass(name);
    in the jar-file (module/service) you need a file named as the interface (path.to.package.ModuleInterface) inside of a folder "META-INF/services/" and contains just as a string (path.to.package.ModuleImplementation) the name of the implementaion class (in the jar-file)
    Edited by: mrp_cologne on Jul 21, 2008 3:55 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Weblogic 12c JSF2 and EJB3.1 using CDI injection , in separate jar files

    I am trying to inject a stateless EJB and  managed Bean of JSF2 into a CDI managed controller.
    That means using @inject replace @EJB of EJB and @Named of CDI replace @ManageBean in JSF2 ,  EJB3.1 and JSF2 in separate jar files.
    At result,My  test  gets the following Exception in  weblogic 12c。
    If EJB in separate files and Managed Bean of JSF in WEB-INF/classes not separte file, then no problem.
    weblogic.management.DeploymentException:
         at weblogic.application.internal.BaseDeployment.throwAppException(BaseDeployment.java:123)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:239)
         at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:48)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ISaleInfoService] with qualifiers [@Default] at injection point [[field] @Inject private com.hylandtec.hystone.showcase.web.SaleInfoBean.saleInfoService]
         at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:258)
         at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:105)
         at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:125)
         at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:324)
         at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:309)
         at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:361)
         at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:105)
         at com.oracle.injection.integration.CDIAppDeploymentExtension.prepare(CDIAppDeploymentExtension.java:60)
         at weblogic.application.internal.flow.AppDeploymentExtensionFlow.prepare(AppDeploymentExtensionFlow.java:23)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
         at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:48)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Edited by: user8823518 on 2012-3-12 上午12:49

    This is a Weblogic 12.1.1 bug (a patch is available), explained here:
    http://docs.oracle.com/cd/E24329_01/doc.1211/e26593/issues.htm#BCFGBBBE
    extract:
    If a WAR file has two embedded bean deployment archive JARs (that is, JARs that contain META-INF/beans.xml), an UnsatisfiedDependencyException occurs if a class in one JAR contains an @Inject that is of a type that is defined in the other JAR.
    Workaround
    +Download and install patch 13563205. Enter this value in the Patch Number Search field on the Patches & Updates tab of My Oracle Support.+

  • Launching classes with java -jar option

    hi all,
    i have read how to launch a class using the -jar option.
    Now i have one additional question.
    Suppose that the class that i want to launch contains packages from other jar files.
    Can i pack all the other jar files in the same jar, and have the code run by simply calling
    java -jar MyClass?
    if different jar packages are in the same jar file, can the main class that i want to launch see them?? or do i still
    have to specify the -cp option??
    thanx in advance and regars
    marco

    I don't know about having jar files in a jar file, but if you have class files in a jar file, you can make it so you just have to run it as
    java -jar MyJar.jar
    To make the jar file, you need to add an attribute to the manifest file. Make a text file and call it whatever you want, e.g. manifest.mf or manifest.txt.
    Add this line to it:
    Main-Class: MyMain
    if MyMain is your class with the main method. If MyMain is in a package, then you need to add that too, e.g. mypackage.MyMain.
    Now create your jar file as
    jar cfm MyJar.jar manifest.mf *.class
    After manifest.mf you add all the classes you have with spaces to separate them, or use wildcards.

  • Execute specific class/method in jar

    Hi!
    Is there any way to execute a particular main method of a class inside a jar-file? I have several main-methods that I would like to run, something like this:
    java -jar my.jar classA
    java -jar my.jar classB
    but I find no way of doing it. Is it possible?

    I thought so to. It doesn't. It says
    "NoClassDefFoundError: "I am assuming the class that isn't found is one of the main classes. Either the class is not in the jar, the class is not correctly installed into the jar, or you did not correctlys specify the class.
    For example, if the classes are in package yourpack and are named Main1 and Main2, they must be in the jar as yourpack/Main1 and yourpack/Main2. You must specify them as in
    java -classpath path/to/thejar.jar yourpack.Main1

  • Very Strange java.lang.NoClassDefFoundError. Class exists in classpath

    Dear Forum:
    Occasionally, I run into strange java.lang.NoClassDefFoundErrors.
    Here is an example: I have two different classes Class1.class and Class2.class in different jars. Both use a common class: AppContext in third jar file.
    If Class1 tries to use AppContext, it works just fine. However, if Class1 instantiates Class2 and Class2 tries to use AppContext, you get the nasty java.lang.NoClassDefFoundError, in the same thread.
    After a struggle and trying out different orders in class / library paths, the error goes away. However, I do want to know what is the better way to understand and resolve this issue?
    Here is a sample code, for illustration purposes only:
    File:Class1.java_
    Public class Class1
         Public Class1 ()
    AppContext.getLogger().logDebug(�test1�);
    //the above line works just fine.
    try
    Class2 something = new Class2();
    catch(Error ex)
         //here we get a java.lang.NoClassDefFoundError for AppContext, which works just fine from Class1.java
         ex.printstackTrace();
    File:Class2.java:_
    Public class Class2
    Public Class2()
    AppContext.getLogger().logDebug("test2");
    }

    I think I have answer to this mystery.
    This was an issue with the jdeveloper, where the jar file throwing the class not found exception was loaded by a different classloader and the jar file which could find the class was loaded by another classloader.
    I forgot to mention that this was a j2ee application being run by the internal j2ee server of Jdeveloper.

Maybe you are looking for

  • Disk repair and Apple Hardware Test says HD has no problem but grey screen still persists on MBP

    5 days ago while on vacation, my MBP just froze with the grey screen, apple logo and spinning gear. I performed all that was instructed on the following discussions: http://support.apple.com/kb/TS2570  except  Archive and Install installation of MAC

  • Lock objects to allow 1 user to insert data at a time

    Is it possible to Use lock objects to allow only 1 user to insert data into a  database table at a time. I am creating Assets using "BAPI_FIXEDASSET_CREATE1". To create "n" assets similar to the asset I use a DO loop in my program and call the BAPI.

  • COGS in Accounting document of the Invoice

    Hi All, Our client requirement is that they want to capture the Cost from Material Master u2013 Standard cost (Condition Type in pricing procedure: VPRS) in the accounting document that is generated automatically when the Billing document is created.

  • Ipod Nano 6th Gen not turning on after lcd change

    again, Hello People, =D I changed the lcd and flex cable over on a ipod nano but the new buttons didnt seem to work (power did, volume didnt). i took it out of the body and connected the touchscreen and flex cable to see if there was a kink in the fl

  • Combine rows of same value in to one row in sharepoint

    I have a list with three columns and I have the same set of values in all the three rows. column1  column2    total a              a             1 a              a             1 a              a             1 I would like to concatenate and display t