Referencing an optional package in a jar inside an ear

UPDATE: We no longer need this as the third-party will change their shared-library ear to a jar for use on other application servers.
We have no trouble deploying an ear containing a jar as a shared library, and then referencing the classes in it from another application by specifying the appropriate <library-ref> in weblogic-application.xml.
In some installations, that shared library is not required, and indeed may not be present. In that case, the <library-ref> is unresolved, and the application will not deploy. We would like to avoid having two versions of our application - one with the <library-ref> and one without.
If we add the Extension-Name property to the manifest of the jar mentioned above, and deploy the jar (not the ear) as a shared library, our application can reference classes in that jar. The problem is that the library ear (containing the jar) comes from a third party, and we cannot extract out the jar. And the "optional package" mechanism does not appear to work for jars within ears. We've specified the Extension-Name from the library ear ( the one from the library jar is not visible) in the Extension-List of the application. There is no complaint that the optional package is unresolved, but accessing the classes gives ClassNotFoundException.
I did not find any documentation that optional package jars within an ear should be visible to other deployment units, but it seems odd that the third party would package them such that they can only be referenced with the <library-ref> (i.e. on WLS).
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/programming/libraries.html
http://java.sun.com/j2ee/verified/packaging.html
Edited by: mikereiche on Nov 11, 2011 4:34 PM

The JarInputStream class is used to read the contents of a JAR file from any input stream.
InputStream input=getResourceAsStream("/input.xml");
JarInputStream jis
=new JarInputStream(input);

