You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Gopalakrishnan (JIRA)" <ji...@apache.org> on 2005/08/11 10:48:37 UTC

[jira] Commented: (AXIS2-137) ArchiveReader.creatModuleArchivefromResource(): handling of module archive has problems.

    [ http://issues.apache.org/jira/browse/AXIS2-137?page=comments#action_12318460 ] 

Gopalakrishnan commented on AXIS2-137:
--------------------------------------

Thanks Deepal. That fixes problem 2. What about 1 and 3? Is that not an issue?

> ArchiveReader.creatModuleArchivefromResource(): handling of module archive has problems.
> ----------------------------------------------------------------------------------------
>
>          Key: AXIS2-137
>          URL: http://issues.apache.org/jira/browse/AXIS2-137
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug
>   Components: deployment
>     Versions: 0.9
>     Reporter: Gopalakrishnan
>     Assignee: Deepal Jayasinghe
>      Fix For: 0.91

>
> There 3 problems in this:
> 1. 
> org.apache.axis2.deployment.repository.util.ArchiveReader.creatModuleArchivefromResource() has this piece of code:
> if(DeploymentEngine.axis2repository == null ){
>                 String userHome = System.getProperty("user.home");
>                 File userHomedir = new File(userHome);
>                 File repository = new File(userHomedir, ".axis2home");
> 184:       if (!repository.exists()) {  ***** 
>                     repository.mkdirs();                
>                     modules = new File(repository, "modules");
>                     modules.mkdirs();
>                 }
> } else {
>         modules = new File(DeploymentEngine.axis2repository, "modules");
>         if (!modules.exists()) {
>           modules = new File(DeploymentEngine.axis2repository, "modules");
>           modules.mkdirs();
>         }
>       }
>       String modulearchiveName = moduleName + ".mar";
> 197:   modulearchiveFile = new File(modules, modulearchiveName);
> So when the repository directory exsists(line 184), the module variable will not be initialized and at Line 197, modules will still be null. So the moduleArchiveFile will point to a file in the users  'current directory' and the .mar file will get extracted in the user's current dir, instead of the userhome/.axis2home/modules dir.
> the code should have been:
>       if (DeploymentEngine.axis2repository == null) {
>         modules = new File(System.getProperty("user.home"), ".axis2home/modules");
>       } else {
>         modules = new File(DeploymentEngine.axis2repository, "modules");
>       }
>       if (!modules.exists())
>         modules.mkdirs();
>       
>       String modulearchiveName = moduleName + ".mar";
>       modulearchiveFile = new File(modules, modulearchiveName);
>  
> 2. 
> Another problem is from 198 - 202
>             if (modulearchiveFile.exists()) {
>                 return modulearchiveFile;
>             } else {
>                 modulearchiveFile.createNewFile();
>             }
> If the module file exsists it returns it otherwise creates a new one. But we are creating the new file too early, what if we are not able to load the module file as resource. This will endup in creating a 0 byte file file in the repository and from next time onwards axis will try to load this 0 byte file and will give a module.xml not found error. We should do  modulearchiveFile.createNewFile(); only after 
>            if(in == null){
>                 throw new DeploymentException( moduleName + " module is not found");
>             }
> succeeds.
> 3. Why are we caching the module archive in the repository dir? This will create problems if I update the .mar file in my distribution(.jar file or .war file). Axis engine will find the old .mar file in the repository and use it, instead of loading the new .mar from the distribution .jar or .war. 
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Commented: (AXIS2-137) ArchiveReader.creatModuleArchivefromResource(): handling of module archive has problems.

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi Gopalakrishnan  ;

The latest code for suggestion 1 will be look like follows;

  if (!repository.exists()) {
                    repository.mkdirs();
                    modules = new File(repository, "modules");
                    modules.mkdirs();
                } else {
                    modules = new File(repository, "modules");
                    if(!modules.exists()){
                        modules.mkdirs();
                    }
                }

According to this modules is always not null , if you can still see an error 
here please explain me , I am really appreciate your suggestion .


Thanks,
 Deepal
................................................................
~Future is Open~



----- Original Message ----- 
From: "Gopalakrishnan (JIRA)" <ji...@apache.org>
To: <ax...@ws.apache.org>
Sent: Thursday, August 11, 2005 2:48 PM
Subject: [jira] Commented: (AXIS2-137) 
ArchiveReader.creatModuleArchivefromResource(): handling of module archive 
has problems.


>    [ 
> http://issues.apache.org/jira/browse/AXIS2-137?page=comments#action_12318460 ]
>
> Gopalakrishnan commented on AXIS2-137:
> --------------------------------------
>
> Thanks Deepal. That fixes problem 2. What about 1 and 3? Is that not an 
> issue?
>
>> ArchiveReader.creatModuleArchivefromResource(): handling of module 
>> archive has problems.
>> ----------------------------------------------------------------------------------------
>>
>>          Key: AXIS2-137
>>          URL: http://issues.apache.org/jira/browse/AXIS2-137
>>      Project: Apache Axis 2.0 (Axis2)
>>         Type: Bug
>>   Components: deployment
>>     Versions: 0.9
>>     Reporter: Gopalakrishnan
>>     Assignee: Deepal Jayasinghe
>>      Fix For: 0.91
>
>>
>> There 3 problems in this:
>> 1.
>> org.apache.axis2.deployment.repository.util.ArchiveReader.creatModuleArchivefromResource() 
>> has this piece of code:
>> if(DeploymentEngine.axis2repository == null ){
>>                 String userHome = System.getProperty("user.home");
>>                 File userHomedir = new File(userHome);
>>                 File repository = new File(userHomedir, ".axis2home");
>> 184:       if (!repository.exists()) {  *****
>>                     repository.mkdirs();
>>                     modules = new File(repository, "modules");
>>                     modules.mkdirs();
>>                 }
>> } else {
>>         modules = new File(DeploymentEngine.axis2repository, "modules");
>>         if (!modules.exists()) {
>>           modules = new File(DeploymentEngine.axis2repository, 
>> "modules");
>>           modules.mkdirs();
>>         }
>>       }
>>       String modulearchiveName = moduleName + ".mar";
>> 197:   modulearchiveFile = new File(modules, modulearchiveName);
>> So when the repository directory exsists(line 184), the module variable 
>> will not be initialized and at Line 197, modules will still be null. So 
>> the moduleArchiveFile will point to a file in the users  'current 
>> directory' and the .mar file will get extracted in the user's current 
>> dir, instead of the userhome/.axis2home/modules dir.
>> the code should have been:
>>       if (DeploymentEngine.axis2repository == null) {
>>         modules = new File(System.getProperty("user.home"), 
>> ".axis2home/modules");
>>       } else {
>>         modules = new File(DeploymentEngine.axis2repository, "modules");
>>       }
>>       if (!modules.exists())
>>         modules.mkdirs();
>>
>>       String modulearchiveName = moduleName + ".mar";
>>       modulearchiveFile = new File(modules, modulearchiveName);
>>
>> 2.
>> Another problem is from 198 - 202
>>             if (modulearchiveFile.exists()) {
>>                 return modulearchiveFile;
>>             } else {
>>                 modulearchiveFile.createNewFile();
>>             }
>> If the module file exsists it returns it otherwise creates a new one. But 
>> we are creating the new file too early, what if we are not able to load 
>> the module file as resource. This will endup in creating a 0 byte file 
>> file in the repository and from next time onwards axis will try to load 
>> this 0 byte file and will give a module.xml not found error. We should do 
>> modulearchiveFile.createNewFile(); only after
>>            if(in == null){
>>                 throw new DeploymentException( moduleName + " module is 
>> not found");
>>             }
>> succeeds.
>> 3. Why are we caching the module archive in the repository dir? This will 
>> create problems if I update the .mar file in my distribution(.jar file or 
>> .war file). Axis engine will find the old .mar file in the repository and 
>> use it, instead of loading the new .mar from the distribution .jar or 
>> .war.
>>
>
> -- 
> This message is automatically generated by JIRA.
> -
> If you think it was sent incorrectly contact one of the administrators:
>   http://issues.apache.org/jira/secure/Administrators.jspa
> -
> For more information on JIRA, see:
>   http://www.atlassian.com/software/jira
>
>
>