External Project Assets fails to import models

When I try to import a model into a project created using the “External Project Assets” project type, I get an IllegalStateException “Cannot find project AssetManager!”



If I create a BasicGame project and File | Import Model a simple model, it imports successfully and converts to j3o.



If I use File | Import Project | External Project Assets to create an assets-only project, then File | Import Model the same simple model. It previews OK, but when I click Finish nothing happens. In the JME messages.log I get:


SEVERE [org.openide.util.Exceptions]
java.lang.IllegalStateException: Cannot find project AssetManager!
at com.jme3.gde.modelimporter.ImportModel.copyModel(ImportModel.java:80)
at com.jme3.gde.modelimporter.ImportModel.access$000(ImportModel.java:35)
[catch] at com.jme3.gde.modelimporter.ImportModel$1.run(ImportModel.java:62)
at java.lang.Thread.run(Thread.java:680)


The SDK created an assets.jmp file in my assets-only project which references my assets directory - but there is no nbproject directory or any other project files. Also in the Project Explorer, the "Project Assets" looks like a normal folder icon, whereas in the BasicGame project it has a yellow cabinet icon.

So it doesn't seem like "External Project Assets" is correctly setting up an assets-only project.
1 Like

It has to be in the defined assets folder.

When you set up the project you set the project root and the assets folder inside. The ProjectAssetManager only has access to that folder and the paths have to be relative to that folder.

@normen said:
It has to be in the defined assets folder.
When you set up the project you set the project root and the assets folder inside. The ProjectAssetManager only has access to that folder and the paths have to be relative to that folder.


I when I import the external assets project I set the project root to "/asset-test" and the assets folder to "assets" (i.e. a folder relative to asset-test) and "/asset-test/assets" exists.

The problem doesn't seem to be that the ProjectAssetManager doesn't have access - the problem is there is no ProjectAssetManager. That exception is thrown from jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java because this lookup is returning null:
[java]ProjectAssetManager manager = context.getLookup().lookup(ProjectAssetManager.class);[/java]
1 Like
@rectalogic said:
I when I import the external assets project I set the project root to "/asset-test" and the assets folder to "assets" (i.e. a folder relative to asset-test) and "/asset-test/assets" exists.

The problem doesn't seem to be that the ProjectAssetManager doesn't have access - the problem is there is no ProjectAssetManager. That exception is thrown from jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java because this lookup is returning null:
[java]ProjectAssetManager manager = context.getLookup().lookup(ProjectAssetManager.class);[/java]

Hm, strange. So you say that happens when when it wants to copy and import it after you went through the wizard? Yeah, that would be the actual projects assetManager then (the import wizard creates one for the folder of the model thats to be imported too).. Though its strange that the manager doesn't exist when the project is being created properly. You _can_ open it as a project, right?

I have a library project with assets in it and I find I can’t access those assets in scene composer etc. It sounds pretty similar. I have to move the objects to the simple application project, make the changes/do imports/etc there … and then move them back afterwards.



(My library project isn’t anything fancy…just a netbeans jar library project.)

1 Like

Okay, thanks for reporting, maybe that broke at some point without me noticing. I’ll check into this.

btw do your paths have any backslashes in them? if yes try replacing them with forward slashes.

@normen said:
btw do your paths have any backslashes in them? if yes try replacing them with forward slashes.


No backslashes.

I can’t really reproduce this, I get an assets.jmp and a nbproject folder with a project.properties and a private folder and the project has a “normal” project assets node, a library node and an “important files” node.

I just created a standard java library (jar) project, not a JME project…assets inside that don’t work.

@zarch said:
I just created a standard java library (jar) project, not a JME project...assets inside that don't work.

correct
@normen said:
I can't really reproduce this, I get an assets.jmp and a nbproject folder with a project.properties and a private folder and the project has a "normal" project assets node, a library node and an "important files" node.


Hmm, I only get assets.jmp - no nbproject folder or project.properties is created. I was testing on MacOS, I'll try with Windows later and see if that's different.
@rectalogic said:
Hmm, I only get assets.jmp - no nbproject folder or project.properties is created. I was testing on MacOS, I'll try with Windows later and see if that's different.


I tried on Windows 7 - same issue. When I import "External Project Assets" only assets.jmp is created, no nbproject folder or project.properties. And importing a model gets the same exception.

Am I misunderstanding how this feature is intended to be used? Why is it "import" instead of "create" a new codeless project? Am I supposed to create a normal JME3 project (like BasicGame) using "New Project..." and then import it's assets into a new codeless project or something?

What I am doing is creating a new empty directory "/path/to/asset-test" and an empty subdirectory "/path/to/asset-test/assets" then in the "External Project Assets" wizard I give it the full path to "/path/to/asset-test" and the relative path from that to "assets". This creates the file "/path/to/asset-test/assets.jmp" (which has the property assets.folder.name=assets) and nothing else, on both mac and windows. Then importing any assets into this project fails with that exception.

Its supposed to be used when you want to manage the code side of your project in another IDE, hence the “import” name. The assets subdir name has to be relative as said in the wizard, so its “/path/to/asset-test” and “assets”.

@normen I was able to fix this by adding the CodelessProjects ProjectAssetManager instance to its Lookup.



[patch]

Index: sdk/jme3-core/src/com/jme3/gde/core/codeless/CodelessProject.java

===================================================================

— sdk/jme3-core/src/com/jme3/gde/core/codeless/CodelessProject.java (revision 9590)

+++ sdk/jme3-core/src/com/jme3/gde/core/codeless/CodelessProject.java (working copy)

@@ -105,6 +105,7 @@

lkp = Lookups.fixed(new Object[]{

this, //project spec requires a project be in its own lookup

state, //allow outside code to mark the project as needing saving

  •                    projectAssetManager,<br />
    

new ActionProviderImpl(), //Provides standard actions like Build and Clean

new DemoDeleteOperation(),

new DemoCopyOperation(this),

[/patch]



I’m not sure why you weren’t able to reproduce the problem - but it seems strange that you get an nbproject and project.properties created when you import a codeless project. I don’t, and also when I create a new Asset Pack project it also doesn’t create nbproject - it only creates an assetpack.xml file, and it works fine (i.e. I can import models into it).



Anyway I compared the AssetPackProject and CodelessProject and noticed that AssetPackProject included its ProjectAssetManager in it’s Lookup, so I tried the same with CodelessProject and now it works too.

2 Likes

Cool, thanks! I just realized I got the NetBeans 7.2 based version of the SDK here, gonna check if thats why it creates the default netbeans project files as well.

Fix is committed now.