Re: [Configuration] Problems reading Chinese text from an XMLConfiguration - Problem solved, thanks
Hello XML allows you to specify the encoding of the document, otherwise it defaults to ISO-8859-1. [...] change it to ?xml encoding=UTF-8? if that isn't in the xml document or the very first item, add it. The encoding was correctly specified in the XML document. The reason for the error was indeed the bug Oliver pointed at: Note also that in configuration 1.1 final there was a bug that the encoding was not always taken into account (http://issues.apache.org/bugzilla/show_bug.cgi?id=34204). So you might want to check out the newest version from SVN. With the current version of Commons Configuration (1.2 dev) the encoding is recognized correctly and all Chinese characters remain untouched. This works even without specifiying the encoding beforehand (by calling setEncoding() ). However, before saving a configuration to another XML document the setEncoding() method still has to be called or the file will not be stored in the desired UTF-8. Thanks alot for helping me so quickly. Best wishes, Matthias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Betwixt] Customizing Vector binding with dot betwixt file
Thank for your response Robert, i´ve been on vacations till today. I'll try your solution. robert burrell donkin wrote: On Tue, 2005-07-26 at 18:25 +0200, Rodrigo Partearroyo wrote: I´m trying to serialize a Vector of Strings. They are the security-roles allowed to access some part of my webapp. The output i need is this: security-roles security-role rol=rol1 / security-role rol=rol2 / security-role rol=rol3 / security-role rol=rol4 / /security-roles but all i can obtain is this: security-roles security-role rol=[rol1, rol2, rol3, rol4]/ /security-roles The bean i'm using is : public class SecurityRolesBean { private Vector rolesList; public SecurityRolesBean (){ rolesList = new Vector(); } public Vector getRolesList(){ return rolesList; } public void setServiceRole(String role){ setRolesList(role); } private void setRolesList(String rol){ rolesList.addElement(rol); } } and the dot betwixt file: ?xml version=1.0? info element name=security-roles element name=security-role attribute name='rol' property='rolesList'/ /element /element /info The question is: How can i put each of the Vector's elements (which are Strings) in separate xml elements? that 'attribute' tag needs to be an 'element' tag ?xml version=1.0? info element name=security-roles element name=security-role element name='rol' property='rolesList'/ /element /element /info The inverse step (populating the Bean with data read from a xml file) is done with Digester following this rule: [...] pattern value=security-role set-properties-rule alias attr-name=rol prop-name=serviceRole / /set-properties-rule /pattern [...] Due to Digester cannot perform the inverse operation (writting beans to xml files) i´m trying to move it to Betwixt, but the xml format cannot change. betwixt should handle this pretty easily. you'll need to add the name of the adder to be used to the dot betwixt file ?xml version=1.0? info element name=security-roles element name=security-role element name='rol' property='rolesList' adder='setServiceRole'/ /element /element /info please take a look at the documentation (http://jakarta.apache.org/commons/betwixt) for more details. - robert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Rodrigo Partearroyo González - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Digester: Problem with CallMethodRule
Simon Kitching wrote: On Mon, 2005-09-05 at 07:18 +0300, Mikko Nylén wrote: Hi!, I'm having a little problem with Digester's CallMethodRule: it doesn't call the method. The XML file I try to parse is: --- configuration pages page path=/index.htm class=test.TestPage / page path=/hello.htm class=test.HelloPage / /pages /configuration --- The Java code I'm trying to use for parsing the configuration: --- ... Digester digester = new Digester(); digester.addObjectCreate(configuration, test.Configuration); digester.addObjectCreate(configuration/pages/page, test.PageConfiguration); digester.addSetProperties(configuration/pages/page, new String[]{path, class}, new String[]{path, className}); digester.addCallMethod(configuration/pages/page, freeze); digester.addSetNext(configuration/pages/page, addPageConfiguration, test.PageConfiguration); Configuration configuration = (Configuration)digester.parse(reader); --- The problem is that the freeze() method of instantiated PageConfiguration objects isn't ever called (which results to that the Configuration's addPageConfiguration(PageConfiguration) throws an IllegalStateException). How I should fix this? I'm using the version 1.7 of Digester. Are you sure the problem isn't the *order* that methods get called for element configuration/pages/page rather than that the freeze method doesn't get called at all? I suggest reading the FAQ entry titled How do I get CallMethodRule to fire before SetNextRule? here: http://wiki.apache.org/jakarta-commons/Digester/FAQ Regards, Simon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Thanks! That FAQ entry solved the problem. - Mikko Nylén - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: [VFS] URLInputStream(jar:file:/Z:/some/where.jar!/META-INF/MANIFEST.MF) ???
Ups - nearly overseen this answer in the flood of postings :-) As a VFS start you can do: FileObject fo = VFS.getManager().resolveFile(jar:file://Z:/some/where.jar!/META-INF/MAN IFEST.MF); This will do what you want. Sounds good. However, as I have overseen this reply in the first hand, I tried by myself, going to use JarFile, and splitting the URI at the ! by myself. But I am sure I can need your approach for more general problems somewhere in the future. Thanks for help! Thomas I'll try to polish the docu :-) :-) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Convert list to map
Hi all, I need to do a lot of list-to-map conversions, and I'm looking for a way to use commons collections for this. I would like to do something like this: Map map = ListUtils.toMap(list, new SomeTransformerInterface() { void insertIntoMap(Object object, Map map) { SpecificObject s = (SpecificObject) object; map.put(s.getId(), s.getDescription()); } }); Does something like this exist? -- Regards, Danny Lagrouw Java Developer, Profict b.v.
[VFS] fileObject.copyFrom ?
Hi all! And what a great tool VFS is :-) Just having some startup difficulties. file = fsManager.resolveFile(/path/someDir); remDir.copyFrom(file, new AllFileSelector()); Ok, the file I want to copy is the directory + content. Somehow it is only the content of the dir that is copied?? How can i do this? thanks Jens - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[VFS] ftp and path problems?
Hi again, I want to define the absolute path for my ftp dir like this: remDir = fsManager.resolveFile(ftp://me:[EMAIL PROTECTED]/import/home2/me); That is home2 is probably a mounted dir on the server. This does not seem to work. when using an ftp client the PWD is: /.automount/idefix/root/export/home2/me But that too does not work as path. I have used the: FileSystemOptions opts = new FileSystemOptions(); FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true); That works great, but it is not exactly what I want. any help is welcome :-) Jens org.apache.commons.vfs.FileSystemException: Could not determine the type of file ftp://me:[EMAIL PROTECTED]/import/home2/me. at org.apache.commons.vfs.provider.AbstractFileObject.attach(AbstractFileObject.java:1229) at org.apache.commons.vfs.provider.AbstractFileObject.getChildren(AbstractFileObject.java:515) at app.CloneTask.run(CloneTask.java:96) at app.Clone.main(Clone.java:88) at app.CloneTask.main(CloneTask.java:62) Caused by: java.lang.NullPointerException at org.apache.commons.vfs.provider.ftp.FtpFileObject.doGetChildren(FtpFileObject.java:136) at org.apache.commons.vfs.provider.ftp.FtpFileObject.getChildFile(FtpFileObject.java:93) at org.apache.commons.vfs.provider.ftp.FtpFileObject.getInfo(FtpFileObject.java:169) at org.apache.commons.vfs.provider.ftp.FtpFileObject.doAttach(FtpFileObject.java:158) at org.apache.commons.vfs.provider.AbstractFileObject.attach(AbstractFileObject.java:1215) ... 4 more - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [VFS] fileObject.copyFrom ?
[EMAIL PROTECTED] wrote: And what a great tool VFS is :-) Just having some startup difficulties. Thanks! file = fsManager.resolveFile(/path/someDir); remDir.copyFrom(file, new AllFileSelector()); Ok, the file I want to copy is the directory + content. Somehow it is only the content of the dir that is copied?? How can i do this? I am not sure if I understand you fully, but: You do have a directory e.g. /home/im/tmp/src /home/im/tmp/src/file.txt /home/im/tmp/src/dir/file2.txt and your remDir is e.g. /home/im/tmp/dest after the copyFrom you have /home/im/tmp/dest /home/im/tmp/dest/file.txt /home/im/tmp/dest/dir/file2.txt but you would like to have: /home/im/tmp/dest/src /home/im/tmp/dest/src/file.txt /home/im/tmp/dest/src/dir/file2.txt correct? The following two code blocks will solve this: ---cut--- final FileObject foIN = VFS.getManager().resolveFile(/home/im/tmp/src/); FileObject foOUT = VFS.getManager().resolveFile(/home/im/tmp/dst/); FileObject foOUT2 = foOUT.resolveFile(foIN.getName().getBaseName()); foOUT2.copyFrom(foIN, new AllFileSelector()); ---cut--- ---cut--- final FileObject foIN = VFS.getManager().resolveFile(/home/im/tmp/src); FileObject foOUT = VFS.getManager().resolveFile(/home/im/tmp/dst); foOUT.copyFrom(foIN.getParent(), new FileSelector() { public boolean includeFile(FileSelectInfo fileInfo) throws Exception { return foIN.getName().isDescendent(fileInfo.getFile().getName(), NameScope.DESCENDENT_OR_SELF); } public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception { return fileInfo.getDepth() == 0 || includeFile(fileInfo); } }); ---cut--- Hope this helps! --- Mario - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [VFS] ftp and path problems?
[EMAIL PROTECTED] wrote: Caused by: java.lang.NullPointerException at org.apache.commons.vfs.provider.ftp.FtpFileObject.doGetChildren(FtpFileObject.java:136) at It looks like commons-net do have some problems to parse your directory listing. What ftp server do you use? Could you issue the commands syst and dir in your ftp client and post the output here. If it contains sensitive data you can send the output through personal mail. Thanks! --- Mario - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [VFS] fileObject.copyFrom ?
Yes you got it, and it works fine thanks a lot. I guess I assumed that the FileObject returned was that actual src folder, so it seemed strange that it did not appear when copying it to dest dir. thanks again Jens Mario Ivankovits wrote: [EMAIL PROTECTED] wrote: And what a great tool VFS is :-) Just having some startup difficulties. Thanks! file = fsManager.resolveFile(/path/someDir); remDir.copyFrom(file, new AllFileSelector()); Ok, the file I want to copy is the directory + content. Somehow it is only the content of the dir that is copied?? How can i do this? I am not sure if I understand you fully, but: You do have a directory e.g. /home/im/tmp/src /home/im/tmp/src/file.txt /home/im/tmp/src/dir/file2.txt and your remDir is e.g. /home/im/tmp/dest after the copyFrom you have /home/im/tmp/dest /home/im/tmp/dest/file.txt /home/im/tmp/dest/dir/file2.txt but you would like to have: /home/im/tmp/dest/src /home/im/tmp/dest/src/file.txt /home/im/tmp/dest/src/dir/file2.txt correct? The following two code blocks will solve this: ---cut--- final FileObject foIN = VFS.getManager().resolveFile(/home/im/tmp/src/); FileObject foOUT = VFS.getManager().resolveFile(/home/im/tmp/dst/); FileObject foOUT2 = foOUT.resolveFile(foIN.getName().getBaseName()); foOUT2.copyFrom(foIN, new AllFileSelector()); ---cut--- ---cut--- final FileObject foIN = VFS.getManager().resolveFile(/home/im/tmp/src); FileObject foOUT = VFS.getManager().resolveFile(/home/im/tmp/dst); foOUT.copyFrom(foIN.getParent(), new FileSelector() { public boolean includeFile(FileSelectInfo fileInfo) throws Exception { return foIN.getName().isDescendent(fileInfo.getFile().getName(), NameScope.DESCENDENT_OR_SELF); } public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception { return fileInfo.getDepth() == 0 || includeFile(fileInfo); } }); ---cut--- Hope this helps! --- Mario - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [VFS] ftp and path problems?
Boy you are fast :-) I use commons-net-1.4.0 I am not sure about the dir command. But here goes: Cmd: SYST 215: UNIX Type: L8 Cmd: NLST 425: Use PORT or PASV first. Cmd: STAT 211: FTP server status: Connected to 70.19.88.199 Logged in as schodt TYPE: ASCII No session bandwidth limit Session timeout in seconds is 300 Control connection is plain text Data connections will be plain text At session startup, client count was 4 vsFTPd 2.0.1 - secure, fast, stable End of status Cmd: PWD 257: /.automount/idefix/root/export/home2/schodt Thanks Jens - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [VFS] ftp and path problems?
Hi Cmd: NLST 425: Use PORT or PASV first. Do your ftp client do not have a dir or ls command? I guess it has something to do with your language setup on the ftp server, but I would like to see a directory listing to confirm this. Do you work on an linux/unix machine? Then we can try to tcpdump the communication between you and your ftp server. --- Mario - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jasper] compiling jsp in osgi context
hi- i'm trying to execute jsp in an osgi context with no luck as of today. i've embedded jetty as an osgi bundle and registered a BundleListener which registers installed bundles as webapp if they contain a web descriptor file. so far so good. it plays nice with simple html files. however i'm encountering troubles when it comes to jsp. generated servlets don't compile anything because javax.servlet.* classes are not found (please note that the transformation process is successfull). in the manifest i declare javax.servlet as Import-Package (most prolly this seems to cause the issue) and jetty, jasper and related dependencies as bundled libs. Also as jasper seems to require an urlclassloader i've come up with a (pretty simple) custom urlclassloader which delegates all calls to either the target bundle (i.e. the installed bundle which wraps the webapp) or the current bundle. jasper classes are succesfully loaded, but not the javax.servlet.* classes. googling about this using various criteria gives me in only three relevant results : 1/ embedded pagebox whose earlier version (2001) targets the same problematic as me. since it is released under lgpl i've tried to use it to match my specific needs, however it pretty quick became total hackery - 2000 lines src files not maintained since 2001 or so and they duplicate lot of services already provided by containers. 2/ a thread on oscar user list with no anwer 3/ a wiki page (entitled 'Tomcat as osgi bundles' and hosted on safehaus - with just a listing of bundles i'm unable to find) so i thought i could ask here if someone came to a solution to this problem. Has it already be done yet ? below are the relevant manifest entries and webapp registration code. the target bundle as no Import-Package and no classes (just the simplest hello world). webapp registration [1] assigns the currentThead contextClassLoader to the simple delegating classloader discussed above - needed to start the webapp, and [2] sets the WebApplicationContext ClassLoader to the exact same ClassLoader - which i thought would have provided javax.servlet.* classes. this may not be the best list for this question (should i rather ask on jetty or triplesec user lists ?), anyway thanks for any input. Import-Package: org.osgi.service.http,javax.servlet, javax.servlet.http,org.osgi.framework,net.joss.utils Bundle-Classpath: ., org.mortbay.jetty-5.1.4.jar, commons-logging-1.0.4.jar, servlet-api-2.4.jar, xerces-2.4.0.jar, xmlParserAPIs-2.6.2.jar, xml-apis-2.0.2.jar, jsp-api-2.0.jar, jasper-compiler-5.5.9.jar, jasper-runtime-5.5.9.jar, commons-el-1.0.jar, ant-1.6.2.jar class JettyWrapper { public void createApplication(final String appName, final File app, final Bundle fromBundle) { Thread thread = new Thread() { public void run() { try { ClassLoader loader = new DelegatingClassLoader( fromBundle, this.getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(loader);[1] String location = app.getAbsolutePath(); WebApplicationContext context = jetty.addWebApplication(/ + appName, location); context.setClassLoader(loader);[2] ... context.start(); } catch (Exception e) { LOG.error(Unable to start ' + appName + ' context, e); } } }; thread.start(); } } -- gd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jasper] compiling jsp in osgi context
I'm not sure I understand what the relationship is between what you're doing and Jakarta Commons, if there is one. Note that Jasper is part of the Tomcat project, so I would suggest asking over there. -- Martin Cooper On 9/5/05, Gilles Dodinet [EMAIL PROTECTED] wrote: hi- i'm trying to execute jsp in an osgi context with no luck as of today. i've embedded jetty as an osgi bundle and registered a BundleListener which registers installed bundles as webapp if they contain a web descriptor file. so far so good. it plays nice with simple html files. however i'm encountering troubles when it comes to jsp. generated servlets don't compile anything because javax.servlet.* classes are not found (please note that the transformation process is successfull). in the manifest i declare javax.servlet as Import-Package (most prolly this seems to cause the issue) and jetty, jasper and related dependencies as bundled libs. Also as jasper seems to require an urlclassloader i've come up with a (pretty simple) custom urlclassloader which delegates all calls to either the target bundle (i.e. the installed bundle which wraps the webapp) or the current bundle. jasper classes are succesfully loaded, but not the javax.servlet.* classes. googling about this using various criteria gives me in only three relevant results : 1/ embedded pagebox whose earlier version (2001) targets the same problematic as me. since it is released under lgpl i've tried to use it to match my specific needs, however it pretty quick became total hackery - 2000 lines src files not maintained since 2001 or so and they duplicate lot of services already provided by containers. 2/ a thread on oscar user list with no anwer 3/ a wiki page (entitled 'Tomcat as osgi bundles' and hosted on safehaus - with just a listing of bundles i'm unable to find) so i thought i could ask here if someone came to a solution to this problem. Has it already be done yet ? below are the relevant manifest entries and webapp registration code. the target bundle as no Import-Package and no classes (just the simplest hello world). webapp registration [1] assigns the currentThead contextClassLoader to the simple delegating classloader discussed above - needed to start the webapp, and [2] sets the WebApplicationContext ClassLoader to the exact same ClassLoader - which i thought would have provided javax.servlet.* classes. this may not be the best list for this question (should i rather ask on jetty or triplesec user lists ?), anyway thanks for any input. Import-Package: org.osgi.service.http,javax.servlet, javax.servlet.http,org.osgi.framework,net.joss.utils Bundle-Classpath: ., org.mortbay.jetty-5.1.4.jar, commons-logging-1.0.4.jar, servlet-api-2.4.jar, xerces-2.4.0.jar, xmlParserAPIs-2.6.2.jar, xml-apis-2.0.2.jar, jsp-api-2.0.jar, jasper-compiler-5.5.9.jar, jasper-runtime-5.5.9.jar, commons-el-1.0.jar, ant-1.6.2.jar class JettyWrapper { public void createApplication(final String appName, final File app, final Bundle fromBundle) { Thread thread = new Thread() { public void run() { try { ClassLoader loader = new DelegatingClassLoader( fromBundle, this.getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(loader); [1] String location = app.getAbsolutePath(); WebApplicationContext context = jetty.addWebApplication(/ + appName, location); context.setClassLoader(loader); [2] ... context.start(); } catch (Exception e) { LOG.error(Unable to start ' + appName + ' context, e); } } }; thread.start(); } } -- gd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jasper] compiling jsp in osgi context
oh. right, my mistake! gonna ask there. thanks! -- gd Martin Cooper wrote: I'm not sure I understand what the relationship is between what you're doing and Jakarta Commons, if there is one. Note that Jasper is part of the Tomcat project, so I would suggest asking over there. -- Martin Cooper - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]