How to share dependant jars across rars & ears / avoid classcast exceptions

<b>How can one share dependant jars between a ear application and a resource adapter and avoid getting a ClassCastException? </b>
<P>
In some appservers(such as Oracle) the resource adapter is the parent of your ear classloader, so a single instance multiple classloader problem doesn't occur. But in some appservers such as BEA Weblogic this isn't the case. Not sure why BEA decided to make resource adapter class loader seperate and not the parent of ear loader...
<P>
If I bundle the resource adapter specific classes in the corresponding module archive file, I will get a class cast exception, becos I will have a <i>single instance and multiple class loader situation</i> (assuming resource adapters uses its own classloader).
<P>
Second question related to the above: Web logic documentation recommends that we bundle the common files in APP-INF direcotory for embedded resource adapter apps. If I start bundling the resource adapter in an ear file, for every ear app we will have a rar bundled. What about the JNDI names? won't you have to rename the resource adapter differently for each ear so that there is no jndi name clash? Doesn't this defeat the purpose of having one common connector for all apps?
<P>
Here is a detailed description of what I want:
Let say you have a ear file. Let's say there is a common.jar shared between your ear application (say the ejb module uses it), and your resource adapter.
<P>
In the case of Oracle's OC4J I can see there won't be any problem of having this common.jar part of the resource adapter(RA). When the RA class loader loads the rar, it makes sure the common.jar files are accessible in the chain of all class loaders it is a parent of. So, the ear loader, ejb loader etc...will have visibility -> hence no class cast exception.
<p>
But what do clients do when they want to have their ear deployable across multiple appservers not just oc4j. BEA recently changed their class loader structure...their resource loader is no longer parent of the ear, so the ejb app in the ear doesn't have visibility into common.jar packaged with rar. So, the only solution was to bundle the common.jar file with the ear. But this causes problems, because we can have a situation where certain object instances (that are not serialized or copied) can be shared across class loaders. This ends up in the single instance multiple class loader situation->hence classcastexception.
<p>
The only solution I found was to make the common.jar file a shared library. That way only one copy of the class files are there for both the rar and the ear and its visibility is there not only for rar but for ear since it is loaded by the system class loader or shared library class loader (if ther eis one such).
<P>
Please convey best practise recommendation.
Sudhakar

Pete <[email protected]> wrote:
Is there a way to have a non-EJB jar at the EJB classloader level ? Sure, just add it to the Class-Path: manifest entry in your ejb.jar.
Dimitri

