There is no available project classpath to apply a semantic analysis

78 views
Skip to first unread message

Alroy D'souza

unread,
Apr 11, 2016, 6:32:29 AM4/11/16
to walkmod
hi, 

I am trying to run the walkmod-dead-code-cleaner-plugin plugin from the commend line. it shows me the following error.

 INFO [main] - ** STARTING TRANSFORMATIONS CHAINS **
--------------------------------------------------------------------------------
 INFO [main] - TRANSFORMATION CHAIN FAILS

--------------------------------------------------------------------------------
 INFO [main] - Total time: 0.059 seconds
 INFO [main] - Finished at: Mon, 11 Apr 2016 15:56:10
 INFO [main] - Final memory: 114 M/ 123 M
--------------------------------------------------------------------------------
 INFO [main] - Please, see the walkmod log file for details
ERROR [main] - TRANSFORMATION CHAIN (default) FAILS
An exeception has been produced during the null transformation - org.walkmod.util.location.LocationImpl@25084a1e
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.walkmod.walkers.AbstractWalker.walk(AbstractWalker.java:261)
        at org.walkmod.walkers.AbstractWalker.execute(AbstractWalker.java:276)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.execute(DefaultJavaWalker.java:160)
        at org.walkmod.impl.DefaultChainWalkerInvocation.invoke(DefaultChainWalkerInvocation.java:41)
        at org.walkmod.impl.DefaultChainInvocation.invoke(DefaultChainInvocation.java:38)
        at org.walkmod.impl.DefaultChainAdapter.execute(DefaultChainAdapter.java:165)
        at org.walkmod.WalkModFacade.executeAllChains(WalkModFacade.java:911)
        at org.walkmod.WalkModFacade.apply(WalkModFacade.java:376)
        at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40)
        at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:171)
        at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:196)
Caused by: java.lang.reflect.InvocationTargetException
        ... 15 more
Caused by: There is no available project classpath to apply a semantic analysis - org.walkmod.util.location.LocationImpl@25084a1e
        at org.walkmod.javalang.walkers.DefaultJavaWalker.visit(DefaultJavaWalker.java:211)
        at org.walkmod.javalang.walkers.DefaultJavaWalker.accept(DefaultJavaWalker.java:86)
        ... 15 more



this is my walkmod.xml
<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD" "http://www.walkmod.com/dtd/walkmod-1.1.dtd">
<walkmod> 
<plugins> 
<plugin artifactId = "walkmod-dead-code-cleaner-plugin" groupId = "org.walkmod" version = "1.0.0" /> 
</plugins> 
<chain name = "default"> 
<reader path="src/"></reader> 
<transformation type = "walkmod:commons:unused-declarations-cleaner" /> 
<writer path="output"></writer>
</chain> 
</walkmod>


Please let me know what am I doing wrong. 

Thanks

Regards,
Alroy

walkmod

unread,
Apr 11, 2016, 6:40:18 AM4/11/16
to walkmod
How do you build your project? Using ant?

In such case, you need to add the rawclasspath plugin (https://github.com/walkmod/walkmod-rawclasspath-plugin) in order to make walkmod discover your project .class files and your dependencies (jar files).

I hope it helps.

Alroy D'souza

unread,
Apr 11, 2016, 6:51:30 AM4/11/16
to walkmod
Okay I am trying to create my own plugin to delete unused variable. I came across the 2 plugins dead code cleaner and sonar:RemoverUselessVariables. I got those source files from git and tried to run it, but both gave me above mentioned error. upon deleting @RequiresSemanticAnalysis annotation it deletes all the variables even if its used in code. 

Can you please direct where am I doing wrong. Guide me.

Thanks

 

walkmod

unread,
Apr 11, 2016, 7:12:58 AM4/11/16
to walkmod
Hi,

Yo don't need to create your own plugin since, this is a problem solved by dead code cleaner.
The problem is that walkmod needs your classpath and the way to configure it is using the plugin I mentioned, which is explained in the Github webpage: https://github.com/walkmod/walkmod-rawclasspath-plugin

Raquel

Alroy D'souza

unread,
Apr 11, 2016, 7:19:48 AM4/11/16
to walkmod
I know I don't have to create my own but my project mentor is insisting me to do so. That's the reason for my this project. I specified the classpath but I have got one more error 
Caused by: org.walkmod.javalang.compiler.types.TypeNotFoundException: Error resolving the class for Sample

walkmod

unread,
Apr 11, 2016, 8:38:56 AM4/11/16
to walkmod
Hi,

Great. 

Have you added the folder that contains the .class of your project (e.g bin, target..)? Because the problem is that walkmod is not finding the Sample.class file.

Alroy D'souza

unread,
Apr 11, 2016, 9:15:45 AM4/11/16
to walkmod
hey,

I have added the .class path, but it showing me some NullPointer Exception.

If you don't mind can you just show me how to write this tags with my file Sample.java 


<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD"  "http://www.walkmod.com/dtd/walkmod-1.1.dtd" >
<walkmod
>
  ...
  <conf-providers>
    <conf-provider type="rawclasspath">
       <param name="classpath">bin;lib/guava.jar;lib/log4j.jar</param>
    </conf-provider>
  </conf-providers>
  ...
</walkmod>

walkmod

unread,
Apr 11, 2016, 4:44:11 PM4/11/16
to walkmod
Acording your walkmod.xml:

<!DOCTYPE walkmod PUBLIC "-//WALKMOD//DTD" "http://www.walkmod.com/dtd/walkmod-1.1.dtd">
<walkmod> 
<plugins> 
<plugin artifactId = "walkmod-dead-code-cleaner-plugin" groupId = "org.walkmod" version = "1.0.0" /> 
</plugins>
<conf-providers>
    <conf-provider type="rawclasspath">
       <param name="classpath"><!--here your classpath--></param>
    </conf-provider
  </conf-providers> 
<chain name = "default"> 
<reader path="src/"></reader> 
<transformation type = "walkmod:commons:unused-declarations-cleaner" /> 
<writer path="output"></writer>
</chain> 
</walkmod>

Alroy D'souza

unread,
Apr 12, 2016, 12:08:07 AM4/12/16
to walkmod
Hi

That worked like a charm.

Thanks for your help and all the best for future work.
I will surly write you in future with more queries and information.

Thanks

Regards
Alroy D'souza

Reply all
Reply to author
Forward
0 new messages