Exception: No shader code found

classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Exception: No shader code found

fmorat
In a nutshell, the file .. / ../shader/texture01_xxx.vp cannot be found.

Some context: I've created a self contained java app using the java jlink command. I've put the files of my java app within a MacOs App bundle. I modified the Info.plist to launch my main Java class. Which it does. The problem is that my app does not seem to be able to find non-class files in the jar.

Classes in the jar file are being accessed fine.

Any ideas on what I could be doing wrong?

According to this: https://stackoverflow.com/questions/8258244/accessing-a-file-inside-a-jar-file

I should be accessing the non-class files as so: InputStream in = this.getClass().getResourceAsStream("/resources/" + filename);

Which I assume it is already been done.

Everything works fine though when I run my java app from a terminal as so:

bin/java -cp bin/jogamp-fat.jar -m makinacraftmodule/com.noatechnologies.machinawjava.MachinaWJavaApp

It is only when I try to double click on the MacOs bundle that I get the exception below.

this is the exception I'm getting:

java.lang. Error: java.lang.RuntimeException: com.jogamp.opengl. GLException: No shader code found (source nor binary) for src: [.. / ../shader/texture01 xxx.vp], bin: null at makinacraftmodule/com.noatechnologies.androidjavaapp.OpenGLAndroidApp.main(OpenGLAndroidApp.java:211) at makinacraftmodule/com.noatechnologies.machinawjava.MachinaWJavaApp.main(MachinaWJavaApp.java:203) at makinacraftmodule/com.noatechnologies.machinawjava.MachinaWJavaApp.main(MachinaWavaApp.¬°ava:145) at makinacraftmodule/com.noatechnologies.machinawjava.MachinaWJavaApp.main(MachinaWJavaApp.java:111)

Caused by: java.lang. RuntimeException: com.jogamp.opengl.GLException: No shader code found (source nor binary) for src: [../ ../ shader/ texture01_xxx.vp], bin: null at jogamp.fat/com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58) at jogamp.fat/jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103) at jogamp.fat/jogamp.opengl.Threading|mpl.invokeOnOpenGLThread(Threading|mpl.java:201) at jogamp.fat/com.jogamp.opengl.Threading.invokeOnOpenGLThread(Threading.java:202) at jogamp.fat/com.jogamp.opengI.Threading.irvoke(Threading.java:221) at jogamp.fat/com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:503) at makinacraftmodule/com.noatechnologies.androidjavaapp.OpenGLAndroidApp.main(OpenGLAndroidApp.java:185)

... 3 more

Caused by: com.jogamp.opengI.GLException: No shader code found (source nor binary) for sc: [. / ../ shader/ texture01 _xxx.vp], bin: null at jogamp.fat/com.jogamp.opengl.util.gIsI.ShaderCode.create(ShaderCode.java:551) at jogamp.fat/com.jogamp.opengl.util.g|sI.ShaderCode.create(ShaderCode.java:706) at jogamp.fat/com.jogamp.opengl.util.g|sI.ShaderCode.create(ShaderCode.java:771) at jogamp.fat/jogamp.opengl.macos.cgI.MacOSXCGLContext.createCALayerShader(MacOSXCGLContext.java:188) at jogamp.fat/jogamp.opengl.macosx.cgl.MacOSXCGLContext.access$4800(MacOSXCGLContext.java:84) at jogamp.fat/jogamp.opengl.macosx.cg|.MacOSXCGLContext$NSOpenGLImpl.associateDrawable(MacOSXCGLContext.java:946) at jogamp.fat/jogamp.opengl.macosx.cgl.MacOSXCGLContext.associateDrawable(MacOSXCGLContext.java:427) at jogamp.fat/jogamp.opengl.GLContextimpl.makeCurrent(GLContextimpl.java:740) at jogamp.fat/jogamp.opengI.GLContextImpl.makeCurrent(GLContextlmpl.java:614) at jogamp.fat/jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1279) at jogamp.fat/jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147) at jogamp.fat/com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.iava:1442) at java.desktop/java.awt.event. InvocationEvent.dispatch(InvocationEvent. java:308) at java.desktop/java.awt.EventQueue.dispatchEventlmpl(EventQueue.java:773) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714) at java.base/java.security.AccessController.doPrivileged(Access Controller.java:399)

