DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Building a Flask Web Application With Docker: A Step-by-Step Guide
  • Microsoft Azure Active Directory
  • How To Build a Google Photos Clone - Part 1
  • 3 Easy Steps for a (Dev)Containerized Microservice With Jolie and Docker

Trending

  • Extracting Maximum Value From Logs
  • Distributed Tracing Best Practices
  • Monetizing APIs: Accelerate Growth and Relieve Strain on Your Engineers
  • Spring Authentication With MetaMask

Fixed: Embedded Jetty Fails To Unpack With FileNotFoundException: Not a directory

Jakub Holý user avatar by
Jakub Holý
·
Oct. 13, 13 · Interview
Like (0)
Save
Tweet
Share
5.37K Views

Join the DZone community and get the full member experience.

Join For Free

I have built an executable .war with an embedded Jetty and all the dependencies packed in using the Maven Shade and War plugins. When I tried to run it (java -jar <my war>.war) then I got a strange FileNotFoundException during the unpack phase. It was strange because the unpack code actually checks whether a file’s parent directory exists and creates it if it doesn’t.

The problem was that I use OS X which has a case-insensitive filesystem. A directory contained both the file LICENSE and the directory license/. When Jetty tried to unpack license/LICENSE.base64.txt, the check for the parent directory (license/) incorrectly succeeded (because it checked new File("[..]/license/LICENSE.base64.txt").getParentFile().exists() and that returned true because the file LICENSE already was there, and it wasn’t distinguished from the actual directory license; .isDirectory() would have at least failed.) The workaround was to exclude the offensive file from the archive:

<project ...>
    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            </transformers>
                            <finalName>fake-cc-proxy-with-dependencies</finalName>
                            <filters>
                                <filter>
                                    <artifact>*</artifact>
                                    <excludes>
                                        <exclude>META-INF/LICENSE</exclude> <!-- conflicts on OS X with license/) -->
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

This was the original exception:

2013-10-02 13:44:16.557:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@76959acc{/,null,null}{file:/Users/me/FakePM/target/fake-pm-with-dependencies.war}
java.io.FileNotFoundException: /private/var/folders/k0/2842tm752zv1dh4q77_gmgdr0000gn/T/jetty-0.0.0.0-8444-fake-pm-with-dependencies.war-_-any-/webapp/META-INF/license/LICENSE.base64.txt (Not a directory)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
    at org.eclipse.jetty.util.resource.JarResource.copyTo(JarResource.java:237)
    at org.eclipse.jetty.webapp.WebInfConfiguration.unpack(WebInfConfiguration.java:478)
    at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure(WebInfConfiguration.java:72)
    at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:453)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.Server.start(Server.java:342)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
    at org.eclipse.jetty.server.Server.doStart(Server.java:290)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at no.viatravel.poc.safecc.profilemaster.Main.startServerAndBlock(Main.java:123)
    at no.viatravel.poc.safecc.profilemaster.Main.main(Main.java:38)
2013-10-02 13:44:16.575:INFO:oejs.ServerConnector:main: Started ServerConnector@478bc78e{HTTP/1.1}{0.0.0.0:8444}

See JarResource.java:230 in jetty 9.0.5.x for the relevant code.

Directory Jetty (web server)

Published at DZone with permission of Jakub Holý, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Building a Flask Web Application With Docker: A Step-by-Step Guide
  • Microsoft Azure Active Directory
  • How To Build a Google Photos Clone - Part 1
  • 3 Easy Steps for a (Dev)Containerized Microservice With Jolie and Docker

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: