You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-users@mina.apache.org by Manish Marathe <mm...@egnyte.com> on 2010/12/03 02:59:11 UTC
Use custom beans in the ftpserver configuration file
Hello,
How can I add custom beans that I can reference from user-manager or any
other element?
Current error I am getting is:
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a:
Invalid content was found starting with element 'bean'. One of
'{"http://mina.apache.org/ftpserver/spring/v1":ftplets,
"http://mina.apache.org/ftpserver/spring/v1":file-user-manager,
"http://mina.apache.org/ftpserver/spring/v1":db-user-manager,
"http://mina.apache.org/ftpserver/spring/v1":user-manager,
"http://mina.apache.org/ftpserver/spring/v1":native-filesystem,
"http://mina.apache.org/ftpserver/spring/v1":filesystem,
"http://mina.apache.org/ftpserver/spring/v1":commands,
"http://mina.apache.org/ftpserver/spring/v1":messages}' is expected.
which I can understand that according to the namespace and xml-schema,
SAXParser is not allowing me to have the <beans:bean> tag directly under
<Server> but I do include xmlns:beans if you see before.
So, the above error is thrown if I have something like:
<server
xmlns="http://mina.apache.org/ftpserver/spring/v1"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://mina.apache.org/ftpserver/spring/v1
http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
"
id="myServer"
max-logins="200"
anon-enabled="false"
max-anon-logins="0"
max-login-failures="3"
login-failure-delay="500"
>
<beans:bean class="mypackage.MyClass" id="myClass1">
</beans:bean>
<user-manager>
<beans:bean class="mypackage.MyUserManager">
<beans:property name="maxLogin" value="20" />
<beans:property name="maxLoginPerIp" value="15" />
<beans:property name="directoryService" ref="myClass1" />
</beans:bean>
</user-manager>
</Server>
Re: Use custom beans in the ftpserver configuration file
Posted by Manish Marathe <mm...@egnyte.com>.
On 12/02/2010 05:59 PM, Manish Marathe wrote:
> Hello,
>
> How can I add custom beans that I can reference from user-manager or
> any other element?
Any help on how to reference other POJO's as beans from the
configuration file will be highly useful.
>
> Current error I am getting is:
>
> Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a:
> Invalid content was found starting with element 'bean'. One of
> '{"http://mina.apache.org/ftpserver/spring/v1":ftplets,
> "http://mina.apache.org/ftpserver/spring/v1":file-user-manager,
> "http://mina.apache.org/ftpserver/spring/v1":db-user-manager,
> "http://mina.apache.org/ftpserver/spring/v1":user-manager,
> "http://mina.apache.org/ftpserver/spring/v1":native-filesystem,
> "http://mina.apache.org/ftpserver/spring/v1":filesystem,
> "http://mina.apache.org/ftpserver/spring/v1":commands,
> "http://mina.apache.org/ftpserver/spring/v1":messages}' is expected.
>
> which I can understand that according to the namespace and xml-schema,
> SAXParser is not allowing me to have the <beans:bean> tag directly
> under <Server> but I do include xmlns:beans if you see before.
>
> So, the above error is thrown if I have something like:
>
> <server
> xmlns="http://mina.apache.org/ftpserver/spring/v1"
> xmlns:beans="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://mina.apache.org/ftpserver/spring/v1
> http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
> "
> id="myServer"
> max-logins="200"
> anon-enabled="false"
> max-anon-logins="0"
> max-login-failures="3"
> login-failure-delay="500"
> >
>
> <beans:bean class="mypackage.MyClass" id="myClass1">
> </beans:bean>
>
> <user-manager>
> <beans:bean class="mypackage.MyUserManager">
> <beans:property name="maxLogin" value="20" />
> <beans:property name="maxLoginPerIp" value="15" />
> <beans:property name="directoryService" ref="myClass1" />
> </beans:bean>
> </user-manager>
>
> </Server>
>
Re: Use custom beans in the ftpserver configuration file
Posted by Manish Marathe <mm...@egnyte.com>.
Niklas,
Thanks a lot for the response. This was a dumb question on my part. I
knew it was my fault in using the configuration file as the namespaces
were not right.
Anyway, I used beans as my default namespace and used "ftpserver"
namespace for our ftpserver config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:ftpserver="http://mina.apache.org/ftpserver/spring/v1"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://mina.apache.org/ftpserver/spring/v1
http://mina.apache.org/ftpserver/ftpserver-1.0.xsd">
<ftpserver:server
id="ftpServer"
max-logins="200"
anon-enabled="false"
max-anon-logins="0"
max-login-failures="3"
login-failure-delay="500"
>
<ftpserver:listeners>
<ftpserver:nio-listener name="default" port="2222" implicit-ssl="false"
idle-timeout="54000">
<ftpserver:data-connection idle-timeout="54000">
<active enabled="true" local-address="172.16.0.130" local-port="2323"
ip-check="true" />
<passive ports="123-125" address="172.16.0.130"
external-address="172.16.0.130" />
</ftpserver:data-connection>
</ftpserver:nio-listener>
</ftpserver:listeners>
<ftpserver:user-manager>
<beans:bean id="userManager" class="dev.MyUserManager">
<beans:property name="maxLogin" value="20" />
<beans:property name="maxLoginPerIp" value="15" />
<beans:property name="directoryService" ref="cachingDirectoryService" />
</beans:bean>
</ftpserver:user-manager>
<!-- The file system -->
<ftpserver:native-filesystem case-insensitive="false" create-home="true" />
</ftpserver:server>
<bean class="dev.CachingDirectoryService" id="cachingDirectoryService">
<property name="servers" value="localhost:11211;localhost:11222" />
<property name="directoryService" ref="ldapDirectoryService" />
</bean>
<bean class="dev.LdapDirectoryService" id="ldapDirectoryService">
<property name="servers" value="localhost:389;localhost:1489"/>
</bean>
</beans>
Thanks a lot for your answer.
On 12/09/2010 01:18 AM, Niklas Gustavsson wrote:
> Sorry for the late reply.
>
Not at all.
> On Fri, Dec 3, 2010 at 2:59 AM, Manish Marathe<mm...@egnyte.com> wrote:
>
>> How can I add custom beans that I can reference from user-manager or any
>> other element?
>>
> If you need to do this, you can not use<server> as the outer element,
> instead you need to do something like:
> <beans:beans
> xmlns="http://mina.apache.org/ftpserver/spring/v1"
> xmlns:beans="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://mina.apache.org/ftpserver/spring/v1
> http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
> "
> >
> <beans:bean class="mypackage.MyClass" id="myClass1" />
>
> <server
> id="myServer"
> max-logins="200"
> anon-enabled="false"
> max-anon-logins="0"
> max-login-failures="3"
> login-failure-delay="500"
> >
>
> <user-manager>
> <beans:bean class="mypackage.MyUserManager">
> <beans:property name="maxLogin" value="20" />
> <beans:property name="maxLoginPerIp" value="15" />
> <beans:property name="directoryService" ref="myClass1" />
> </beans:bean>
> </user-manager>
>
> </server>
> </beans:beans>
>
> /niklas
>
>
Re: Use custom beans in the ftpserver configuration file
Posted by Niklas Gustavsson <ni...@protocol7.com>.
Sorry for the late reply.
On Fri, Dec 3, 2010 at 2:59 AM, Manish Marathe <mm...@egnyte.com> wrote:
> How can I add custom beans that I can reference from user-manager or any
> other element?
If you need to do this, you can not use <server> as the outer element,
instead you need to do something like:
<beans:beans
xmlns="http://mina.apache.org/ftpserver/spring/v1"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://mina.apache.org/ftpserver/spring/v1
http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
"
>
<beans:bean class="mypackage.MyClass" id="myClass1" />
<server
id="myServer"
max-logins="200"
anon-enabled="false"
max-anon-logins="0"
max-login-failures="3"
login-failure-delay="500"
>
<user-manager>
<beans:bean class="mypackage.MyUserManager">
<beans:property name="maxLogin" value="20" />
<beans:property name="maxLoginPerIp" value="15" />
<beans:property name="directoryService" ref="myClass1" />
</beans:bean>
</user-manager>
</server>
</beans:beans>
/niklas