Similar Messages

  • Share http session across multiple EARs

    I am curious to know the following:-
    --> is it possible to share http session across multiple EARs running on same Weblogic application server.
    i.e weblogic server/Jboss
    --> is it possible to share http session across multiple EARs running on different Weblogic application server.
    i.e weblogic server/Jboss
    Please share the steps/way to acheive the same.

    What are you trying to achieve / accomplish by splitting it up?
    e.g. Clean Build in workshop will be faster for multiple EAR's , but unless you have all your application level libraries as shared libraries you might increase your runtime footprint. or you might want independent deploy/redeploy for your apps etc.
    If however you need the session to be shared , that these aren't really independent web-applications and shouldn't be separate ear's. In most cases though you dont actually need the session as shared (e.g. a user's data is fetched from the database , you dont really need the session shared, you need a single shared sign on). So when you say is the session shared, what is the data that you need shared? should it be in the session in the first place?
    And finally are these webapp's really independent (functionally ) or not?
    Edited by: deepshet on Oct 13, 2009 2:09 PM

  • Unable to resolve setting of dependent jar file in ear

    Hi,
    I have an .ear file which as an ejb.jar and dependent.jar file. Now i set the classpath in MANIFEST.MF of ejb.jar and tried to deploy in weblogic server7.0 but my ejb is not able to identity my dependent.jar its throwing class not found error. I even tried setting up classpath even @ my MANIFEST.MF of ear also. still not able to resolve.
    So let me know does dependent.jar in ear is suppoted are not?

    Hello Sanjay,
    This should work without any problems. Can you provide your manifest.mf file?
    Meanwhile, refer to the following link for more documentation about WebLogic classloading
    and how to specify a manifest.mf file to do what you're trying to achieve:
    http://edocs.bea.com/wls/docs70/programming/classloading.html#1073491
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    Sanjay <[email protected]> wrote:
    Hi,
    I have an .ear file which as an ejb.jar and dependent.jar file. Now
    i set the classpath in MANIFEST.MF of ejb.jar and tried to deploy in
    weblogic server7.0 but my ejb is not able to identity my dependent.jar
    its throwing class not found error. I even tried setting up classpath
    even @ my MANIFEST.MF of ear also. still not able to resolve.
    So let me know does dependent.jar in ear is suppoted are not?

  • How to access a jar file in EAR file?

    I have a EAR file which contains EJB.jar file and util.jar file. Outside of EAR, I mean in client side, I need to reference util.jar file. How can I access it?
    EAR structure is
    |--+META-INF/
    |--|---application.xml
    |--|---manifest.mf
    |--EJB.jar
    |--|---+MEAT-INF/
    |--|---|--- deployment descriptors...
    |--|---|--- manifest.mf
    |--|--- EJB classes
    |--Util.jar
    Util.jar must be executed in server side. If I just add Util.jar in client program's classpath, when client program is executed, serverside Util.jar is executed? Or what else I should do in the client program to reference server-side Util.jar?

    Excellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
    Write another EAR file with the following structure:
    ear:
    META-INF/application.xml
    util.jar
    client.jar
    client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.
    Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.
    If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
    Points to note are:
    you have to repackage util.jar again inside this ear file.
    For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.
    Hope this helps,
    Sahoo

  • How to share a session across applications?

    Hi
    I am developing a web application. There will be two web applications (including mine) running in one servlet container. The user can navigate from one application to other and vice versa. We need to know how can we share a session across these applications. Any inputs in this regard will be helpful!

    You may be interested (& probably discouraged at the end) in this discussion http://forum.java.sun.com/thread.jspa?threadID=619170
    cheers,
    ram.

  • ODI - Multi development environment how to share the JAR files

    Hi,
    For some of our functionality, existing KM not sufficient so we created with our own KM and we have called some jave code which we created and place inside lib directory of ODI as a JAR file. there are four people in the development work. so we have four development environment(all are complete installation, i.e while installing we choosing Complete Option).
    One of our developer created the our own KM and he placed the jar file in his own Dev environment's lib Directory. Since four Dev environment shares the some work rep we could see the new KM and all the ODI object in all the dev env. but if we run the the ODI interface which use the new KM from other Dev environment where we dint place the jar we are getting Error.
    if we keep the jar file in all the other three Dev environment's LIB directory then respective interface working.
    here my doubt,   is there any other way to share the JAR file to all the Environment without copying into everywhere?
    Thanks
    Knidhi

    Thanks you verymuch Cezar and Ratish, now almost i got the answer for my question.
    i installed ODI Server into separate machine. it has folder structure as follows
    Directory: D:/ODIServer/oracledi/ has the following subfolder
    1.bin 2.drivers 3.lib 4.tools.
    here i need to keep my Jar files under the lib folder. am i right?
    and bin directory contains only Agent related batch files. (agent.bat, agentscheduler.bat,agentservice.bat,agentstop.bat,agentstart.bat,agentweb.bat and jython.bat and respective .sh files)
    here dont know how to precede the following things
    1. how to configure the Master and Work Repository information with ODI Server?(MR and WR i already created with the help of one the ODI Client)
    2. how to configure the Client machine to Server?
    3. Since ODI Server not having the Topology, how to create the Agent? do i need to use any one of the ODI Client for this task?
    --Thanks
    Knidhi

  • How to share one variable across multiple JVMs?

    Hi,
    How to share one string value across two applications, which are there in two different JVMs.
    Requirement is, If I update one value(static) in first server through jsp, it should update second server static value too apart from first server.
    I am using WebLogic 8.1, is there any MBean to access other application's static value?
    Please suggest!
    Thanks,
    Murthy P

    Welcome User in OTN,
    to make two projects can access its classes you should goto the project property ---> Dependencies then add the other project.
    in your case:
    try to goto you Model project property ----> Dependencies ---> Edit Dependencies .
    you will find your ViewController project. Expand it thin check to Build Output.
    you can make this for ViewContoller project also as:
    goto you ViewContoller project property ----> Dependencies ---> Edit Dependencies .
    you will find your Model project. Expand it thin check to Build Output.
    Sameh Nassar

  • Share external jars across domains

    Hello, I'm wondering what is the best practice or suggestion to share 3rd party jars across domains in JCAPS 5.1.3.
    Thanks

    Thanks for your insight moonsit.
    Also, I would like to organize my dependencies into directories (i.e. localhost/is/lib/myPorject/ext/foo.jar and localhost/is/lib/myPorject/bar.jar) and I tried various bat file to set the classpath to my jar locations....could anyone help me point me to the right directions? Or is the intergration server administration config under jvm settings the right way to do it.
    --Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to Create a jar war or ear--Probelms in deploying

    I have the following dir structure. I am using Struts 1.1 and weblogic 7.0
    APP
    +jsp
    +WEB-INF
    + ---lib
    +--- classes
    +----com
    --ap
    --action
    --beans
    --handler
    --service
    --client
    --ejb
    --valueobject
    1> Do I need to create a ear file since i want both the ejb (under service folder) and war as reusable components. Whenever we have a EJB component do we always need to have an EAR file??
    2> Whats the best way to create the jar, war or ear file. I am facing great difficulty in deploying the war.Do we need to set any classpath before we create the war and jar files except for the deployment descriptors.I have created the ejb descriptors correctly through ejbc.
    3>I have kept struts.jar,log4j.jar under lib folder. However when i create the ear and try to deploy it under weblogic it deploys the war file but gives error in deploying the jar which has the ejb. I have aslo validated the jar using ejbc.
    It gives error indicating that it requires struts.jar in classpath. If we give the classpath of struts.jar at system leve the Application deploys with ease..Can anyone tell whats the error.The jar does not use any strust component .
    4>Also the valueobject which has some beans which are used to populate the jsp through Actionformbean. Is it ok if we give refrences in both ejb jar and war?
    ie while creating jar and war folder have the valueobject in both the files or will it lead to any errors..
    Thanks in Advance
    ....

    Yes, I have tried that. But, as the server is running and the jars are in use, it throws and EditFailedException

  • How to share a Drive across a Network

    I have just added an external drive to my G5 system that I need to share across a network as my internal drive which was shared is running low on space.
    How do I make my external drive shareable? Thanks in advance for your help.

    Hi, and a warm welcome to the forums!
    Easiest way to share an external HD is with Sharepoints...
    http://www.hornware.com/sharepoints/
    It's just a GUI interface to the OS' functions, but you can also do it in NetInfo Manager with a lot more work & understanding.

  • How to share a session across multiple jws?

    Hi!
    I have this problem.
    I'm looking for a way to have shared sessions, available across multiple JWS with WLW 8.1
    I try to get a session with this code:
    WebServiceContext wsContext = WebServiceContext.currentContext(); WebServiceSession session = (WebServiceSession)wsContext.getSession();
    but it throws COntextNotFoundException....
    I added the session descriptor in weblogic.xml to set the param CookiesEnabled to true, because I read that using this code works but requires that the client support cookies to keep the HttpSession object around.
    But it's not works!
    How can I get to HTTP session from a JWS?
    And....it's possible to share a session accross multiple JWS?
    Thanks a lot!

    You may be interested (& probably discouraged at the end) in this discussion http://forum.java.sun.com/thread.jspa?threadID=619170
    cheers,
    ram.

  • How to Share All Photos Across All Devices?

    Hello.  I have a friend with an Ipad, an Iphone 5, and an Iphone 6.  He has photos on each device.  He has backed them all up to Icloud separately on the same apple id.  He has the 200gb storage option.
    The question is how can he see all his photos from all his devices on all of his devices?  Photostream is only last 1000 photos, plus Apple just killed it with ios8.  Isn't there a way to share them on all devices?  It appears there is not and that is very surprising, especially after he is paying extra to have enhanced icloud functionality.   Will he have to use a third party solution?
    Thanks for your replies.

    Copy Photos (& Videos) Between iOS Devices
    http://tinyurl.com/cnz95bc
     Cheers, Tom

  • How to use signed JAR-libs in EAR

    I have a project wich depend library my_crypto, and my_crypto depend JCE.
    When I place these lib's to WEB-INF - all works fine.
    But when I remove from WEB-INF/lib my_crypto (I have to do this one!)
    there is an Exception:
    java.lang.SecurityException: no manifiest section for signature file entry javax/crypto/spec/DHParameterSpec.class
    What's this? And how can I fix this?
    (I work on JBuilder under Windows2000, jdk 1.3.1)

    JCE code and JCE provider suppose to be installed into <jre>\lib\ext directory. Otherwise you going to have a lot of problems.
    Unfortunately the only alternative is not to use JCE at all in web application context. For example you may go with some 3rd part low level crypto (such as BouncyCasle low level crypto API).

  • How to share common classes across multiple projects in Jdeveloper?

    Hi Experts,
    I have a basic question.
    I am using Jdeveloper 11g and have divided my application into 2 projects (Model(ejb's) and Viewcontroller(jsf+managed beans etc)).
    The model project has a stateless session bean(named VisitingScholarBean) which uses a java bean class(named VisitingScholarDetails) defined in the ViewController project.
    The relevant Method in the stateless session bean is public void saveVSDetails(VisitingScholarDetails vsDetails).
    Now the issue is that the VisitingScholarDetails class is part of only the ViewController project but is being used in the Model project.
    So when I try to run the application it gives an error saying that
    weblogic.application.ModuleException: Exception preparing module: EJBModule(VisitingScholar-Model-ejb)
    [EJB:011023]An error occurred while reading the deployment descriptor. The error was:
    edu/nyu/ecoms/oaa/vs/web/backing/VisitingScholarDetails.
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:452)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
         Truncated. see log file for complete stacktrace
    java.lang.ClassNotFoundException: edu.nyu.ecoms.oaa.vs.web.backing.VisitingScholarDetails
         at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
         at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)I cannot replicate the same VisitingScholarDetails class in both projects as it will lead to duplication.
    Please let me know how to include the VisitingScholarDetails class in the ejb-jar without replicating it in the Model and View Controller projects.
    Thanks for your time and help.
    Edited by: user10376431 on Jan 24, 2010 6:25 AM

    Welcome User in OTN,
    to make two projects can access its classes you should goto the project property ---> Dependencies then add the other project.
    in your case:
    try to goto you Model project property ----> Dependencies ---> Edit Dependencies .
    you will find your ViewController project. Expand it thin check to Build Output.
    you can make this for ViewContoller project also as:
    goto you ViewContoller project property ----> Dependencies ---> Edit Dependencies .
    you will find your Model project. Expand it thin check to Build Output.
    Sameh Nassar

  • How to share projects/events across multiple users

    what's the best way to share projects and events for multiple users on the same computer?
    i want to be able to open fcpx in one user account and have access to all events and projects that i have access to as another user. basically, fcpx should look exactly the same in both accounts.

    Welcome User in OTN,
    to make two projects can access its classes you should goto the project property ---> Dependencies then add the other project.
    in your case:
    try to goto you Model project property ----> Dependencies ---> Edit Dependencies .
    you will find your ViewController project. Expand it thin check to Build Output.
    you can make this for ViewContoller project also as:
    goto you ViewContoller project property ----> Dependencies ---> Edit Dependencies .
    you will find your Model project. Expand it thin check to Build Output.
    Sameh Nassar