at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.dolntersectionPrivilege(ProtectionDomain.java:86)

at java.desktop/java.awt. EventQueue.dis patchEvent(EventQueue java:742) at java. desktop/java.awt. EventDis patchThread. pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java. desktop /java.awt.EventDispatchThread.pumpEventsEventDispatchThread.java:101) at java. desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)



This is my Info.plist file in case it helps.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>
    <key>CFBundleExecutable</key>
    <string>bin/MakinaCraftApp</string>
    <key>CFBundleGetInfoString</key>
    <string>MachinaWJavaApp (1)1.0, Copyright {user} 2004. All rights reserved.</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleIconFile</key>
    <string>MachinaWJavaApp (1).icns</string>
    <key>CFBundleIdentifier</key>
    <string>MakinaCraft</string>
    <key>CFBundleName</key>
    <string>MachinaWJavaApp2</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1.0.1</string>
    <key>Java</key>
    <dict>
        <key>MainClass</key>
        <string>com.noatechnologies.machinawjava.MachinaWJavaApp</string>
        <key>StartOnMainThread</key>
        <true/>
        <key>Arguments</key>
        <array/>
        <key>ClassPath</key>
        <string>$JAVAROOT/jogamp_fat.jar</string>
    </dict>
</dict>

</plist>
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

gouessej
Administrator
Hello

Why are there some spaces before .. twice in your path? I know that it's possible to find non-class files in the JAR as I do it in my game, I use my own solution to package it for OS X, I'll look at my Info.plist file and I'll compare it to yours.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
You mean here: ../ ../ shader/ texture01_xxx.v

They are just artifacts introduced during copy and paste. I think. The path is actually in the MacOSXCGLContext, which is part of jogamp code so it should be correct.

It is good to know that that your game is able to run fine. I guess it must be something else that I'm doing.

What is the name of your game if you don't mind me asking? Just curious.
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

Sven Gothel
Administrator
.. I am watching this, curious myself.

fmorat, please also attach the file produced by 'java -jar jogamp-far.jar >& jogamp-info.txt',
so we know some of your machine details, OS etc .. and add your OS version manually maybe.
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

gouessej
Administrator
In reply to this post by fmorat
fmorat wrote
What is the name of your game if you don't mind me asking? Just curious.
https://forum.jogamp.org/T-U-E-R-Truly-Unusual-Experience-of-Revolution-first-person-shooter-td4042327.html

I produce a single fat JAR which is not the smartest solution for sure.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
In reply to this post by Sven Gothel
Hello Sven, attached is the file you requested. My OS version is: macOS Ventura Version 13.5

jogamp-info.txt
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
In reply to this post by gouessej
This game looks interesting! Will try to download it once I have a chance.
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

Sven Gothel
Administrator
In reply to this post by fmorat
fmorat wrote
Hello Sven, attached is the file you requested. My OS version is: macOS Ventura Version 13.5

jogamp-info.txt
Thank you. Looks all normal.
Yeah, looks like your specific MacOS packaging sort of denies reading the shader files (using a relative path)
or perhaps you missed copying them in the 1st place into your packaging?
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
So this is the result when I run the command: jar tf jogamp-fat.jar >& joamp-fat-contents.txt

joamp-fat-contents.txt

The required files are definitely in the jar file.

jogamp/opengl/shader/texture01_xxx.vp
jogamp/opengl/shader/texture01_xxx.fp

I'm starting to think that it has something to do with the relative paths. I will do some tests to be sure.
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

Sven Gothel
Administrator
Yes, interesting indeed - especially the "fall back exception"
in ShaderCode line 551, implying ShaderCode::create() line 218
and ShaderCode:readShaderSource() line 1174 bail out quietly returning null.
I.e. `final URLConnection conn = IOUtil.getResource(..)` is null.

Perhaps use GlueGen debug property:
  -Djogamp.debug.IOUtil

or _better_ just enable all of 'em via
  -Djogl.debug=all
  -Djogamp.debug=all

Please attach the piped stdout+stderr output ( bla 2>&1 | tee mylog.txt ),
perhaps this gives us a clue - at least where we try to find the shader file (and fail).
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

