# SVG file throwing nullPointerException

**URL:** <https://discourse.processing.org/t/svg-file-throwing-nullpointerexception/18466>\
**Category:** Coding Questions\
**Created:** [March 6, 2020, 11:38pm UTC](https://discourse.processing.org/t/svg-file-throwing-nullpointerexception/18466 "2020-03-06T23:38:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://discourse.processing.org/u/martinh)\
**Post date:** [March 6, 2020, 11:38pm UTC](https://discourse.processing.org/t/svg-file-throwing-nullpointerexception/18466/1 "2020-03-06T23:38:53Z")

</div>

I was given some svg files by a colleague for incorporating a project I’m working on, but it’s throwing a nullPointerException error (Actuator.svg). snowman.svg is loading fine.

Actuator was cause a style error, but I found what they needed to do to fix that error with Adobe Illustrator. This problem I can’t locate a fix for. Any thoughts? Thanks.

```auto
  try {
    s = loadShape("Actuator.svg");
  } catch (Exception e) {
    e.printStackTrace();
    s = loadShape("snowman.svg");
  }

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 7, 2020, 5:53am UTC](https://discourse.processing.org/t/svg-file-throwing-nullpointerexception/18466/2 "2020-03-07T05:53:05Z")

</div>

When you use try early during developing a Sketch you hinder processing to throw a proper error message

Try without try

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://discourse.processing.org/u/martinh)\
**Post date:** [March 7, 2020, 1:07pm UTC](https://discourse.processing.org/t/svg-file-throwing-nullpointerexception/18466/3 "2020-03-07T13:07:30Z")

</div>

It throws a nullPointerException as noted. That’s why I put the try in to catch and try another Svg that works.

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://discourse.processing.org/u/martinh)\
**Post date:** [March 8, 2020, 3:47pm UTC](https://discourse.processing.org/t/svg-file-throwing-nullpointerexception/18466/4 "2020-03-08T15:47:34Z")

</div>

So any other thoughts?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 10, 2020, 6:59pm UTC](https://discourse.processing.org/t/svg-file-throwing-nullpointerexception/18466/5 "2020-03-10T18:59:05Z")

</div>

> [@martinh](#):
>
> Actuator was cause a style error, but I found what they needed to do to fix that error with Adobe Illustrator. This problem I can’t locate a fix for.

I don’t understand what this means. It was causing an error, but they fixed it, but they didn’t?

The SVG file spec is massive. loadShape only has limited support for it. Your SVG could contain any one of dozens of things that loadShape doesn’t support. You could try converting it to a rastor format, resaving it using SVG1.1 to force down the feature set, sharing the actual details of your error on this thread, and / or just hacking away parts of your svg until it starts working to narrow down the problem. Unfortunately there is no one reason why SVGs fail.

See also: [Get new size of PShape after transform (shear)? - #2 by snaders](https://discourse.processing.org/t/get-new-size-of-pshape-after-transform-shear/18184/2)

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://discourse.processing.org/u/martinh)\
**Post date:** [March 10, 2020, 7:24pm UTC](https://discourse.processing.org/t/svg-file-throwing-nullpointerexception/18466/6 "2020-03-10T19:24:57Z")

</div>

Ok, thank you, that helps me understand the issues.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 11, 2020, 2:49am UTC](https://discourse.processing.org/t/svg-file-throwing-nullpointerexception/18466/7 "2020-03-11T02:49:19Z")

</div>

Good luck – hope you find a fix / workaround. If you have a specific file or log to share perhaps the forum can be of more help.
