You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by Guillaume Nodet <gn...@gmail.com> on 2008/07/28 09:20:06 UTC

Re: svn commit: r680252 - /servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java

Not sure if this patch is the right one.  What if someone wants to
deploy a war or another kind of extensions.  These could already be
OSGi bundles, so I don't think we should ignore them for the default
deployer.

On Mon, Jul 28, 2008 at 6:16 AM,  <ff...@apache.org> wrote:
> Author: ffang
> Date: Sun Jul 27 21:16:35 2008
> New Revision: 680252
>
> URL: http://svn.apache.org/viewvc?rev=680252&view=rev
> Log:
> [SMX4-76]error in opening zip file when start smx4
>
> Modified:
>    servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>
> Modified: servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
> URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java?rev=680252&r1=680251&r2=680252&view=diff
> ==============================================================================
> --- servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java (original)
> +++ servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java Sun Jul 27 21:16:35 2008
> @@ -342,6 +342,10 @@
>         JarFile jar = null;
>         try {
>             // Handle OSGi bundles with the default deployer
> +            if (!file.getName().endsWith("zip") && !file.getName().endsWith("jar")) {
> +                // that's file type which is not supported as bundle
> +                return null;
> +            }
>             jar = new JarFile(file);
>             Manifest m = jar.getManifest();
>             if (m.getMainAttributes().getValue(new Attributes.Name("Bundle-SymbolicName")) != null &&
>
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: svn commit: r680252 - /servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java

Posted by Guillaume Nodet <gn...@gmail.com>.
On Mon, Jul 28, 2008 at 9:32 AM, Freeman Fang <fr...@gmail.com> wrote:
> Hi Guillaume,
>
> How about we just exclude file with extensor like "txt" "xml" "properties"
> to avoid the exception like
> java.util.zip.ZipException: error in opening zip file?

Yeah, I think it would be safer and would still avoid those exceptions
in the log.

> Or leave the exception info alone in the log since it's DEBUG level logs?
>
> Regards
> Freeman
>
> Guillaume Nodet wrote:
>>
>> Not sure if this patch is the right one.  What if someone wants to
>> deploy a war or another kind of extensions.  These could already be
>> OSGi bundles, so I don't think we should ignore them for the default
>> deployer.
>>
>> On Mon, Jul 28, 2008 at 6:16 AM,  <ff...@apache.org> wrote:
>>
>>>
>>> Author: ffang
>>> Date: Sun Jul 27 21:16:35 2008
>>> New Revision: 680252
>>>
>>> URL: http://svn.apache.org/viewvc?rev=680252&view=rev
>>> Log:
>>> [SMX4-76]error in opening zip file when start smx4
>>>
>>> Modified:
>>>
>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>>>
>>> Modified:
>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>>> URL:
>>> http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java?rev=680252&r1=680251&r2=680252&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>>> (original)
>>> +++
>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>>> Sun Jul 27 21:16:35 2008
>>> @@ -342,6 +342,10 @@
>>>        JarFile jar = null;
>>>        try {
>>>            // Handle OSGi bundles with the default deployer
>>> +            if (!file.getName().endsWith("zip") &&
>>> !file.getName().endsWith("jar")) {
>>> +                // that's file type which is not supported as bundle
>>> +                return null;
>>> +            }
>>>            jar = new JarFile(file);
>>>            Manifest m = jar.getManifest();
>>>            if (m.getMainAttributes().getValue(new
>>> Attributes.Name("Bundle-SymbolicName")) != null &&
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: svn commit: r680252 - /servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java

Posted by Guillaume Nodet <gn...@gmail.com>.
We already catch this exception and don't load the file, but the
exception is displayed in the log.
Actually, we might want to keep it, because deployers (such as the
spring xml files deployer) handle non-binary files and if they are not
registered, we may want to inform the user that the deployment of the
artifact failed.  One way to solve the problem would be to find a way
to configure the pax-logging system with the configuration in
etc/org.ops4j.pax.logging.cfg even before the file monitor is started
(using a system property maybe).  Currently, the file deployer is used
to load the configuration, give it to the Config Admin service, which
is then given to the logging system, but this is a bit too late and we
should find a way to initiatlize the log system with the right
configuration.

On Mon, Jul 28, 2008 at 10:06 AM, Willem Jiang <wi...@gmail.com> wrote:
> There could be other extensor beyond "txt", "xml"......
> How about we catch this exception and do not load the file?
>
> Willem
>
> Freeman Fang wrote:
>>
>> Hi Guillaume,
>>
>> How about we just exclude file with extensor like "txt" "xml" "properties"
>> to avoid the exception like
>> java.util.zip.ZipException: error in opening zip file?
>>
>> Or leave the exception info alone in the log since it's DEBUG level logs?
>>
>> Regards
>> Freeman
>>
>> Guillaume Nodet wrote:
>>>
>>> Not sure if this patch is the right one.  What if someone wants to
>>> deploy a war or another kind of extensions.  These could already be
>>> OSGi bundles, so I don't think we should ignore them for the default
>>> deployer.
>>>
>>> On Mon, Jul 28, 2008 at 6:16 AM,  <ff...@apache.org> wrote:
>>>
>>>>
>>>> Author: ffang
>>>> Date: Sun Jul 27 21:16:35 2008
>>>> New Revision: 680252
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=680252&view=rev
>>>> Log:
>>>> [SMX4-76]error in opening zip file when start smx4
>>>>
>>>> Modified:
>>>>
>>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>>>>
>>>> Modified:
>>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java?rev=680252&r1=680251&r2=680252&view=diff
>>>>
>>>> ==============================================================================
>>>> ---
>>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>>>> (original)
>>>> +++
>>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>>>> Sun Jul 27 21:16:35 2008
>>>> @@ -342,6 +342,10 @@
>>>>        JarFile jar = null;
>>>>        try {
>>>>            // Handle OSGi bundles with the default deployer
>>>> +            if (!file.getName().endsWith("zip") &&
>>>> !file.getName().endsWith("jar")) {
>>>> +                // that's file type which is not supported as bundle
>>>> +                return null;
>>>> +            }
>>>>            jar = new JarFile(file);
>>>>            Manifest m = jar.getManifest();
>>>>            if (m.getMainAttributes().getValue(new
>>>> Attributes.Name("Bundle-SymbolicName")) != null &&
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: svn commit: r680252 - /servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java

Posted by Freeman Fang <fr...@gmail.com>.
Hi Willem,

Is there any way we can determain a file is text or binnary?
That's may be the good solution.

Regards
Freeman

Willem Jiang wrote:
> There could be other extensor beyond "txt", "xml"......
> How about we catch this exception and do not load the file?
>
> Willem
>
> Freeman Fang wrote:
>> Hi Guillaume,
>>
>> How about we just exclude file with extensor like "txt" "xml" 
>> "properties" to avoid the exception like
>> java.util.zip.ZipException: error in opening zip file?
>>
>> Or leave the exception info alone in the log since it's DEBUG level 
>> logs?
>>
>> Regards
>> Freeman
>>
>> Guillaume Nodet wrote:
>>> Not sure if this patch is the right one.  What if someone wants to
>>> deploy a war or another kind of extensions.  These could already be
>>> OSGi bundles, so I don't think we should ignore them for the default
>>> deployer.
>>>
>>> On Mon, Jul 28, 2008 at 6:16 AM,  <ff...@apache.org> wrote:
>>>  
>>>> Author: ffang
>>>> Date: Sun Jul 27 21:16:35 2008
>>>> New Revision: 680252
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=680252&view=rev
>>>> Log:
>>>> [SMX4-76]error in opening zip file when start smx4
>>>>
>>>> Modified:
>>>>    
>>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java 
>>>>
>>>>
>>>> Modified: 
>>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java 
>>>>
>>>> URL: 
>>>> http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java?rev=680252&r1=680251&r2=680252&view=diff 
>>>>
>>>> ============================================================================== 
>>>>
>>>> --- 
>>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java 
>>>> (original)
>>>> +++ 
>>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java 
>>>> Sun Jul 27 21:16:35 2008
>>>> @@ -342,6 +342,10 @@
>>>>         JarFile jar = null;
>>>>         try {
>>>>             // Handle OSGi bundles with the default deployer
>>>> +            if (!file.getName().endsWith("zip") && 
>>>> !file.getName().endsWith("jar")) {
>>>> +                // that's file type which is not supported as bundle
>>>> +                return null;
>>>> +            }
>>>>             jar = new JarFile(file);
>>>>             Manifest m = jar.getManifest();
>>>>             if (m.getMainAttributes().getValue(new 
>>>> Attributes.Name("Bundle-SymbolicName")) != null &&
>>>>
>>>>
>>>>
>>>>     
>>>
>>>
>>>
>>>   
>>
>>
>
>


Re: svn commit: r680252 - /servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java

Posted by Willem Jiang <wi...@gmail.com>.
There could be other extensor beyond "txt", "xml"......
How about we catch this exception and do not load the file?

Willem

Freeman Fang wrote:
> Hi Guillaume,
>
> How about we just exclude file with extensor like "txt" "xml" 
> "properties" to avoid the exception like
> java.util.zip.ZipException: error in opening zip file?
>
> Or leave the exception info alone in the log since it's DEBUG level logs?
>
> Regards
> Freeman
>
> Guillaume Nodet wrote:
>> Not sure if this patch is the right one.  What if someone wants to
>> deploy a war or another kind of extensions.  These could already be
>> OSGi bundles, so I don't think we should ignore them for the default
>> deployer.
>>
>> On Mon, Jul 28, 2008 at 6:16 AM,  <ff...@apache.org> wrote:
>>  
>>> Author: ffang
>>> Date: Sun Jul 27 21:16:35 2008
>>> New Revision: 680252
>>>
>>> URL: http://svn.apache.org/viewvc?rev=680252&view=rev
>>> Log:
>>> [SMX4-76]error in opening zip file when start smx4
>>>
>>> Modified:
>>>    
>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java 
>>>
>>>
>>> Modified: 
>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java 
>>>
>>> URL: 
>>> http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java?rev=680252&r1=680251&r2=680252&view=diff 
>>>
>>> ============================================================================== 
>>>
>>> --- 
>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java 
>>> (original)
>>> +++ 
>>> servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java 
>>> Sun Jul 27 21:16:35 2008
>>> @@ -342,6 +342,10 @@
>>>         JarFile jar = null;
>>>         try {
>>>             // Handle OSGi bundles with the default deployer
>>> +            if (!file.getName().endsWith("zip") && 
>>> !file.getName().endsWith("jar")) {
>>> +                // that's file type which is not supported as bundle
>>> +                return null;
>>> +            }
>>>             jar = new JarFile(file);
>>>             Manifest m = jar.getManifest();
>>>             if (m.getMainAttributes().getValue(new 
>>> Attributes.Name("Bundle-SymbolicName")) != null &&
>>>
>>>
>>>
>>>     
>>
>>
>>
>>   
>
>


Re: svn commit: r680252 - /servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java

Posted by Freeman Fang <fr...@gmail.com>.
Hi Guillaume,

How about we just exclude file with extensor like "txt" "xml" 
"properties" to avoid the exception like
java.util.zip.ZipException: error in opening zip file?

Or leave the exception info alone in the log since it's DEBUG level logs?

Regards
Freeman

Guillaume Nodet wrote:
> Not sure if this patch is the right one.  What if someone wants to
> deploy a war or another kind of extensions.  These could already be
> OSGi bundles, so I don't think we should ignore them for the default
> deployer.
>
> On Mon, Jul 28, 2008 at 6:16 AM,  <ff...@apache.org> wrote:
>   
>> Author: ffang
>> Date: Sun Jul 27 21:16:35 2008
>> New Revision: 680252
>>
>> URL: http://svn.apache.org/viewvc?rev=680252&view=rev
>> Log:
>> [SMX4-76]error in opening zip file when start smx4
>>
>> Modified:
>>    servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>>
>> Modified: servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java
>> URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java?rev=680252&r1=680251&r2=680252&view=diff
>> ==============================================================================
>> --- servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java (original)
>> +++ servicemix/smx4/kernel/trunk/filemonitor/src/main/java/org/apache/servicemix/kernel/filemonitor/FileMonitor.java Sun Jul 27 21:16:35 2008
>> @@ -342,6 +342,10 @@
>>         JarFile jar = null;
>>         try {
>>             // Handle OSGi bundles with the default deployer
>> +            if (!file.getName().endsWith("zip") && !file.getName().endsWith("jar")) {
>> +                // that's file type which is not supported as bundle
>> +                return null;
>> +            }
>>             jar = new JarFile(file);
>>             Manifest m = jar.getManifest();
>>             if (m.getMainAttributes().getValue(new Attributes.Name("Bundle-SymbolicName")) != null &&
>>
>>
>>
>>     
>
>
>
>