6 Replies Latest reply on Jan 21, 2009 5:23 PM by corrado.campisano

    file-sender: how to specify a network folder?

    corrado.campisano

      Hi,

       

      I am having troubles in using a network folder on windows.

      (I am using servicemix-web.3.3 deployed into tomcat)

       

       

      I'd like to use a mapped drive like:

      K:\myfolder

      or the full path:


      server\mypath\myfolder

       

       

      what's the exact syntax for that?

       

      Notice I externalized this configuration in an external property file, so my bean.xml looks like that:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <beans xmlns:file="http://servicemix.apache.org/file/1.0"

             xmlns:sme="http://servicemix.eu/tools/sMixCcbFrt/1.0"

             xmlns="http://www.springframework.org/schema/beans"

             xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance"

             xsi:schemaLocation="http://servicemix.apache.org/file/1.0 http://servicemix.apache.org/schema/servicemix-file-3.2.2.xsd

             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

       

          <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

            <property name="locations">        

              <value>file:${catalina.home}/../apps/sMixCcbFrt/config/sMixCcbFrt.properties</value>

            </property>

          </bean>

       

          <file:sender service="sme:fileWriter"

              endpoint="endpoint"

              directory="${sMixCcbFrt.outPath}">

       

              <property name="marshaler">

                  <bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" />

              </property>

          </file:sender>

      </beans>

       

       

       

      Notice the variable ${sMixCcbFrt.outPath}

      is set in the external configuration file like this (here's several attempts I made):

       

      1)

      sMixCcbFrt.outPath = K:
      test

       

      this raises a javax.jbi.management.DeploymentException upon deployment: 'The directory property must be a directory but was K:\test'

      at org.apache.servicemix.file.FileSenderEndpoint.validate(FileSenderEndpoint.java:64)

       

       

       

      2)

      sMixCcbFrt.outPath =
      sgromds01
      psd$
      test

      this is ok on deplyoment, but at runtime a folder is created in c:\sgromds01\psd$\testand files are placed there instead of in the network folder.

       

       

       

      3)

      sMixCcbFrt.outPath =file:
      \sgromds01
      psd$
      test

      again, this is ok on deplyoment, but at runtime a folder is created in c:\sgromds01\psd$\testand files are placed there instead of in the network folder.

       

       

      Do you have any suggestions?

       

       

      Best regards,

      Corrado Campisano

       

       

        • 1. Re: file-sender: how to specify a network folder?
          corrado.campisano

          Here's a few details:

           

          using this:

          sMixCcbFrt.outPath = file://

          sgromds01
          psd$
          test

          raises this error:

          <component-task-result>

          <component-name>servicemix-file</component-name>

          ...

          <loc-message>The directory property must be a directory but was:
          sgromds01\psd$\test</loc-message>

          <stack-trace><![CDATA[javax.jbi.management.DeploymentException: The directory property must be a directory but was: file://sgromds01/psd$/test

          at org.apache.servicemix.file.FileSenderEndpoint.validate(FileSenderEndpoint.java:64)

           

           

          Taking a look at the sources here:

          https://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-file/tags/servicemix-file-2008.01/src/main/java/org/apache/servicemix/file/FileSenderEndpoint.java

           

          I can see the method does:

              public void validate() throws DeploymentException {

                  super.validate();

                  if (directory == null) {

                      throw new DeploymentException("You must specify the directory property");

                  }

                  if (isAutoCreateDirectory()) {

                      directory.mkdirs();

                  }

          if (!directory.isDirectory()) {

          •            throw new DeploymentException("The directory property must be a directory but was: " + directory);*

          •        }*

              }

           

          where the property 'directory' is a java.io.File:

          import java.io.*;

          ...

          private File directory;

           

           

           

          The strangest thing ever is that testing this folder on a standalone Java class it seems to be seen as a folder!

           

          Take a look at the shot attached...

          ...pretty strange, isn't' it?

           

           

          Have a nice weekend

          Corrado

           

          Edited by: corrado on Jan 9, 2009 7:41 PM

          • 2. Re: file-sender: how to specify a network folder?
            davestanley

            If you map the drive to K: then file:///k:/... should work.

             

            Not sure on your last question. Maybe the directory is a symlink?

             

            Hope this helps

            /Dave

            • 3. Re: file-sender: how to specify a network folder?
              corrado.campisano

              Hi,

               

              thanks for your suggestion, I'll try again by end of next week and update the thread.

               

               

              By the way (referring to my second post), maybe this behavior is due to servicemix running inside tomcat which runs as "SYSTEM" user on my machine and this user has no rights on the network share?

               

              I tried to add my computer (by its name only, not as name\SYSTEM - which was not possible) as granted user on the network folder, but this didn't work.

               

               

              Regards,

              Corrado

              • 4. Re: file-sender: how to specify a network folder?
                corrado.campisano

                Hi,

                 

                I tried with

                 

                file:///K:
                test

                 

                as suggested, but it failed.

                 

                 

                 

                 

                I'm attaching servicemix logs and a shot from eclipse showing the folder being accessible from java (run with my account, while servicemix is run embedded in tomcat, executed under SYSTEM account).

                 

                 

                 

                 

                The error message is still the same:

                The directory property must be a directory but was: K:\test

                 

                 

                 

                 

                Anyone having comments or suggestions?

                 

                Regards,

                Corrado Campisano

                 

                Edited by: corrado on Jan 19, 2009 5:06 PM

                 

                Edited by: corrado on Jan 19, 2009 5:07 PM

                • 5. Re: file-sender: how to specify a network folder?
                  corrado.campisano

                  Hi all,

                   

                  I confirm it's just a matter of permissions.

                   

                  Running Tomcat by double clicking tomcat5.exe in the bin folder,

                  makes tomcat start as normal user.

                   

                  Once this user has rights on the remote folder,

                  deploying the SA works fine with network folder:

                   

                  file:///K:/test

                   

                   

                  Unfortunately, it seems tomcat cannot be run as a service with normal user credentials - check attachment...

                  • 6. Re: file-sender: how to specify a network folder?
                    corrado.campisano

                    It was just a permission issue, ok...

                     

                     

                    Anyway, running ServiceMix or its container with certain credentials,

                    in order to workaround this problem, is not a good choice!

                     

                     

                    So, IMHO, providing these 2 new BC:

                    - a Samba BC, for windows systems;

                    - a Fish (file ssh) BC, for *nix systems;

                     

                    in addition to these existing ones:

                    - file BC, for local filesystems;

                    - ftp BC, for remote filesystems;

                     

                    could provide serviceMix with larger support for file-based integration.

                     

                     

                    Best regards & enjoy ServiceMix!

                    Corrado Campisano

                     

                    Edited by: corrado on Jan 21, 2009 11:23 PM