OC4J Class Loaders for Servlets

Hi all,
I know that servlets running in certain servlet engines (iPlanet for example) are loaded by different class loaders.
Since I'm trying to define a singleton class which shares data commont to all my servlets, I realized that OC4J uses different class loaders for different servlets; as a consequence, different servlets accessing my singleton class get two different objects.
This conjecture comes from the fact that using
System.identityHashcode(myClass.class.getClassLoader())
I get different codes when running different JSP.
Can someone from Oracle confirm my thoughts?
TIA
Maurizio

Hello,
It looks like you may need to find an appropriate class loader in your application for toplink.
First, let us clarify assumptions:
1. Your session bean (which is, I assume managing your TopLink persistent objects) is in an ejb.jar by itself.
2. Your application and TopLink enabled persistent classes are in a separate jar.
3. Your web interface is in a war by itself.
4. This package is bundled, complete, in an ear file and deployed as a single unit in oc4j.
5. TopLink is supplied as an oc4j level library by adding the xerces.jar and wdiall.jar in the lib directory. (antlr too if you want ejbql).
6. Your code is using the sessions.xml technique for initializing TopLink.
Having made all these assumptions about your code, the only thing you need to do to make your application work with all the various class loaders is instead of calling SessionManager.getManager().getSession("mySession"), call SessionManager.getManager().getSession("mySession",MyApplicationClassFromMyApplicationClassJar.class.getClassLoader());
This should resolve your problem. Generally, the above 6 assumptions are an approved way of structuring an application that uses session beans and TopLink for deployment in oc4j. Other ways can be made to work similarly by finding a class which has the right classloader on it. One requirement is that the class loader can see everything for the TopLink project, not just portions of it.
I hope this deluge of information helps,
Christian Weeks