Sven Gothel
Administrator
In reply to this post by fmorat
fmorat, 'just' in case it is appropriately matching a corp or org of yours,
please consider the project funding remark.
Thank you, tough times :)
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
>>morat, 'just' in case it is appropriately matching a corp or org of yours,
>>please consider the project funding remark.
>>Thank you, tough times :)

Unfortunately I'm a one man show. Wished you guys had a donation page so that people like me that use your work could donate.
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

Sven Gothel
Administrator
Thank you .. hinting just in case.
Sure, if 80k people would spend a dollar (I did setup one donation button at github)
.. but only one was using it so far :)
Hence my original idea I prefer to stick to is a corporate / org biz to biz support.

Back to the issue, please provide the log files, best with all debug enabled.
Thx.
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
In reply to this post by Sven Gothel
I think I finally figured out what's going on. I didn't mention this before but I turned the jogam-fat.jar into a module by injecting a module-info.class. This is the source code of module-info.class: module-info.java

The reason I had to do this is because jlink requires jogamp-fat.jar to be a module.

You may notice that it is not exporting any of the packages that contain any resource files. In this specific case it is not exporting jogamp.opengl.shader.

Unfortunately I tried adding an export to that package and got a compile error saying that that package was empty. It did not like it that it doesn't have any class files.

So the reason it cannot see the shaders is becasue that specific package is not being exported, but it cannot be exported because it has not classes.

I believe it may work if instead I use the opens keyword. Need to try it out.


By the way, could not get the debug property set from the MacOS App bundle.
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

Sven Gothel
Administrator
Yes, I stopped my test of creating a dual jar package adding such a module-info.java/class file
after realizing that our JAR resource stuff would need to have a module equivalent ...

I would think it should be possible to add a similar resource location within modules,
i.e. pimp up our TempJarCache .. and IOUtils - in case the OpenJDK owners didn't restrict all that.

Perhaps a good task for release 2.6.0, i.e. adding full module support to JogAmp?

+++

> By the way, could not get the debug property set from the MacOS App bundle.
Hmm, not knowing your tools etc, but doesn't it allow to add arguments
to the java launch executable?
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

gouessej
Administrator
SharderCode.class.getModule().getResourceAsStream() should work if and only if the resource file is visible in the module path. Please use --show-module-resolution to show what is visible.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
>>SharderCode.class.getModule().getResourceAsStream() should work if and only if the resource file is visible in the module path. Please use --show-module-resolution to show what is visible.

You are right. I'm able to get the file texture01_xxx.vp from my code by executing the code:

jogamp.opengl.Debug debugClass=new jogamp.opengl.Debug();
InputStream in3 = debugClass.getClass().getModule().getResourceAsStream("jogamp/opengl/shader/texture01_xxx.vp");

At least now I know of a sure way to get the resource files from a module. Unfortunately this still does not fix my problem since it is the code within jogamp-fat.jar that is trying to access that file, it is not like I can change it.  At least not without attempting to build the whole thing myself which right now I'm not prepared to do.

I'm gonna see If I can figure out a workaround.

 FYI: I also added the open keyword  in module-info.java to make all the packages open as so:

open module jogamp.fat
{
....
}



Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
In reply to this post by gouessej
>>Please use --show-module-resolution to show what is visible.

Unfortunately I was not able to do this because I have not figured out yet how to pass arguments to the jvm when it is initialized from a MacOS .app bundle
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
In reply to this post by Sven Gothel
>>Hmm, not knowing your tools etc, but doesn't it allow to add arguments
to the java launch executable?

I'm opening my app by double clicking on its .app Mac bundle.

Unfortunately I have not figured out yet how to pass arguments to the jvm when it is initialized from a MacOS .app bundle.
Reply | Threaded
Open this post in threaded view
|

Re: Exception: No shader code found

fmorat
In reply to this post by fmorat
One more thing:

Turns out that doing this also works:

jogamp.opengl.Debug debugClass=new jogamp.opengl.Debug();
InputStream in3 = debugClass.getClass().getResourceAsStream("/jogamp/opengl/shader/texture01_xxx.vp");
12