I just followed the simple example...

http://wiki.coldbox.org/wiki/Models.cfm

I just followed the simple example on the link above and I could not get it to work.

I created a sample project called CBBooks - using the cfbookclub.

I only wanted to have one example that worked pulling from one table from the service to the gateway a getallbooks().

It failed. I cannot figure out what I am doing wrong. What am I overlooking?
I attached the sample project to this post.

Thanks for any help you can give me,
Nathan

CBBooks.zip (162 KB)

When you say failed, how did it fail?

Regards,
Andrew Scott

Yes I got an error.

Oops! Exception Encountered### Application Execution ExceptionError Type: Expression : [N/A]

Error Messages: Element BOOKSERVICE is undefined in a Java object of type class [Ljava.lang.String;.

I included the sample code and it connects to the sample CF Database cfbookclub.

What is the stack trace?

What version of ColdBox are you using?

If you are using 3.0/3,1 then your DI;s need to change from

to

It looks like you need to pick between the legacy bean factory (only necessary if you’re on CF 7) and WireBox.

It looks like you have set up both modelMappings.cfm as well as WireBox.cfc. These are mutually exclusive.

The modelMappings.cfm file is only used for the legacy bean factory. WireBox.cfc is the new way going forward.
You should delete the modelMappings.cfc, and then UNCOMMENT the wirebox lines of config that set wirebox.enabled = true to turn on WireBox.

Then, like Andrew said, you need to switch from the legacy type=“model” to inject=“model”.

Also, you seem to have two copies of your BookService, one in models and one in models/book.

I can’t really try your code since you didn’t tell us what version of ColdBox you’re using.

One last thing, I would recommend configuring a file appender in logbox. It can have invaluable information about what is going on under the covers and not all pages have the default coldbox tracer (like ajax calls)

This line in your config:

info = [ “coldbox.system” ]
means you don’t want to see any debug level messages from the framework.

And this line in your config:

root = { levelmax=“INFO”, appenders="*" }
means that your root logger won’t log any debug messages either.

When trying to troubleshoot something with WireBox not injecting, try setting both of those to “DEBUG” and you should get a whole bunch of extra logging goodness (that you can turn off later) that let’s you know what’s going on.

Thanks!

~Brad

The other thing is you have all this littered in the code as well.

instance = structnew();

You will also need to remove all this, reason is very obvious as the property sets above this bit of code is being trashed by the creation of an empty structure into the instance variable.

By making all the types to injects and removing the snippet above I was able o get it up and running to a degree, from there all the errors are due to bad code in your service and gateway code. And I am sure you will be able to take it from there.

Hmm, I didn’t actually try running the code, but I wouldn’t expect the instance = structnew(); line in BookService.cfc for example to hurt anything.
The code is outside any function tags which means CF runs it immediately on component creation. That means that the injection wouldn’t happen until long after the instance struct is created.

Thanks!

~Brad

You are correct there Brad, didn’t think of that I just removed them anyway as the code is mute…

  1. Once again I used the code I found on the website documents named simple example.
    http://wiki.coldbox.org/wiki/Models.cfm (scroll down a ways and see it has the code below)
instance = structnew();
  1. Wirebox, Lightwire, ColdSpring, whatever I just want a working example that will give me bookService and book where the service calls the book object to get the information.

I downloaded the ColdBox bundle at http://www.coldbox.org/download now if I need to download a new version let me know. I am ready to go do whatever I need to but I need to get a working example.

Framework Info:
ColdBox 3.0.0 318-GENESIS-14:14
Application Name:
CB Books (environment=production)
TimeStamp:
Jul-18-2011 08:06:10 AM
Server Instance:
gold
Current Event:
General.index
Current Layout:
N/A
Current View:
N/A
Current Route:
N/A
Routed URL:
N/A
LogBox Appenders:
COLDBOXTRACER
RootLogger Levels:
FATAL - INFO
Loaded Modules:
forgebox

I might have broken something as I made so many changes to my code that I am lost as what to do to fix it.

The code you posted I dropped in and as I said made all type="" to inject="" although as Brad stated the inject is after the creation of the CFC, but in my eyes it is something that serves no purpose so I would remove it.

But that will get you to a better point, and the errors that I was getting at that point was with your code changes.

I changed the type to inject and it is still not working. since it is only simple example would you mind sending me the one you have working? I just want one example working with one service (bookService) getting the data from one object (book) and getting a getall() function from the CFBookclub (the database coldfusion installs) If I get one that works I can get it into my own code. I don’t mind admitting what I don’t know I just worked on it for 3 days 8-10hrs per day not counting other times I was working on it. (Friday, Saturday, Sunday) Personal Time spent trying to figure this out.

Can anyone help me figure out what I did wrong?

I think you and Andrew might be on different versions of ColdBox. If you are on 3.0, did you enable WireBox in the config like I said to?

I’m thinking 3.1 defaults to WireBox being enabled.

Also, did you enable any of the logging I talked about?

~Brad

Yeah I did drop CB3.1 in and although I got it working, I got as far as getAll() was not found in book.bookService.

Nathan, what point did you get up to. In other words what error are you getting at the point you are at now.

Also try what Brad has mentioned about CB3.0 and wireBox if you are using 3.0

Here is a simple example I got working with ColdBox 3.1 (maybe the docs should be fixed to work with CB 3.1 just a thought. Thanks for the help. I will keep learning CB as I go. If you see some bad practices let me know I want to do the best I can since we are starting a brand new app in CB.

CBBook.zip (177 KB)

Looks like you made some huge progress here.

When I dropped this into my test, I got an error in your mappings for wireBox.

I am not sure how you are setting up your mapPath you are using appMapping for your wirebox, I personally couldn’t find what you had this set to in your code and removed that from the wireBox.cfc to get it to work.

You might want to take that into consideration when going forward.

maybe the docs should be fixed to work with CB 3.1

Can you show us the URL of the docs that are not correct? Since there are still people out there using older versions of ColdBox, we have more than one version of the docs available. Make sure you weren’t viewing a legacy version.

Thanks!

~Brad

My very first post had the URL.
http://wiki.coldbox.org/wiki/Models.cfm

I have it working now and if I can find some time I might work up several examples using cfartgallery, cfbookclub, cfcodeexplorer, and cfdocexamples. Since those databases are installed with ColdFusion Server.

I stayed up until 3:30 am the other night and finally got it working. I am considering working on a generator since the CFCGenerator will not do my oracle database correctly and I want to generate my objects. I want to use CFScript instead of tags.

Nathan Sr.