Similar Messages

  • Placing class files for servlets in j2ee

    i am new to java servlets. i recently installed j2ee v1.4 sdk. i have gotten my first file that imports packages to compile. i now need a path to place .class files and .jar files. everyone says web-inf/classes and web/lib. due to the directory structure paths are so long. can someone give me the right path in j2ee v1.4 (C:\Sun\Appserver) to place these .class files and .jar files. if there is anything else i need to do before i can run a servlet, please inform me. i just want to run this silly helloWorld servlet. any suggestions would be greatly appreciated.

    Hi rickjamesb_tch,
    What you have heard is correct - you need to place your class files in the WEB-INF's classes directory (or jar files in the lib directory).
    To give you a little background, J2EE servers use custom ClassLoaders (a set of Java Classes that actually load the class into the JVM). The top-level class loaders has classes that are accessible through the JVM (and are usually picked up from the classpath).
    The other class loaders load classes that are only accessible within a particular web (or enterprise) application. These classloaders pick classes from the WEB-INF directory. These classloaders also have the capability of dynamically re-loading classes (eg when you change your .jsp file). Finally, the classes loaded are only visible within the web-application so that they do not pollute the global namespace.
    Hope that helps.
    Of course, the J2EE specification goes into a lot of depth about class loading, but unless you are designing an application server, you need not understand those details and specifics - just understanding where to place your classes is enough.

  • 'USING CLASS LOADERS FOR HOT DEPLOYMENT' not working...

    Hi all, Im trying to use use the code from:
    http://developer.java.sun.com/developer/TechTips/2000/tt1027.html#tip3 to load reload classes that have changed meanwhile the main process was running. It doesn't work for me. When I write RELOAD, it doesn't reload the new .class generated and the result is the same than after generate the new .class file.
    Any ideas? Do you have tried this and it worked for you?
    Please help me.
    Thanks in advance.
    Dani.
    the code is:
    //file ServerItf.java
    public interface ServerItf {
    public String getQuote();
    //file Client.java
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    public class Client {
    static ClassLoader cl;
    static ServerItf server;
    public static void loadNewVersionOfServer()
    throws Exception {
    URL[] serverURLs =
    new URL[]{new URL("
                file:server/")};
    cl = new URLClassLoader(serverURLs);
    server = (ServerItf) cl.loadClass(
    "ServerImpl").newInstance();
    public static void test() throws Exception {
    BufferedReader br = new BufferedReader(
    new InputStreamReader(System.in));
    loadNewVersionOfServer();
    while (true) {
    System.out.print(
    "Enter QUOTE, RELOAD, GC, or
    QUIT: ");
    String cmdRead = br.readLine();
    String cmd = cmdRead.toUpperCase();
    if (cmd.equals("QUIT")) {
    return;
    } else if (cmd.equals("
    QUOTE")) {
    System.out.println(
    server.getQuote());
    } else if (cmd.equals("
    RELOAD")) {
    loadNewVersionOfServer();
    } else if (cmd.equals("
    GC")) {
    System.gc();
    System.runFinalization();
    public static void main(String [] args) {
    try {
    test();
    catch (Exception e) {
    e.printStackTrace();
    // file ServerImpl.java. Place this file
    // in a subdirectory named 'server'.
    class Reporter {
    Class cls;
    Reporter(Class cls) {
    this.cls = cls;
    System.out.println(
    "ServerImpl class " +
    cls.hashCode() +
    " loaded into VM");
    protected void finalize() {
    System.out.println("ServerImpl
    class " +
    cls.hashCode() + " unloaded
    from VM");
    public class ServerImpl implements ServerItf {
    //catch the class being unloaded from the VM
    static Object reporter =
    new Reporter(ServerImpl.class);
    public String getQuote() {
    return "A rolling stone gathers no
    moss";
    Compile the Client and ServerItf files in a directory, and then compile the ServerImpl in a subdirectory named "server." Make sure to include the higher level directory on your class path when you compile ServerImpl, for example:
    javac -classpath \mypath\ServerImpl.java
    When you start the Client, you should see the following prompt:
    Enter QUOTE, RELOAD, GC, or QUIT:
    Enter QUOTE to see the current quote from the server:
    A rolling stone gathers no moss
    Now, without shutting down the process, use another console or GUI to edit the ServerImpl class. Change the getQuote method to return a different quote, for example, "Wet birds do not fly at night." Recompile the server class. Then return to the console where the Client is still running and enter RELOAD. This invokes the method loadNewVersionOfServer(), which uses a new instance of URLClassLoader to load a new version of the server class. You should see something like this:
    ServerImpl class 7434986 loaded into VM
    Reissue the QUOTE command. You should now see your new version of the quote, for example:
    Wet birds do not fly at night

    http://forum.java.sun.com/thread.jsp?forum=4&thread=460822&tstart=0&trange=30

  • OC4J: Class not found for class in jar file placed in \j2ee\home\applib\

    I have an ADF application which uses external libraries (jars), which works fine when running the application from within JDeveloper (TP4).
    However if I deploy the application to the embedded OC4J server it won't find any classes imported in those external libraries at runtime (deploy does work). E.g. one library class imports oracle.jbo.server.DBTransaction. If a method of this class is called I get the following exception:
    Unexpected exception caught: java.lang.NoClassDefFoundError, msg=oracle/classloader/util/AnnotatedNoClassDefFoundError
    oracle/classloader/util/AnnotatedNoClassDefFoundErrorThe same exception, when using a german locale, explicitely states that it cannot find oracle.jbo.server.DBTransaction.
    The jar files are placed in the \j2ee\home\applib\ directory and a <library> element to this path is present in application.xml.
    Any further hints what could be wrong?

    Hi Edwin,
    tried your suggestions but without success.
    when I add this library to server.xml then following error occures when starting OC4J
    17.09.2008 17:10:33 oracle.oc4j.util.SystemLog log
    SCHWERWIEGEND: Server start failed processing configuration
    java.lang.InstantiationException: Illegal tag, 'library': The library tag has moved from config/server.xml to config/application.xml, please update your configuration manually or reinstall.
            at com.evermind.server.XMLApplicationServerConfig.parseDeploymentMainNode(XMLApplicationServerConfig.java:1227)
            at com.evermind.xml.XMLConfig.parseRootNode(XMLConfig.java:342)
            at com.evermind.xml.XMLConfig.init(XMLConfig.java:222)
            at com.evermind.xml.XMLConfig.init(XMLConfig.java:154)
            at com.evermind.server.XMLApplicationServerConfig.<init>(XMLApplicationServerConfig.java:237)
            at com.evermind.server.ApplicationServer.createConfig(ApplicationServer.java:661)
            at oracle.oc4j.server.ServerFactory$Worker.prepareConfig(ApplicationServerFactory.java:225)
            at oracle.oc4j.server.ServerFactory$Worker.start(ApplicationServerFactory.java:244)
            at oracle.oc4j.server.ServerFactory$Worker.run(ApplicationServerFactory.java:259)
            at java.lang.Thread.run(Thread.java:619)
    17.09.2008 17:10:33 oracle.oc4j.util.SystemLog logNoStack
    SCHWERWIEGEND: Server exiting: ApplicationServer entered state EXITING--> I added this to application.xml
    Than I enabled more logging of classloader "-Duser.country=US -Dclass.load.log.level=finest"
    Here a snippet of the output at starttime of OC4J:
    ================================
    08/09/18 10:17:07 Initial class loaders created. Uptime: 3156ms.
    08/09/18 10:17:07 Loading main class com.evermind.server.OC4JServer...
    08/09/18 10:17:07 com.evermind.server.OC4JServerMain class loaded. Uptime: 3344ms.
    08/09/18 10:17:07 Transferring to com.evermind.server.OC4JServer.main()...
    08/09/18 10:17:15 Ignoring non-existent code source: D:\oracle\jdevstudio1111_preview4_standalone\j2ee\home\config\..\..\..\BC4J\lib\jmxdc.jar(from <code-source> (ignore manifest Class-Path) in /D:/oracle/jdevstudio1111_preview4_standalone/j2ee/home/config/server.xml)
    08/09/18 10:17:15 Ignoring <code-source> (ignore manifest Class-Path) in /D:/oracle/jdevstudio1111_preview4_standalone/j2ee/home/config/server.xml entry: code-source /D:/oracle/jdevstudio1111_preview4_standalone/j2ee/home/lib/api-ext/adflogginghandler.jar (from system property api.ext.dirs) is already visible in the search path of adf.oracle.domain:11.1.4949.
    08/09/18 10:17:15 Ignoring non-existent code source: D:\oracle\jdevstudio1111_preview4_standalone\j2ee\home\config\..\..\..\BC4J\lib\jmxdc.jar(from <code-source> (ignore manifest Class-Path) in /D:/oracle/jdevstudio1111_preview4_standalone/j2ee/home/config/server.xml)
    08/09/18 10:17:15 Import was not resolved for adf.oracle.domain:11.1.4949: shared library "oracle.fabric.runtime" could not be found.
    08/09/18 10:17:15 Import was not resolved for adf.generic.domain:11.1.4949: shared library "oracle.fabric.runtime" could not be found.Seems that oracle.fabric.runtime couldn't be found but the jar's are located in D:\oracle\jdevstudio1111_preview4_standalone\lib\java\shared\oracle.fabric.runtime\11.1.1.0.0
    It's the same as with my jdeveloper installation where I don't have this problems.
    regards
    Peter

  • Servlets / Class Loaders

              Hi,
              I have read the BEA documentation on the class loader hierarchy in Weblogic Server,
              and I have some questions regarding some behavior I am seeing.
              I am running Weblogic Server 7.0.
              I have an ear file that contains 3 web apps (wars) and several utility jars.
              The web apps' manifests contain the Class-Path entry for the utility jars. My
              understanding of this is that each web app SHOULD have its own class loader.
              Also, the utility jars will be scoped in a separate class loader and WILL NOT
              have visibility to the web app classes. The web app classes should have visibility
              to the utility jars.
              Is this correct????
              I added a static segment of code in each web app and printed the class loader
              for each servlet when it was loaded. I also printed the class loader from a class
              that is DEFINITELY contained in one of the utility jars. Here is the result:
              Utility Class ClassLoader: sun.misc.Launcher$AppClassLoader@b9d04
              Utility Class Parent ClassLoader: sun.misc.Launcher$ExtClassLoader@71732b
              Servlet 1 ClassLoader: sun.misc.Launcher$AppClassLoader@b9d04
              Servlet 1 Parent ClassLoader: sun.misc.Launcher$ExtClassLoader@71732b
              Servlet 2 ClassLoader: sun.misc.Launcher$AppClassLoader@b9d04
              Servlet 2 Parent ClassLoader: sun.misc.Launcher$ExtClassLoader@71732b
              I'm a little confused.... I expected to see 3 different class loaders (i.e.
              one for each class above). I believe the above printout says that all 3 classes
              are being loaded by the SAME class loader instance (Launcher$AppClassLoader@b9d04).
              Am I interpreting this correctly? If so, what's going on?
              

    Hi Mark,
              It sounds perfectly understandable.
              <Quote from edocs.bea.com>
              WebLogic Server classloading is centered on the concept of an application. An
              application is normally packaged in an Enterprise Archive (EAR) file
              containing application classes. Everything within an EAR file is considered
              part of the same application. Other applications include:
              An Enterprise JavaBean (EJB) JAR file
              A Web Application WAR file
              If you deploy an EJB JAR file and a Web Application WAR file separately, they
              are considered two applications. If they are deployed together
              within an EAR file, they are one application. You deploy components together
              in an EAR file for them to be considered part of the same
              application.
              </quote>
              So there is a classloader for the ear which is used to load everything in that
              ear and the parent classloader must be the one that started your weblogic
              server(or a thread which started your weblogic server).
              -Raj
              Slava Imeshev wrote:
              > Hi Mark,
              >
              > Check if that utility and webapp classes are not in the server classpath.
              >
              > Regards,
              >
              > Slava Imeshev
              >
              > "Mark Cotherman" <[email protected]> wrote in message
              > news:[email protected]...
              > >
              > > Hi,
              > >
              > > I have read the BEA documentation on the class loader hierarchy in
              > Weblogic Server,
              > > and I have some questions regarding some behavior I am seeing.
              > >
              > > I am running Weblogic Server 7.0.
              > >
              > > I have an ear file that contains 3 web apps (wars) and several utility
              > jars.
              > > The web apps' manifests contain the Class-Path entry for the utility jars.
              > My
              > > understanding of this is that each web app SHOULD have its own class
              > loader.
              > > Also, the utility jars will be scoped in a separate class loader and WILL
              > NOT
              > > have visibility to the web app classes. The web app classes should have
              > visibility
              > > to the utility jars.
              > >
              > > Is this correct????
              > >
              > > I added a static segment of code in each web app and printed the class
              > loader
              > > for each servlet when it was loaded. I also printed the class loader from
              > a class
              > > that is DEFINITELY contained in one of the utility jars. Here is the
              > result:
              > >
              > >
              > > Utility Class ClassLoader: sun.misc.Launcher$AppClassLoader@b9d04
              > > Utility Class Parent ClassLoader: sun.misc.Launcher$ExtClassLoader@71732b
              > >
              > > Servlet 1 ClassLoader: sun.misc.Launcher$AppClassLoader@b9d04
              > > Servlet 1 Parent ClassLoader: sun.misc.Launcher$ExtClassLoader@71732b
              > >
              > > Servlet 2 ClassLoader: sun.misc.Launcher$AppClassLoader@b9d04
              > > Servlet 2 Parent ClassLoader: sun.misc.Launcher$ExtClassLoader@71732b
              > >
              > >
              > >
              > > I'm a little confused.... I expected to see 3 different class loaders
              > (i.e.
              > > one for each class above). I believe the above printout says that all 3
              > classes
              > > are being loaded by the SAME class loader instance
              > (Launcher$AppClassLoader@b9d04).
              > >
              > >
              > > Am I interpreting this correctly? If so, what's going on?
              > >
              

  • InterMedia Java Classes for Servlets and JSPs and Netscape

    I am using the interMedia Java Classes for Servlets and JSPs to upload and retrieve multimedia data. I have found that it is much more performant in Internet Explorer (5.5) than in Netscape Communicator (4.7). In fact, I cannot upload images larger than 10K at all using netscape. However, the same image can be uploaded into the same application using IE. Is this a known issue?
    Thanks in advance.

    Hi,
    We have successfully uploaded multimedia data in the giga-byte range (Quicktime and AVI files) at the same speed with both the Netscape (4.7n) and MS IE (4.n and 5.n) browsers. One thing we have noticed is that its very important to set the manual proxy settings correctly if you have an environment with a proxy server. If you don't, then uploads can go via the proxy server and, for some reason, that seems to take considerably longer. For example, suppose you are in the www.xyzco.com domain and are connecting to a host named webserver.www.xyzco.com, then specify webserver and webserver.www.xyzco.com (to cover both cases) in the "Do not use proxy servers for..." box in the manual proxy server configuration screen. Also, if you're using a tool such as JDeveloper that uses the host IP address in the debugger environment, then you also need to add the numeric-based (nnn.nnn.nnn.nnn) IP address to this list.
    Hope this helps.
    In order to better understand the variety of ways in which our customers are using interMedia, we'd be very interested in knowing a little more about your application, the interMedia functionality that you are using, and how you are developing and deploying your application. If you are able to help us, please send a short email message with some information about your application, together with any comments you may have, to the Oracle interMedia Product Manager, Joe Mauro, at [email protected] Thank you!
    Regards,
    Simon
    null

  • No servlet class has been specified for servlet null

    Hi,
    I�m trying to bend tomcat in my own application. Therefore I�m using the Embedded Tomcat version 5.5.23.
    I have started only a server, engine, host and context, so I have a server without the sockets etc. this because it has to become a test-application for the web-app of the company.
    The server starts gracefully, but when I call context.invoke(request,response) I get this error:
    SEVERE: Allocate exception for servlet null
    With this stacktrace:
    javax.servlet.ServletException: No servlet class has been specified for servlet null
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1016)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:791)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:127)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:870)
    at nl.realworks.embedTomcat.EmbedTomcat.invoke(EmbedTomcat.java:74)
    at nl.realworks.embedTomcat.StartEmbedTomcat.main(StartEmbedTomcat.java:29)
    Exception in thread "main" java.lang.NullPointerException
    at org.apache.catalina.connector.Request.setAttribute(Request.java:1383)
    at org.apache.catalina.core.StandardWrapperValve.exception(StandardWrapperValve.java:331)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:145)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:870)
    at nl.realworks.embedTomcat.EmbedTomcat.invoke(EmbedTomcat.java:74)
    at nl.realworks.embedTomcat.StartEmbedTomcat.main(StartEmbedTomcat.java:29)
    does anyone has a idea what the cause of this problem is? The request I send is �GET /index.jsp� using a MockHttpServletRequest of the spring framework. I convert the mockhttpservletrequest to a org.apache.cataline.connecor.Request. and that works.
    The code in tomcat where the error is caused by:
    // Complain if no servlet class has been specified
    if (actualClass == null) {
    unavailable(null);
    throw new ServletException
    (sm.getString("standardWrapper.notClass", getName()));
    Thanks in advance.
    Auke Noppe

    Tobias
    Yes , you are correct. We dont need to replicate DDIC tables for direct BW replication. This was the first time we were working with BW on Hana and never installed DMIS component on that system. The error was gone after we put the addon.
    Mahesh Shetty

  • Parent class loaders are not searched for native libraries?

    I'm loading a native library in the default system classloader. I think create several new children of the default class loader and instantiate some new objects in those child classloaders. The problem is that those new objects get a LinkUnsatisfiedError when they try to call the native methods.
    I was under the impression that ClassLoaders would delegate native method class to their parent class loader, the same way that they do when searching for class definition. This is confirmed by this quote from http://java.sun.com/docs/books/jni/html/design.html:
    "Because each class loader maintains a set of native libraries, the programmer may use a single library to store all the native methods needed by any number of classes as long as those classes have the same defining loader."
    I'm in a serious catch-22 here, because I cannot load the native library in the child classloaders (native libs are not allowed to be loaded by multiple class loaders), and I need to put the objects in a separate classloader. What is the solution?

    i.getClass().getResourceAsStream("/hello.txt"); //this should be disallowedWhy is getting a resource so bad? It puts a dependency on a module, but in a plugin system, dependencies should be supported. Netbeans platform supports this same thing. I use image resources from some core modules at my own risk. If you really want to block it, override the getResource method of URLClassLoader to block unwanted resource fetching. You will have to use the SecurityManager, AccessController, ProtectionDomain, and AccessControlContext and I'm not going to tell you how ;)
    i.getClass().newInstance(); //something even worseNot possible to block without package private constructors or similar restrictions as above.

  • While running my app I get the below error  - have different Class objects for the type javax/servlet/http/HttpServletRequest used in the signature

    I am running ATG[10.1.2] app on Jboss [EAP 5.1.0 GA] I am able to open dyn/admin however when I start my app I get the below error
    java.lang.LinkageError: loader constraint violation: when resolving method "atg.servlet.ServletUtil.setSessionConfNumCacheRequest(Ljavax/servlet/http/HttpServletRequest;)Ljavax/servlet/http/HttpServletRequest;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, atg/filter/dspjsp/PageFilter, and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) for resolved class, atg/servlet/ServletUtil, have different Class objects for the type javax/servlet/http/HttpServletRequest used in the signature
      at atg.filter.dspjsp.PageFilter.doFilter(PageFilter.java:215)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at atg.servlet.ForwardFilter.doFilter(ForwardFilter.java:263)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at atg.servlet.ErrorFilter.doFilter(ErrorFilter.java:279)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:446)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
      at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:416)
      at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:342)
      at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:286)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:680)
    11:22:47,413 ERROR [[localhost]] Exception Processing ErrorPage[errorCode=500, location=/global/errorPage500.jsp]

    The supported JBoss version for 10.1.2 is JBoss EAP 5.1.2 but I don't think that your issue is caused because of this. Your issue is more of an environmental thing as you are probably getting two different versions getting loaded of class javax.servlet.http.HttpServletRequest and so correspondingly two different Class objects as the error shows. One reason for this could be if you include any server-specific libraries (in present case the Servlet API JAR which contains the class javax.servlet.http.HttpServletRequest) of a different version in the /WEB-INF/lib of your web application. Try removing it from there if so and see if that helps.

  • Suggest tutorial or article for understanding Java Class Loaders

    I want to learn about the Java Class Loaders, from basics to writing custom Class Loaders. Please suggest good material for the same.

    [http://www.javalobby.org/java/forums/t18345.html]
    [http://java.sun.com/developer/onlineTraining/Security/Fundamentals/magercises/ClassLoader/help.html]
    [http://publib.boulder.ibm.com/infocenter/javasdk/v1r4m2/index.jsp?topic=/com.ibm.java.doc.diagnostics.142/html/id1100.html]
    [http://onjava.com/pub/a/onjava/2005/01/26/classloading.html]
    [http://java.sun.com/developer/technicalArticles/Networking/classloaders/]
    [http://www.informit.com/articles/article.aspx?p=1187967]
    This should keep you busy.
    Usually learning about classloader's is coupled with learning to develop with Java's security features and therefore I think most Java security books dedicate a chapter for it.

  • WebLogic 11g EAR EJB Classpath and class loaders

    All,
    I have been having issues migrating Spring based EJB applications from OC4J to WebLogic 11g (10.3.1). I have been in communication with Oracle who has suggested a work around however I am keen to see if anyone else can suggest a solution.
    The application is dependant on stateless session EJB beans that communicate with a Spring managed service tier to perform the business logic and database access. PitchFork is used to inject the Spring managers into the EJB’s using the spring-ejb-jar.xml configuration file. Note originally I was using the SpringBeanAutowiringInterceptor however I could not get this to work. See WebLogic 11g and Spring beens injected into EJB for details.
    When the application is deployed packaging all the dependant jars within the APP-INF\lib folder I get a verity of errors from the following InvalidClassException, NoSuchMethodError, AbstractMethodError and IllegalArgumentException. I am using Spring 2.5.3 to match the supported WebLogic version. Note within the EAR application.xml the library-directory is set to APP-INF/lib. The issue appears to be Spring, PitchFork, commons-logging and aspectj libraries are being loaded form WebLogic and do not have visibility on jars within the application or have been modified when bundled for WebLogic. An example of this is the PitchFork jar within WebLogic has been changed excluding the spi package resulting in java.lang.ClassNotFoundException: org.springframework.jee.spi.PitchforkUtilsImpl errors.
    Moving the jars to the domain library path does not resolve any of the issues. I have been unable to successfully deploy the application picking up the application jars using the prefer-application-packages configuration.
    Oracle has advised me to deploy the libraries into the WebLogic system classpath by modifying the startWebLogic command to load the libraries into the classpath. I am concerned that modifying the system classpath will result in an unstable WebLogic server as I will be replacing modified jar files packages with WebLogic (such as PitchFork). This will also limit the applications that can be deployed within the server as each application must use the same libraries and versions (as the application ibraries are leing ignored).
    Has anyone else hit this issue and corrected it? Can anyone think of an alternative solution?
    Regards
    Neil

    Hi,
    I am in the process of updating the tracking bug# 331569 with copies of the eclipse EAR/WAR projects and the EAR for these scenarios. Here are some details on how I got past the 2nd CCE on the org.eclipse.persistence.jpa.PersistenceProvider class (not the javax one)
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=331569
    Essentially an SE persistence unit running both JPA 2.0 api and the 2.0 XSD schema work fine. I will next retest the EE case with variations of the 3 types of injection on the SSB or Servlet.
    Update: There are 3 (possibly 4) issues here (all of these may become obsolete when the next WLS version ships)Initially I got the same 2.0 schema error and the ClassCastException on org.eclipse.persistence.jpa.PersistenceProvider
    It turns out that my import of the 2 eclipse projects from my bug # 296271 for WebLogic 10.3.2.0 lost their facets(specifically the dynamic web facet) because I associated them with a different WebLogic 10.3.3.0. - this caused the CCE I was experiencing like Sri.
    Anyways, after creating an EAR/Web project combination from scratch in eclipse associated with the 10.3.3.0 instance - I predeployed/deployed/ran fine - even with the 2.0 schema - in SE bootstrap mode (no EE yet).
    Reproduction Procedure:
    redoing project from scratch as I noticed that the war was not at the root of the ear - it was a jar in the app-inf/lib dir - my imported eclipse project was not referenced correctly as a web module facet- create empty EAR and WAR project with references
    - download and open my EAR and WAR project code from bug # 296271
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=296271
    - do essentially all the steps in the page below (I paraphrase for re-verification)
    http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#DI_1.1:_Alternative_3:_Application_Level_Shared_Library_-InUse
    - copy applicationService, entity and FrontController servlet code into new projects
    - create persistence.xml and MANIFEST.MF manifest in src\META-INF
    - update manifest
    Class-Path: APP-INF/lib/eclipselink.jar
    APP-INF/lib/javax.persistence_2.0.0.v200911041116.jar
    - copy both javax.persistence 2.0 and eclipselink 2.x jars to APP-INF/lib
    - change ordering of WebLogic library modules classpath reference (javax.persistence 1.0) to ear reference (2.0 version)
    - update web.xml with servlet tags
    - update weblogic.xml with new context root
    - make the persistence unit name the same in persistence.xml and ApplicationManagedService
    - update weblogic-application.xml with prefer-application-packages overrides
    <wls:prefer-application-packages>
    <wls:package-name>javax.persistence.*</wls:package-name>
    <wls:package-name>org.eclipse.persistence.*</wls:package-name>
    </wls:prefer-application-packages>
    - enable server redirect logging
    <!-- new for 10.3.3.0 http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging#Server_Logging -->
    <property name="eclipselink.logging.logger" value="DefaultLogger"/>
    - start WebLogic 10.3.3.0
    - deploy (run on) server from eclipse or export ear to auto deploy directory
    1) JPA 2.0 XSD usage on 10.3.3.0
    - I reproduced this issue with a bad EAR
    - was able to use the 2.0 schema within the WAR-only application managed EAR
    persistence.xml<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <!-- persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"-->
    <persistence-unit name="example2" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>localJTA</jta-data-source>
    <class>org.eclipse.persistence.example.business.Cell</class>
    <shared-cache-mode>NONE</shared-cache-mode>
    <properties>
    <property name="eclipselink.target-server" value="WebLogic_10"/>
    <property name="eclipselink.logging.level" value="FINEST"/>
    <property name="eclipselink.target-database" value="Derby"/>
    <!-- new for 10.3.3.0 http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging#Server_Logging -->
    <property name="eclipselink.logging.logger" value="DefaultLogger"/>
    <!-- property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
    <property name="javax.persistence.jdbc.url" value="jdbc:derby://127.0.0.1:1527/dataparallel;create=true"/>
    <property name="javax.persistence.jdbc.user" value="APP"/>
    <property name="javax.persistence.jdbc.password" value="APP"/-->
    <!-- turn off DDL generation after the model is stable -->
    <!-- property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
    <property name="eclipselink.ddl-generation.output-mode" value="both"/-->
    </properties>
    </persistence-unit>
    </persistence>
    2) CCE on JPA provider implementation class
    Error instantiating the Persistence Provider class org.eclipse.persistence.jpa.PersistenceProvider of the PersistenceUnit example2: java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider
    - I reproduced and fixed this one (was Eclipse project facet issue) - EAR was wrong
    - was able to run JPA 2.0 code fine on an SE PU (predeploy/deploy together)
    - EE injection should not work but I will post an example EAR anyway
    log[EL Example]: enterprise: JPA 2.0 Metamodel: MetamodelImpl@56287508 [ 3 Types: , 1 ManagedTypes: , 1 EntityTypes: , 0 MappedSuperclassTypes: , 0 EmbeddableTypes: ]
    3) CCE on JPA spec interface class
    - I could not reproduce this one
    Re: WebLogic 11g EAR EJB Classpath and class loaders
    Error processing persistence unit PT of module pt: Error instantiating the Persistence Provider class org.eclipse.persistence.jpa.PersistenceProvider of the PersistenceUnit PT: java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider
    4) CCE on fallback Kodo JPA provider (if an invalid say 2.1 JPA XSD schema is referenced)
    java.lang.ClassCastException: kodo.persistence.PersistenceProviderImpl
    at javax.persistence.Persistence.findAllProviders(Persistence.java:186)
    java.lang.NoSuchMethodError: javax/persistence/EntityManager.getMetamodel()Ljavax/persistence/metamodel/Metamodel;
    - reproduced by using the 1.0 javax.persistence jar (but named as the 2.0 one in APP-INF/lib)
    - fixed by using either the 1.0 or 2.0 JPA XSD schema and using the correct 2.0 spec jar
    thank you
    /michael

  • How can I share a static field between 2 class loaders?

    Hi,
    I've been googling for 2 days and it now seems I'm not understanding something because nobody seems to have my problem. Please, somebody tell me if I'm crazy.
    The system's architecture:
    I've got a web application running in a SunOne server. The app uses Struts for the MVC part and Spring to deal with business services and DAOs.
    Beside the web app, beyond the application context, but in the same physical server, there are some processes, kind of batch processes that update tables and that kind of stuff, that run once a day. Theese processes are plain Java classes, with a main method, that are executed from ".sh" scripts with the "java" command.
    What do I need to do?
    "Simple". I need one of those Java processes to use one of the web app's service. This service has some DAOs injected by Spring. And the service itself is a bean defined in the Spring configuration file.
    The solution is made-up of 2 parts:
    1. I created a class, in the web app, with a static method that returns any bean defined in the Spring configuration file, or in other words, any bean in the application context. In my case, this method returns the service I need.
    public class SpringApplicationContext implements ApplicationContextAware {
         private static ApplicationContext appContext;
         public void setApplicationContext(ApplicationContext context) throws BeansException {
              appContext = context;
         public static Object getBean(String nombreBean) {
              return appContext.getBean(nombreBean);
    }The ApplicationContext is injected to the class by Spring through the setApplicationContext method. This is set in the Spring configuration file.
    Well, this works fine if I call the getBean method from any class in the web app. But that's not what I need. I need to get a bean from outside the web app. From the "Java batch process".
    2. Why doesn't it work from outside the web app? Because when I call getBean from the process outside the web app, a different class loader is executed to load the SpringApplicationContext class. Thus, the static field appContext is null. Am I right?
    So, the question I need you to please answer me, the question I didn't find in Google:
    How can I share the static field between the 2 class loaders?
    If I can't, how can I load the SpringApplicationContext class, from the "Java batch process", with the same class loader my web app was started?
    Or, do I need to load the SpringApplicationContext class again? Can't I use, from the process, the class already loaded by my web app?
    I' sorry about my so extensive post...
    Thank you very much!

    zibilico wrote:
    But maybe, if the web service stuff gets to complicated or it doesn't fulfill my needs, I'll set up a separate Spring context, that gets loaded everytime I run the "Java batch process". It'll have it's own Spring configuration files (these will be a fragment of the web app's config files), where I'll define only the beans I need to use, say the service and the 2 DAOs, and also the DB connection. Additionally, I'll set the classpath to use the beans classes of the web app. Thus, if the service and DAOs were modified in the app server, the process would load the modified classes in the following execution.You'll almost certainly have to do that even if you do use RMI, Web services etc. to connect.
    What I suggest is that you split your web project into two source trees, the stuff that relates strictly to the web front end and the code which will be shared with the batch. The latter can then be treated as a library used by both the batch and web projects. That can include splitting Spring configuration files into common and specific, the common beans file can be retrieved from the classpath with an include. I regularly split web projects this way anyway, it helps impose decoupling between View/Controller and Model layers.
    On the other hand, you might consider running these batch processes inside the web server on background threads.

  • How to set class path for mysql

    hai, I have been trying to make a java program read from mysql database. but i don't know how to set the class path for mysql-connector-java-5_1_.0.6-bin. i set the class path in system variable as C:\Program Files\Java\jdk1.5.0_08\jre\lib\ext\mysql-connector-java-5_1_.0.6-bin.
    in the command prompt, i compile C:\javac abc.java and run java abc.
    when run it come out error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    i am using Window xp. can anybody help me??? TQ.

    hai, I have been trying to make a java program read
    from mysql database. but i don't know how to set the
    class path for mysql-connector-java-5_1_.0.6-bin. i
    set the class path in system variable as C:\Program
    Files\Java\jdk1.5.0_08\jre\lib\ext\mysql-connector-jav
    a-5_1_.0.6-bin.
    in the command prompt, i compile C:\javac abc.java
    and run java abc.
    when run it come out error
    java.lang.ClassNotFoundException:
    com.mysql.jdbc.Driver
    i am using Window xp. can anybody help me??? TQ.Right click on my computer icon,
    Goto properties->advanced->environment variables.
    Look for 'classpath' under system variable.
    Select it and click edit.
    put ';' and path of the mysql connector jar at the end
    suppose if u have jar file under d:/driver/mysqlconnector.jar
    thn put this value in variable value text box
    ;d:/driver/mysqlconnector.jar
    or simply put ur driver jar file in jre/lib/ext folder
    D:\j2sdk1.4.2_03\jre\lib\ext
    [Servlet tutorial|http://www.jsptube.com]

  • What is the "Count" property for Servlet in Console?

    Wondering what the "Count" property for Servlet means in the Console. Is it instances
    or current uses? In other words, if the number is >1 does this mean that the Servlet
    implements the single-threaded model?
    Thanks,
    -Daniel

    btw one of the nice things about java is if you can't find the answer
    in the API or you are not sure what the API is saying you can always
    look at the source for the class your are looking at. the source files
    are in a file called src.zip or src.jar depending on the version.
    anyway just to make sure i understood i looked at the properties method
    in question.
    public String getProperty(String key) {
         Object oval = super.get(key);
         String sval = (oval instanceof String) ? (String)oval : null;
         return ((sval == null) && (defaults != null)) ? defaults.getProperty(key) : sval;
        public String getProperty(String key, String defaultValue) {
         String val = getProperty(key);
         return (val == null) ? defaultValue : val;

  • How to configure for servlets

    i m new to servlets. can any body plz tell me what and how to do configurations for servlets

    hi,
    previously you installed any server or not,
    if not install any one of web server like javawebserver , tomcat etc...
    steps to install tomcat & configure:
    http://forum.java.sun.com/thread.jspa?threadID=5193463
    after successfull config,
    create a servlet program,compile and store under tomcatx.x\webapps\root\WEB-INF\classes
    open a web.xml under WEB-INF and add <servlet> & <servlet-mapping>
    ex:
         <servlet>
              <servlet-name>servletname</servlet-name>
              <servlet-class>package.classname</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>servletname</servlet-name>
              <url-pattern>/urlvalue</url-pattern>
         </servlet-mapping>
    restart tomcat
    run : http://localhost:8080/urlvalue

Maybe you are looking for

  • Phone no longer recognized by my computer or my wall charger...HELP

    After the 2.0 upgrade had a few issues, still have a few of the apps quitting etc. these I can deal with while waiting for the fixes. The big problem is the phone now cannot connect to the computer or the charger, tried different cables {still can ch

  • My MBP experience

    I bought a MBP about 2 weeks ago after being a Windows user for many years. I have been building my own PCs for almost 10 years and my main use of them is for video editing. For the benefit of those in a similar situation, I'd like to share my experi

  • 2 Vertical Black Bars Across Screen...

    Anyone know about or experienced vertical black bars (2) across the monitor after returning from sleep or standby mode? I'm just worried my computer will crap out on me when it's most inconvenient so I'm trying to guage what computer problems/elderly

  • Report is very Slow,!!!

    Hi Every1; I am building a report of statements of different account holders, but it take much time as each page took more than 10 mins consisting of 25 rows only, please check my query is there any problem in it or not. Query i m taking the accounts

  • Salesforce attachment export corrupts pdf

    I am using informatica to export attachments from salesforce and save them to a  folder on a unix server. I am following a process similar to the attachment (this was from another discussion in this forum). This export works fine for most file types