Hi Ken,
Please find jar file for whole nb project from the attachment.
You can find the generate war file under dist directory.
I tidy the src, now it will not generate the jar file under
WEB-INF\lib, but play the same the effect.
the files in libraries is not included.
Thanks,
Jim
Ken Paulsen wrote:
>
> Here the expected app structure:
>
> / <--- docroot where your .jsf / .jsp / images / .css / .js and
> other files go
> /WEB-INF <--- where your web.xml / faces-config.xml files go
> /WEB-INF/lib <-- Where your .jar files go
> /WEB-INF/classes <--- if you don't .jar up your classes, you can put
> the classes under this directory (make sure they're in the right
> subdirectory according to package)
>
> JSFTemplating has a feature to move files out of the docroot in to a
> .jar file, but I'm going to ignore that for now.
>
> The .jar files in your "lib" directory that contain "handlers" should
> have this structure:
>
> /some/package/YourFile.class
> /META-INF/jsftemplating/Handler.map
>
> That's it. If you want to send me your files, just .jar them up and
> I'll take a look.
>
> As for the error directory cannot be deleted error... I don't know why
> this is happening. I have heard of something similar to this
> happening in older version of the app server, but I don't think newer
> versions have this problem. Also, I think only Windows has this
> problem. I'm not sure what the cause / solution is. You might try
> posting to dev_at_glassfish.dev.java.net. It's been a long time since
> I've developed on windows, but I think if you have a file open (i.e.
> in NetBeans), it might lock that file and prevent you from deleting
> it. I'm not sure, though.
>
> God luck!
>
> Ken
>
>
> Jim Jiang wrote:
>
>> Thanks, Ken,
>>
>> I checked the file structure and found sth:
>> under WEB-INF/lib directory, there is no jar file but 2 directories,
>> one for class, another is META-INF/jsftemplating with Handler.map file
>> I created a jar file which contains all files under WEB-INF/lib, then
>> generated the war and deploy it. Some change happen, I can found my
>> handler in the info.jsf! But abc.jsf still not works, the error
>> prompts java.lang.ClassNotFoundException as below.
>>
>> javax.servlet.ServletException: demo.glassfish.ExampleHandlers
>> javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
>> com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
>> *....*
>>
>> java.lang.ClassNotFoundException: demo.glassfish.ExampleHandlers
>> java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>> java.security.AccessController.doPrivileged(Native Method)
>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>> ....
>>
>> I found that both WEB-INF/lib and WEB-INF/classes directory have the
>> same classes, but their size are different.
>> I wrote a jsp to access the handler demo.glassfish.ExampleHandlers,
>> it shows it is in the classpath.
>> BTW, there is another problem look strange, I can not deploy jsf war
>> file twice to glassfish because of following error :
>> /CLI171 Command deploy failed : Deploying application in domain
>> failed; Cannot deploy. Module directo
>> ry is locked and cant be deleted: {1}
>> /
>> Looking forward to your further suggestion.
>>
>> Thanks,
>> Jim
>>
>> Ken Paulsen wrote:
>>
>>>
>>> Yes, it sounds like your directory structure is fine. Here's what
>>> I'd do first to try to debug it:
>>>
>>> Find your GlassFish installation and goto domains/domain1/config and
>>> look at the domain.xml to see where your app is deployed (it might
>>> not be where you think it is). Then I'd goto that directory and
>>> double check that in the WEB-INF/lib directory there is a .jar file
>>> w/ a Handler.map file with the expected contents.
>>>
>>> Hopefully that will show you the error... b/c there isn't much more
>>> to it then that! :)
>>>
>>> Ken
>>>
>>> Jim Jiang wrote:
>>>
>>>> I tried restart and redeploy, but they not works.
>>>> How to make sure my change is in the classpath?
>>>> As i said before, META-INF/jsftemplating/Handler.map is generated
>>>> in the war WEB-INF/lib directory.
>>>> I use Netbean jsf wizard to create project, does the war file
>>>> structure it generated meet the requirement jsftemplate?
>>>>
>>>> Thanks,
>>>> Jim
>>>>
>>>> Ken Paulsen wrote:
>>>>
>>>>>
>>>>> If it's still showing "Test.getResponse" on the info.jsf page,
>>>>> then one of the following must be happening:
>>>>>
>>>>> 1) Your changes aren't in the classpath.
>>>>> 2) You haven't restarted the server (or redeployed the app)
>>>>>
>>>>> The container's classloader caches things in the classpath, so
>>>>> redeploying or restarting the server is necessary. You can also
>>>>> use the ".reload" feature, which essentially redeploys... I've had
>>>>> problems w/ this feature in the past, but I think those problems
>>>>> have been addressed.
>>>>>
>>>>> Good luck!
>>>>>
>>>>> Ken
>>>>>
>>>>>
>>>>> Jim Jiang wrote:
>>>>>
>>>>>> Both answer is 'Yes'.
>>>>>> I clean and build project , the Handler.map show the
>>>>>> 'tt.getResponse' .
>>>>>> The only difference between my step with the guide is that I copy
>>>>>> all the needed jar to <glassfish>/lib, to reduce the war size for
>>>>>> quicker deployment.
>>>>>>
>>>>>> Thanks,
>>>>>> Jim
>>>>>>
>>>>>> Anissa Lam wrote:
>>>>>>
>>>>>>> Hi Jim,
>>>>>>> After changing the name of the method, did you 'clean and build
>>>>>>> project' ?
>>>>>>> When you look at the Handler.map, does it show
>>>>>>> 'tt.getResponse' or 'Test.getResponse' ?
>>>>>>>
>>>>>>> Anissa
>>>>>>>
>>>>>>> Jim Jiang wrote:
>>>>>>>
>>>>>>>> I have a basic question about JSFTemplate.
>>>>>>>> I followed the guide 'Templating for JavaServer™ Faces
>>>>>>>> Technology -- NetBeans Project Tutorial' , and deploy and run
>>>>>>>> the demo successfully.
>>>>>>>> But when I tried to modified the demo to change handler name
>>>>>>>> from Test.getResponse to * tt.*getResponse, I got below error
>>>>>>>> when running abc.jsf.
>>>>>>>>
>>>>>>>> /javax.servlet.ServletException: Handler 'tt*.*getResponse' in
>>>>>>>> event 'beforeEncode' is not declared! Ensure the '_at_Handler'
>>>>>>>> annotation has been defined on the handler Java method, that it
>>>>>>>> has been compiled with the annotation processing tool, and that
>>>>>>>> the resulting 'META-INF/jsftemplating/Handler.map' is located
>>>>>>>> in your classpath (you may need to do a clean build)./
>>>>>>>>
>>>>>>>>
>>>>>>>> I only changed 2 place:
>>>>>>>> One is in abc.jsf: (the bold text)
>>>>>>>> <!beforeEncode
>>>>>>>> * tt.*getResponse(upper(userInput="#{in}"
>>>>>>>> response=>$pageSession{foo});
>>>>>>>> />
>>>>>>>> Another is in ExampleHandlers.java
>>>>>>>> @Handler(id="*tt*.getResponse",
>>>>>>>> input={
>>>>>>>> @HandlerInput(name="userInput", type=String.class)
>>>>>>>> },
>>>>>>>> output={
>>>>>>>> @HandlerOutput(name="response", type=String.class)
>>>>>>>> })
>>>>>>>>
>>>>>>>> I make sure that the file META-INF/jsftemplating/Handler.map is
>>>>>>>> generated in the war WEB-INF/lib directory.
>>>>>>>> but the info.jsf always show the handler I defined, it always
>>>>>>>> show Test.getReponse.
>>>>>>>>
>>>>>>>> Any other place need to be changed for just renaming handler?
>>>>>>>> BTW, I use Netbean 5.5.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Jim
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>