facebook

[Closed] Any way to exclude some JARs from WAR?

  1. MyEclipse Archived
  2.  > 
  3. Application Servers and Deployment
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #241202 Reply

    kurobt
    Member

    One of JARs that my project uses is a JNI library. That means it must be put in the web container’s shared library area, not the per-webapp area, so that the container’s class loader loads it, to avoid UnsatisfiedLinkError exception. (Visit
    http://wiki.apache.org/tomcat/Tomcat/Howto?highlight=%28JNI%29
    and look for “JNI” for this issue.)

    When I make a WAR file by Project Deployment (“Externally Launched”, “Packaged Archive”), it puts all the JAR files in WEB-INF/lib, including this JNI JAR that I don’t want to be loaded by the web application loader.

    Is there any way to instruct MyEclipse Project Deployment wizard to exclude this .jar? Removing this .jar from the Java Bult path is not an option because that would cause compilation errors.

    #241240 Reply

    Riyad Kalla
    Member

    The best way to do this is to create a /lib dir off the root of your project and move that one JAR into it, then remove and re-add it to your build pathj for the project, it will no longer be deployed, but you will have it for development time resolution.

    #242634 Reply

    kurobt
    Member

    I’m not sure if I understand this.
    Did you mean,
    1. Remove the JNI JAR, that is outside of the prject directory, from the build path
    2. Crate a lib dir inside the Web App project
    3. Copy the JNI JAR there
    4. Add that JNI JAR within the project to the build path
    ?

    I did these steps and did the “Externally Launched” deploy to a new directory but I still see a copy of the JNI JAR in WEB-INF/lib. Is there a magic button to tell MyEclipse not to copy the jar?

    #242635 Reply

    Riyad Kalla
    Member
    
    /MyProject
      /lib <-- put the JAR in here
      /WebRoot
        /WEB-INF
          /classes
          /lib <-- I did not mean here just incase you thought this is what I meant
    

    I did these steps and did the “Externally Launched” deploy to a new directory but I still see a copy of the JNI JAR in WEB-INF/lib. Is there a magic button to tell MyEclipse not to copy the jar?

    I should have been more clear. Go ahead and remove the deployment and recreate it. If your JAR is infact in the directory I mentioned above and added normally to your build path, it should not be deployed. If it is however in your WebRoot/WEB-INF/lib directory, it will be deployed.

    #242657 Reply

    kurobt
    Member

    Actually, you were quite clear about the location of the lib. I did lay out the stuff exactly as you mentioned, but things weren’t working.

    The reason, that I found out later, was that the dependent project also had this JNI JAR in its build and its export box was checked. I turned it off and now I no longer see the JAR in the deployment directory tree.

    Thanks!

    #242658 Reply

    Riyad Kalla
    Member

    Ahh very cool, glad it’s working!

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: [Closed] Any way to exclude some JARs from WAR?

You must be logged in to post in the forum log in