Similar Messages

  • Referencing a jar inside an ear

    Hi,
    I have a program where I need to get a reference to a jar inside an ear
    file. For example, I have this variable set:
    $WL_HOME/config/mydomain/applications/test.ear and I want to set a variable
    for a jar inside this ear.
    Does anyone know the best way to do that?
    Thanks

    When you say "set a variable", do you mean read an XML or properties file
    and modify it and write it back?
    It is relatively simple using the java.util.zip / java.util.jar packages.
    Editing XML is a little harder; I would suggest relying on something like
    JDOM or the libs from The Mind Electric.
    Peace,
    Cameron Purdy
    Tangosol Inc.
    Tangosol Coherence: Clustered Coherent Cache for J2EE
    Information at http://www.tangosol.com/
    "Diane Curley" <[email protected]> wrote in message
    news:[email protected]..
    Hi,
    I have a program where I need to get a reference to a jar inside an ear
    file. For example, I have this variable set:
    $WL_HOME/config/mydomain/applications/test.ear and I want to set avariable
    for a jar inside this ear.
    Does anyone know the best way to do that?
    Thanks

  • Startup class not found if included in a jar inside the ear

    I have written a startup class, i have packed it in a jar file(along with some
    other classes). This jar is then packed in side an ear file.(This way i get one
    single distribution file). I have added the startup class in the config.xml using
    weblogic console.But at start up weblogic is unable to find the class. How to
    tell weblogic about the location of the class(classpath) which is inside the ear
    file. Error i get is as follows
    <Aug 21, 2003 8:07:23 PM IST> <Emergency> <WebLogicServer> <BEA-000342> <Unable
    to initialize the server: weblogic.t3. srvr.FatalStartupException: Can't start
    server due to startup class failure WISORCODES_SERVER - with nested exception:
    [java.lang.ClassNotFoundException: com.wisor.common.wisorcodes.rmi.WisorCodesServer]>
    *************************************************************************** The
    WebLogic Server did not start up properly. Exception raised: 'weblogic.t3.srvr.FatalStartupException:
    Can't start server due to startup class failure WISORCODES_ SERVER - with nested
    exception: [java.lang.ClassNotFoundException: com.wisor.common.wisorcodes.rmi.WisorCodesServer]'
    Reason: weblogic.t3.srvr.FatalStartupException: Can't start server due to startup
    class failure WISORCODES_SERVER - wi th nested exception: [java.lang.ClassNotFoundException:
    com.wisor.common.wisorcodes.rmi.WisorCodesServer] ***************************************************************************

    Shirish:
    Classes that are scoped in the application are only visible within the
    application, not to the system classloader.
    If you want to have startup classses scoped inside an EAR then you need to
    use Application lifecycle listeners to actually activate these startup
    classes. Application lifecycle listeners are a replacement for startup
    classes.
    You can check out an example of this in 8.1:
    $BEA_HOME/weblogic81/samples/server/examples/src/examples/splitdir/helloWorl
    dEar
    Docs for it are:
    $BEA_HOME\weblogic81\samples\server\examples\src\examples\splitdir\helloWorl
    dEar\javadoc\index.html
    Check out:
    $BEA_HOME\weblogic81\samples\server\examples\src\examples\splitdir\helloWorl
    dEar\META-INF\weblogic-applcation.xml
    <weblogic-application>
    <listener>
    <listener-class>examples.splitdir.hello.startup.ApplicationStartup</listener
    -class>
    </listener>
    </weblogic-application>
    and
    $BEA_HOME\weblogic81\samples\server\examples\src\examples\splitdir\helloWorl
    dEar
    /appStartup/examples/splitdir/hello/startup/ApplicationStartup.java
    Now if you have a "startup class" that needs to be accessible for the entire
    Server for a set of applications, I suggest just writing a single EAR with a
    dummy web-app (I think you may need a dummy module) and an applicaiton
    lifecycle listener, and have this EAR deploy before any other apps.
    Cheers
    mbg
    "Shirish" <[email protected]> wrote in message
    news:[email protected]...
    >
    I have written a startup class, i have packed it in a jar file(along withsome
    other classes). This jar is then packed in side an ear file.(This way iget one
    single distribution file). I have added the startup class in theconfig.xml using
    weblogic console.But at start up weblogic is unable to find the class. Howto
    tell weblogic about the location of the class(classpath) which is insidethe ear
    file. Error i get is as follows
    <Aug 21, 2003 8:07:23 PM IST> <Emergency> <WebLogicServer> <BEA-000342><Unable
    to initialize the server: weblogic.t3. srvr.FatalStartupException: Can'tstart
    server due to startup class failure WISORCODES_SERVER - with nestedexception:
    >
    >
    [java.lang.ClassNotFoundException:com.wisor.common.wisorcodes.rmi.WisorCodesServer]>
    >
    The
    WebLogic Server did not start up properly. Exception raised:'weblogic.t3.srvr.FatalStartupException:
    Can't start server due to startup class failure WISORCODES_ SERVER - withnested
    exception: [java.lang.ClassNotFoundException:com.wisor.common.wisorcodes.rmi.WisorCodesServer]'
    Reason: weblogic.t3.srvr.FatalStartupException: Can't start server due tostartup
    class failure WISORCODES_SERVER - wi th nested exception:[java.lang.ClassNotFoundException:
    com.wisor.common.wisorcodes.rmi.WisorCodesServer]***************************************************************************
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >

  • Optional Package - startup behavior

    Hi guys,
    Hi have an optional package (similar to a shared library) that is referenced by two different applications. This optional package is a jar file.
    When I 've a web application (WAR) I know that WebLogic will use the exploded directory in .../tmp/_WL_user to load the application, but which is the behavior when i'm using a jar file?
    Thanks

    Hi Amol,
    WebLogic jDriver for Oracle fully supports the JDBC 2.0 Optional Package API for
    distributed transactions.
    Laurent Goldsztejn
    Developer Relations Engineer
    BEA Support
    "amol desai" <[email protected]> wrote:
    >
    Do you support the optional package features? If yes , how?

  • [原创]在WLS9中使用J2EE Libraries 和 Optional Packages

    J2EE Libraries 和 Optional Packages
    概述
         J2EE Shared Libraries是Diablo的一个新特性。可以将一个J2EE模块共享给其他EAR类型的J2EE模块。你不能从非EAR访问J2EE Shared Library。J2EE Shared Library可以是任何类型的J2EE模块,但推荐打包成EAR。此外还有一种J2EE 1.4的标准共享库方式,称为 Optional Packages。区别在于 Optional Packages是基于标准的,而且不被当作J2EE模块使用。 Optional Packages提供和J2EE Libraries类似的方式将一个JAR文件被多个应用分享。optional packages必须通过部署对应的JAR文件方式先被注册到WLS。注册好后可以部署J2EE模块,通过manifest files来引用这些包。Optional packages和J2EE libraries的区别在于optional packages可以被任何J2EE模块(EAR, JAR, WAR, or RAR 文档)或扩展的目录结构引用。而J2EE libraries只能被EAR引用。
         本文附件exercise包括J2EE Libraries 和 Optional Packages的练习代码,可解压到任意位置。配置一个WLS Domain,记得用户名和密码要都设为weblogic,端口为7001。启动该Domain,并启动相应的Console。使用Domain/bin/setDomainEnv.cmd打开一个Prompt窗口。并把目录切换到你解压的文件的位置。然后就可以按照第五节和六节所述完成练习。如果想快速看一下练习结果,在solution中有已经配置好的两个练习的代码,部署后就可以测试。
    一。将一个应用作为J2EE Libraries或Optional Packages。
         你可以在该应用的META-INF目录下创建一个MANIFEST.MF文件,指定自己的版本。
         Extension-Name:可选。表示该库或包的名字。主调应用调用这个应用时需要匹配这个值。如果你不设置这个值,系统将自动使用部署名。
         Specification-Version:可选。定义这个库或包的规格版本。主调应用可以为共享模块随便指定一个规格版本。如果这个规格版本不可用,则主调应用不能被部署。规格参数可以有两种格式。第一种使用主从版本格式,大小版本号用点分割,如"9.0.1.1"。第二种使用文本格式,如 "9011Beta"。如果使用主从版本号格式,主调应用可以配置为共享的模块吻合一个特定版本,或者一个最小版本,或者一个最新的版本额。如果使用文本格式,主调应用必须和共享模块的版本号严格吻合。
         Implementation-Version:可选。定义这个库或包代码的执行版本号。必须在已经定义了规格版本的情况下才能定义执行版本。执行版本使用和规格版本相同的格式。
         如果你不使用MANIFEST.MF文件或者有些条目没有指定,可以在命令行中通过weblogic.Deploy进行部署的时候由参数来设置。
    二。J2EE Libraries and Optional Packages比较:
         Optional packages和J2EE Libraries有如下共同点:
         1。在部署的时候都注册到WLS上。
         2。都支持可选执行版本和特定版本字符串。
         3。引用J2EE libraries and optional packages的应用可以指定共享文件的版本。
         Optional packages和J2EE Libraries有如下区别:
         1。Optional package是普通的JAR文件,而 J2EE libraries可以是普通JAR文件,或J2EE应用,或独立的J2EE模块。J2EE libraries可以包括有效地J2EE或WLS部署描述符,而optional package JAR中的任何部署描述符都被忽略了。
         2。任何J2EE应用或模块可以通过META-INF/MANIFEST.MF引用 optional package。而只有企业应用可以通过weblogic-application.xml引用J2EE library 。
         3。Optional packages可以引用其他Optional packages,而J2EE libraries不能引用其他J2EE libraries。
    三。最佳实践:
         1。如果需要共享J2EE模块给多个企业应用。使用J2EE Libraries。
         2。如果要部署独立的J2EE模块作为共享库,应该把模块打包到企业应用中。这样可以防止潜在的URI冲突。因为独立模块库的URI来源于不署名。所以在部署时指定一个部署名,当其他应用引用它时作为URI。
         3。如果多个J2EE压缩文件需要共享一些JAVA类,则应该用optional packages。
         4。如果有一些类在本Domain中需要被其他应用调用,而你又不经常省级这些类(比如第三方类),则最好把它们放在Domain的 /lib目录下,而不是使用J2EE libraries或optional packages机制。在/lib子目录下的类会在Server启动时候自动装载到系统环境变量中。
         5。通常指定一个规范版本和一个执行版本。即使你不打算使用版本需要功能。为库指定版本可以在做测试时为共享的文件部署多个版本。
         6。通常为每个库指定一个扩展名,如果你不指定扩展名那系统会自动使用库的部署名作为扩展名。
         7。当开发了一个Web应用要部署成J2EE应用,应该使用唯一的上下文目录。如果它的上下文目录和他依赖的应用的上下文目录冲突,应该使用EAR的weblogic-application.xml中context-root元素来覆盖库的上下文目录。
    四。组装共享的J2EE Library 文件:
         几乎所有独立的J2EE模块或EA可以被部署成shareable J2EE library,但有如下限制:
         1。不能在一个J2EE library中引用另一个J2EE library.
         2。共享库不能嵌套。如果你不属一个EAR作为共享库,那整个这个EAR必须被作为一个库,而不能指定这个EAR中的某个独立J2EE模块为一个独立的库。
         3。像其他J2EE模块和企业应用一样,J2EE library必须被部署到目标Server或Cluster上去。这意味着库需要一个有效的J2EE部署描述符和WLS指定的部署描述符。
         4。推荐把J2EE libraries打包成企业应用,而不是独立的J2EE模块。因为独立模块的URI来自于部署名。默认WLS使用部署压缩文件的文件名或展开的目录名作为部署名。
         5。如果你选择把库部署成独立的J2EE模块,通常应该指定一个部署名并把这个名字作为被应用引用的URI。
    五。练习开发和部署Shared J2EE Library
         本练习在J2EEShared目录下。可以看到有两个目录,其中SharedLibraryEAR是被调用的shareable J2EE library,CallingLibraryEAR是调用该库的企业应用。通过把SharedLibraryEAR配置成共享库,CallingLibraryEAR可以访问LoanEJB就像打包在自己的EAR中。
         1.我们先来开发一个库应用。观察一下SharedLibraryEAR下面的目录结构和文件。
         目录LoanEJB是一个EJB结构。包括一个空的目录META-INF和一个包含一个JAVA文件Simple.java的目录data。LoanEJB\data目录是放EJB的源代码,Simple.java是我手写的。在LoanEJB下执行java com.bea.wls.ejbgen.EJBGen -descriptorDir META-INF data\Simple.java就会在生成SimpleHome.java,SimpleRemote.java,ejb-jar.xml,weblogic-ejb-jar.xml和ejbgen-build.xml。然后到LoanEJB编译这几个CLASS:javac data\*.java,生成根和桩文件。最后执行jar cvf ..\LoanEJB.jar *,打包我们需要的EJB LoanEJB.jar到SharedLibraryEAR目录。
         目录APP-INF是一个空的目录,可以放入当前这个应用需要的第三方包。
         目录META-INF下包括application.xml和weblogic-application.xml。application.xml指定了这个应用所包含的只有一个EAR模块:LoanEJB.jar,以及这个应用的部署名。为了把这个应用做成共享库,现在我们创建一个MANIFEST.MF文件,并在里面写入如下信息:
              Extension-Name: myLib
              Specification-Version: 1.0
              Implementation-Version: 1.0
         然后在J2EEShared下执行java weblogic.appc SharedLibraryEAR,生成可部署的企业应用。
         2.配置 CallingLibraryEAR来引用SharedLibraryEAR模块。观察一下CallingLibraryEAR下面的目录结构和文件。
         目录APP-INF是放EAR内部公用的类和库的目录。在这个练习中不需要使用。
         目录LoanApproval是一个Web应用。index.jsp用于调用EJB LoanEJB的getString方法,而没有指定这个EJB是来自本企业应用还是其他库。如果调用成功,则把在LoanEJB中设置的一个字符串显示在浏览器上。
         目录META-INF中包括application.xml和weblogic-application.xml。application.xml指定了这个应用所包含的只有一个Web模块LoanApproval。在weblogic-application.xml中除了编码方式,我们还要指定使用的共享库的名称。能看到在library-ref中我们指向了SharedLibraryEAR这个库myLib。同时在这个文件中我们还能指定库的规格版本和执行版本,以及是否需要严格匹配等。
         在J2EEShared目录下执行 java weblogic.appc -library SharedLibraryEAR CallingLibraryEAR来预编译JSP。执行后会看到在LoanApproval\WEB-INF\classes下面会生成一个目录jsp_servlet包含JSP被编译成的Servlet__index.class和__error.class。由于在weblogic-application.xml中指定了使用的共享库,所以appc在调用jspc来编译JSP的时候能找到调用的EJB LoanEJB的命名空间以及对应类。
         3。部署共享库和前端企业应用并测试。
         确保你的Server运行的情况下,在J2EEShared下执行下面两个命令来部署SharedLibraryEAR和CallingLibraryEAR。注意执行以前Console不能使被Look状态的。
              java weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password weblogic -deploy -library SharedLibraryEAR
         执行之后在Console的Deployments部分能看到新添加了一个名为myLib(1.0)的库,状态为Installed。
              java weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password weblogic -deploy CallingLibraryEAR
         执行之后在Console的Deployments部分能看到新添加了一个名为CallingLibraryEAR的应用,状态为Active。
         如果部署成功,在Console和Prompt都不会有报错。打开一个浏览器测试一下:http://localhost:7001/LoanApproval。如果一切正常,会显示在EJB中设置的那行字符串。
         注意,当需要卸载库的时候,必须先卸载引用这个包的所有应用,然后Activate Change,然后再Look,并且卸载库。
    六。练习开发和部署optional packages
         本练习在OptionalPackages目录下。可以看到两个目录,其中SimpappOptionalPackage是被调用的Optional Packages,SimpappEAR是调用该包的企业应用。通过把SimpappEAR配制成共享包,SimpappOptionalPackage可以访问Simpapp类就像打包在自己的EAR中。
         1。我们先来开发一个Optional Packages。观察一下SimpappOptionalPackage下面的目录结构和文件。
         目录META-INF中现在是空的。需要创建一个MANIFEST.MF文件,包括如下内容:
              Extension-Name: myOptionalPackage
              Specification-Version: 0.9
              Implementation-Version: 1
         目录simp下面包含一个源代码文件Simpapp.java。在OptionalPackages\SimpappOptionalPackage\下执行javac simp/Simple.java,会在simp目录下编译出Simple.class。然后执行 jar cvfm simpapp.jar META-INF/MANIFEST.MF *,把这个类打成一个名为simpapp.jar的JAR包。
         2。配置SimpappEAR来引用SimpappOptionalPackage模块。观察一下SimpappEAR下面的目录结构和文件。
         目录APP-INF和我们前面说的一样,就不赘述。
         目录META-INF下包括application.xml和weblogic-application.xml。application.xml指定了这个应用所包含的只有一个Web模块SimpappWebAp。为了把这个应用做成Optional Packages,现在我们创建一个MANIFEST.MF文件,并在里面写入如下信息:
              Extension-List: simpapp
              simpapp-Extension-Name: myOptionalPackage
              simpapp-Extension-Specification-Version: 0.9
         然后在OptionalPackages下执行java weblogic.appc -classpath SimpappOptionalPackage/simpapp.jar SimpappEAR, 生成可部署的企业应用。注意这次我们没在appc中使用-library,因为使用 optional packages的时候不需要获得它的部署描述符。但我们需要指定optional packages模块的位置放到classpath里编译JSP。
         3。部署OptionalPackages和前端企业应用并测试。
         确保你的Server运行的情况下,在OptionalPackages下执行下面两个命令来部署SimpappOptionalPackage和SimpappEAR。注意执行以前Console不能使被Look状态的。
              java weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password weblogic -deploy -library SimpappOptionalPackage\simpapp.jar
              java weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password weblogic -deploy SimpappEAR
         如果部署成功,在Console和Prompt都不会有报错。打开一个浏览器测试一下:http://localhost:7001/SimpappWebApp/。如果一切正常,会显示在Simple.java中设置的那行字符串。
    七。相关资源。
         http://e-docs.bea.com/wls/docs90/notes/new.html
    该帖由 goblinize 在 Nov 4, 2005 5:43 PM 编辑过

    另外谢谢支持征文活动,让大家先看一下,然后再考虑奖励的事情。希望大家积极参与。
    有什么问题在此积极留言,希望作者给以解答。

  • Referencing Jar inside a Jar

    Hi,
    i have a jar file. the classes inside the jar file refers to classes within another jar file. i packaged the second jar into my jar file but during runtime i get NoClassDefFoundError when i refer to the classes inside the second jar.
    i tried giving the classpath in manifest file but it does not work.
    My question is how to reference a jar which is inside another jar?
    Thanks
    Daniel

    I don't think you can reference classes inside a jar that's itself in a jar.
    However you can definitely reference classes in a (non-nested) separate jar.
    For example A.class in A.jar can reference B.class in B.jar if you put:
    Class-Path B.jar
    in A.jar's manifest file.
    One thing that screwed me up when I first tried this stuff, was that the syntax of Class-Path is not the same as I first expected. If you have more than one path items to put in your class path, you don't separate them with a colon or semicolon, but with spaces.
    good luck
    j

  • Weblogic Optional Packages - Permgen Memory Space

    Hi,
    We are packaging some common jars as Optional Packages in weblogic and using them from different EAR files.We know for classes in side the EAR, each classloader creates individual clazz objects in the permgen space.
    For classes inside the Optional packages and which are referenced in multiple EAR,does weblogic create seperate clazz instances in the permgen space for each classloader? If so then it would mean that classes inside the Optional Package will be created multiple times in the permgen space (attributed to different classloaders)
    Any idea on the behaviour will be highly appreciated.Is the situation same with shared libraries ?

    Depends on where your optinal classes are located.
    If you insert them in the system (or server) classloader they will be loaded once, by the system
    classloader. You can use the ${DOMAIN_HOME}/lib directory for this purpose. The jars located in
    this directory will be picked up and added to the end of the server classpath at server startup.
    The jars will be ordered lexically in the classpath.
    If you are using shared libraries, these shared libraries will be merged at runtime with the
    applications referencing them, so they will be local to the application and to my knowledge
    loaded by the classloader of the application and not a separate shared library classloader. Thus
    if you reference the shared library from multiple applications, the shared libraries get merged
    multiple times and loaded multiple times. The reason is that WebLogic uses classloading
    isolation between the deployed applications, so that from a classloading perspective
    other applications do not bother other applications.

  • Weblogic optional package deployment issue

    Hi All,
    I am using WLS 10.3.4. I have an J2EE web application which references a JAR library as an optional package. Here is my definition of JAR file in the library MANIFEST.MF,
    Manifest-Version: 1.0
    Extension-Name: PCGCommon2.0
    Specification-Version: 1.0.0.0
    Implementation-Version: common055jkp
    Here is my definition of JAR file reference in the application MANIFEST.MF,
    Manifest-Version: 1.0
    Extension-List: pcgcommon2
    pcgcommon2-Extension-Name: PCGCommon2.0
    pcgcommon2-Specification-Version: 1.0.0.0
    pcgcommon2-Implementation-Version: common055jkp
    I deployed the JAR library first successfully. Then I tried to deploy the application. It throws me this error as follows,
    +[J2EE:160149]Error while processing library references. Unresolved Optional Package references (in META-INF/MANIFEST.MF): [Extension-Name: PCGCommon2.0, Specification-Version: 1, Implementation-Version: common055jkp , referenced from: /opt/oracle/Oracle/Middleware/user_projects/domains/Pinellas1qDomain/servers/Pinellas1qMS3/tmp/_WL_user/ppa/cwbd0p/war].+
    Can anyone have an idea what I am missing here?
    Thanks in advance,
    -John
    Edited by: john wang on Mar 9, 2011 8:44 AM
    Edited by: john wang on Mar 9, 2011 8:58 AM

    Hi John,
    Please find the working TestCase in the following Location:
    http://middlewaremagic.com/weblogic/?p=231#comment-3144
    I am copying and pasting the README.txt file here which i attached in the TestCase:
    README.txt
    Step1). Make Sure that the Hello.java is compiled properly like following:
    javac -d . Hello.java<font color=red>Actual Trick is Making the JAR using 'M' option..... :) </font><br>
    Step2). The Most important step to Make the "HelloWorld.jar" along with the MANIFEST.MF file which is present inside "HelloWorld\META-INF\MANIFEST.MF"
    Use the below command with *'M'* as a Flag while making JAR file so that the Jar utility will not overrite the MANIFEST.MF on it's own rather it will place our own MANIFEST.MF inside the Jar.
    C:\OptionalPackageDemo\HelloWorld\> jar -cvfM  HelloWorld.jar META-INF\MANIFEST.MF Hello.java com
    Step3). Deploy the HelloWorld.jar and the TestWebApp
    <b><font color=red>NOTE: </font></b> I just now tested the attached TestCase in WLS10.3.0 And it perfectly worked for me. So if it's not working for you in WLS10.3.4 then i would request you to please open a Support Ticket with Oracle WebLogic Support Team because ideally the same test case is supposed to work fine in that version as well.
    Thanks
    Jay SenSharma

  • Restart deployment (.ear) does not load optional package

    Hello everybody,
    In our 10.3.5 WLS domains, we are using optional packages for sharing libraries between applications see [http://docs.oracle.com/cd/E24329_01/web.1211/e24368/libraries.htm|Creating Shared Java EE Libraries and Optional Packages]
    The problem is that if I redeploy the library I have to redeploy the deployment. This issue only happens with the applications packaged as *.ear*. If the application has been deployed as a .war, with restarting the deployment is enough.
    Would be possible to load the referenced library from an *.ear* just restarting the deployment?
    Thanks in advance,
    Luis

    Thanks Vimala,
    I have 1 ear project and 1 web service project.
    Attached my ant output when I run the build.xml.
    C:\wivWorkSpace\wivApp>ant build -Dworkspace=C:/wivWorkSpace
    Buildfile: build.xml
    init.env:
    init.typedefs:
    init:
    build:
    [echo] project.name = wivApp
    init:
    build:
    [echo] wivWS: C:\wivWorkSpace\wivWS\build.xml
    BUILD SUCCESSFUL
    Total time: 23 seconds
    C:\wivWorkSpace\wivApp>ant build -Dworkspace=C:/wivWorkSpace archive
    Buildfile: build.xml
    init.env:
    init.typedefs:
    init:
    build:
    [echo] project.name = wivApp
    init:
    build:
    [echo] wivWS: C:\wivWorkSpace\wivWS\build.xml
    init.env:
    init.typedefs:
    init:
    stage:
    [delete] Deleting directory C:\wivWorkSpace\wivApp\.staging
    [mkdir] Created dir: C:\wivWorkSpace\wivApp\.staging
    [copy] Copying 13 files to C:\wivWorkSpace\wivApp\.staging
    BUILD FAILED
    C:\wivWorkSpace\wivApp\build.xml:192: The following error occurred while executing this line:
    jar:file:/C:/BEAPLA%7e1/WEBLOG%7e1/workshop/lib/wlw-antlib.jar!/com/bea/wlw/antlib/antlib.xml:91: The follow
    ng this line:
    C:\wivWorkSpace\wivApp\build.xml:204: The following error occurred while executing this line:
    Target `stage.to.ear' does not exist in this project.
    Total time: 15 seconds

  • Is it possible to redeploy Optional Package(J2EELibrary)without versioning?

    Currently, I decided to use Optional Package feature for one of our common shared jar file as it is referenced by our multiple applications (ear files). I can understand, how I can deploy multiple version of the optional package in order for the referencing application to use it. I am planning to use this version feature for optional package in our Production Environment. However, my issue is I don't want to use this version feature in our development environment as it involves more work for the developers (overhead on the developers to specify the optional package version in their referencing application). Is there any way I can redeploy optional package in development environment? I can only redeploy only after undeploying all my 6 referencing applications, which is taking more time.

    Does any one have an example to implement Optional Package and versioning it?

  • Persistence Layer deployed as Optional Package

    Environment:
    - WebLogic 11g which consequently means EJB 3.0
    - Application has 3 modules: Web (referencing EJB and Persistence), EJB (referencing Persistence) and Persistence
    Could I deploy my persistence layer as an Optional Package or does it have to be a Shared Library?
    The reason I'm asking is that when I try to deploy my EJB module, WLS can't find the persistence unit being inject to it:
    Unable to deploy EJB: StocksBean from BLayer-1.0.0-SNAPSHOT.jar: No persistence unit named 'internalAppsPU' is available in scope BLayer-1.0.0-SNAPSHOT.jar. Available persistence units: []
    Persistence module is basically a JAR file deployed as an Optional Package with following in its Manifest:
    Extension-Name: PersistenceLayer
    Implementation-Version: 1.0.0-SNAPSHOT
    Specification-Version: 1.6
    in EJB's code I have:
    @Stateless(name="StocksBean", mappedName="StocksBean")
    public class StocksBean implements Stocks {
         @PersistenceContext(unitName = "internalAppsPU")
         private EntityManager em;
    and in EJB's JAR file I have:
    pLayer-Extension-Name: PersistenceLayer
    pLayer-Implementation-Version: 1.0.0-SNAPSHOT
    pLayer-Specification-Version: 1.6
    I'm deploying these one by one and not as an Application.

    Hi Arun,
    Thank you so much for taking time and responding. I'm still having the same issue.
    You see, I had the exact same problem when my persistence Entities were in the same Jar file as EJBs and I found out the problem was the name of the persistence.xml file (which was "Persistence.xml") and also the version of the namespace used in the XML file which conflicted with version of JPA's spi (version of JPA's spi in JEE1.6 is 1.0 and I was using version 2.0 of the namespace).
    However, I got that fixed and now I'm trying to separate the layers (just moved the files around and didn't change the content). Here is what I have so far:
    Name of Persistence Layer's JAR file: PLayer.jar
    Manifest of Persistence Layer's JAR file:
    Manifest-Version: 1.0
    Archiver-Version: Plexus Archiver
    Created-By: Apache Maven
    Built-By: bm03043
    Build-Jdk: 1.6.0_18
    Extension-Name: PersistenceLayer
    Implementation-Version: 1.0.0-SNAPSHOT
    Specification-Version: 1.6
    Name of EJB's JAR file: BLayer-1.0.0-SNAPSHOT.jar
    Manifest of EJB's JAR file:
    Manifest-Version: 1.0
    Archiver-Version: Plexus Archiver
    Created-By: Apache Maven
    Built-By: bm03043
    Build-Jdk: 1.6.0_18
    Extension-List: PLayer
    PLayer-Extension-Name: PersistenceLayer
    PLayer-Implementation-Version: 1.0.0-SNAPSHOT
    PLayer-Specification-Version: 1.6
    I didn't know that Extension-List entry in EJB's jar file should match with the name of Persistence layer's jar file.
    As for deployment, I deploy the Player and then EJB.
    Appreciate any input.
    Edited by: Keibi on Apr 26, 2012 11:30 AM

  • Loading jars inside jars

    I'm currently building a console launcher that automatically fetches the console UI classes from servers and then caches them to client machine. User can then launch console UIs of different kinds of servers using unified launcher.
    My problem is that most of the console UIs are dependant of other libraries and extracting these libs inside the UI jar is not an option. I've tried to package all jars including the console UI application itself into a another jar but hitting the wall currently when I try to accomplish something like this:
    1. Check if disk cache already contains the jar file with md5
    2. If not fetch the jar to disk
    3. Open the jar file
    4. Fetch all jars inside the jar and pass them to new classloader from classloaderpool <- This is where i hit the wall as I can't figure how to make the classloading of jars inside another jar.
    It seems that i can't create JarFile instances from inputstreams but only from specified filenames.
    I tried to use uberjar from codehaus but couldn't figure how to instantiate the main class of the console ui with parameters from inside another application.

    I suddenly find myself with a similar problem. My app is deployed with webstart, but I need to put a jar file in there (edtftpj-1.3.2.jar) so it can use FTP. Where do I put it? Right now it's inside a lib directory, but it's not getting found by the app that calls it.
    Help?
    --- Eric

  • Optional package versus shared library

    I quote from the WL docs...
    "Optional packages differ from Java EE libraries because optional packages can be referenced from any Java EE module (EAR, JAR, WAR, or RAR archive) or exploded archive directory. Java EE libraries can be referenced only from a valid Enterprise Application. "
    Does this mean that javaee libraries can be accessed only from EAR and WAR
    whereas optionalpackage can be accessed from ear,jar , war or rar.....
    in otherwords javaee libraries cannot be accessed from a regular jar or rar...
    if that is the case, I wish they had just said so!

    Hi,
    EAR Shared Library Cannot be referenced by A WAR Application...EAR Shared Library Should be referenced By An EAR Application Only.
    Similarly...a WAR Shared Library cannot be referenced by EAR....So rule:
    EAR Shared library--------should be reffered by EAR Applications
    WAR Shared Libraries ---should be reffered by WAR Applications
    I have developed a Simple TestCase to demonstrate it...Please download it from: http://www.4shared.com/file/219660365/de4e3636/SharedLibrary_TestCase.html
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com/generalweblogic/ (WebLogic Wonders Are Here)

  • Trying to use ord.jdom package with a jar - it's not working...

    Guys, I'm trying to build a Swing app that uses jdom classes and interfaces. I built the app in NetBeans, and to get the jdom packages to work, I had to mount the jdom.jar. Then suddenly, I had no errors using the jdom classes Document, Element, SAXBuilder etc. I have the program running perfectly inside the netbeans interface.
    Now, how do I get everything working together in a JAR?
    Here's the starts of the respective files:
    * CTATool.java
    * Created on January 3, 2004, 1:23 PM
    package CTATool;
    * @author  jason_michael_trk
    public class CTATool extends javax.swing.JFrame
        /** Creates new form CTATool */
        public CTATool()
            initComponents();...
    * FileWriterXML.java
    * Created on March 5, 2004, 10:06 AM
    package CTATool;
    import org.jdom.*;
    import org.jdom.output.*;
    import java.io.*;
    * @author  Jason L Michael
    public class FileWriterXML
        private Document doc;
        private FileWriter fw;
        private File f;
    I need to include in the JAR the org.jdom package. How do I do this?
    Here's the manifest I am using cirrently:
    Manifest-Version: 1.0
    Created-By: NetBeans IDE
    Specified-By: CTATool.V2.jarContent
    Main-Class: CTATool.CTAToolThe jar includes the CTATool.class file, the FileWriterXML.class file and the jdom.jar.
    I'm getting the following errors, when I attempt to execute the CTATool.V2.jar:
    java.lang.NoClassDefFoundError: org/jdom/JDOMException
            at CTATool.CTATool.saveStatsAndExit(CTATool.java:1457)
            at CTATool.CTATool.quitMenuItemActionPerformed(CTATool.java:1450)
            at CTATool.CTATool.access$400(CTATool.java:13)
            at CTATool.CTATool$5.actionPerformed(CTATool.java:157)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
            at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
            at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
            at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
            at java.awt.Component.processMouseEvent(Component.java:5134)
            at java.awt.Component.processEvent(Component.java:4931)
            at java.awt.Container.processEvent(Container.java:1566)
            at java.awt.Component.dispatchEventImpl(Component.java:3639)
            at java.awt.Container.dispatchEventImpl(Container.java:1623)
            at java.awt.Component.dispatchEvent(Component.java:3480)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
            at java.awt.Container.dispatchEventImpl(Container.java:1609)
            at java.awt.Window.dispatchEventImpl(Window.java:1590)
            at java.awt.Component.dispatchEvent(Component.java:3480)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)this is right when the FileWriterXML class is created and ran.
    Help??!??Thanks in advance!
    chewy

    I think I figured this out, if it helps anyone...
    You have to wrap up all of YOUR classes into a jar, and have a manifest entry that specifies:
    Class-Path: jdom.jar
    Next, you have to put the two together (I used a self-extracting zip file. It contained MyApp.jar and jdom.jar).
    when the client extracts it onto their desktop and double clicks on MyApp.jar, it works perfectly.
    I don't think there's an easy way to package the jdom.jar in my jar and make this work.
    Hope this helps some other wary traveler!
    chewy

  • JARs inside my JAR

    Hi Folks,
    I'm creating a JAR file for my application. My app uses another JAR file and I want to package it inside my jar.
    I tried to use "Path-Class" attribute in MANIFEST.MF file but without success.
    Any help would be appreciate.
    TIA.
    Romualdo Rubens de Freitas

    I wonder how you missed to recognize that jars DO contain jars for four years, as you subscribed in 2001.
    Of course the standard class loader cannot handle jars in jars, but many solutions do exist for this problem. (It was really a problem, since almost all java applications are required to ship with jars inside jars).
    The best solution I encountered, is the fat_jar plugin for eclipse. If you are not an eclipse user try ONEJar.
    Being silent is sometimes better than to provide non-solutions for problems for which solutions exist.

Maybe you are looking for