Maybe you are looking for

  • Connect host win 8.1 pro to vritual domain

    Hi, on my laptop I am running Win 8.1 pro (machine_1) using Hyper-v I created 3 (gen2) VM running Win2012 servers (DC,node1 node2  they  use Internal Virtual Switch) 1.DC is domain controler, I created domain AG and added node1 and onde2 to domain 2.

  • How much RAM do tab groups use (on average)? Do I need to watch out for how many groups I create?

    I may have gone overboard in the creation of Tab Groups. I say this because now my system is beginning to act a bit sluggish. I created 7 groups, two of which have 9 or 10 tabs. Should I pull back on the number of groups I create (as well as how many

  • Manufacturer Name in Service type Items

    Hi Gurus, Can anyone explain that why manufacturer name is shown in Item Listing for Service type items? We do not mention any manufacturer for service type items hence the manufacturer field should be empty for this type of items.

  • Using xml iView to get data from URL generating rss feeds

    hi, I have a URL http://xml.weather.yahoo.com/forecastrss?p=USCA1116 from the yahoo weather site. It opens XML data. I then created an XML iView in the following way: In step 3 in XML source; i typed the above URL. Clicked on Next. In Step 4 for Sele

  • Why is InDesign CS6 so slow accessing files on NAS?

    Using InDesign CS6 on Mac OSX 10.6, accessing files on an Apple Airport Time Capsule. Here is my workflow: - Access indd files on Time Capsule. - Package file with links and fonts. - Move Packages to other computer (for image processing). - Move Pack