jcabi / jcabi-aspects

Collection of AspectJ Java Aspects to facilitate aspect-oriented programming patterns: logging, caching, validating, etc.
https://aspects.jcabi.com
Other
530 stars 150 forks source link

What's wrong with my project? Loggable doesn't work #142

Open dannybaby opened 9 years ago

dannybaby commented 9 years ago

I am using springmvc project. my pom.xml is below:

        <dependency>
            <groupId>com.jcabi</groupId>
            <artifactId>jcabi-aspects</artifactId>
            <version>0.21</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.8.3</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjtools</artifactId>
            <version>1.8.3</version>
        </dependency>

            <plugin>
                <groupId>com.jcabi</groupId>
                <artifactId>jcabi-maven-plugin</artifactId>
                <version>0.12</version>
                <configuration>
                <source>1.8</source>
                <target>1.8</target>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>ajc</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

after I user mvn clean package, the whole log is below:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building fileUpload 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ fileUpload ---
[INFO] Deleting /Users/Lily.L/Tujia/Workspace/fileUpload/target
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:copy (default) @ fileUpload ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ fileUpload ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ fileUpload ---
[INFO] Compiling 2 source files to /Users/Lily.L/Tujia/Workspace/fileUpload/target/classes
[INFO] 
[INFO] --- jcabi-maven-plugin:0.12:ajc (default) @ fileUpload ---
[INFO] jcabi-aspects 0.18/55a5c13 started new daemon thread jcabi-loggable for watching of @Loggable annotated methods
[INFO] Created temp dir /Users/Lily.L/Tujia/Workspace/fileUpload/target/jcabi-ajc
[INFO] jcabi-aspects 0.18/55a5c13 started new daemon thread jcabi-cacheable for automated cleaning of expired @Cacheable values

1 fail|abort, 1 error
[INFO] ajc result: 0 file(s) processed, 0 pointcut(s) woven, 0 error(s), 0 warning(s)
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ fileUpload ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/Lily.L/Tujia/Workspace/fileUpload/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ fileUpload ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ fileUpload ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ fileUpload ---
[INFO] Packaging webapp
[INFO] Assembling webapp [fileUpload] in [/Users/Lily.L/Tujia/Workspace/fileUpload/target/fileUpload-1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/Lily.L/Tujia/Workspace/fileUpload/src/main/webapp]
[INFO] Webapp assembled in [274 msecs]
[INFO] Building war: /Users/Lily.L/Tujia/Workspace/fileUpload/target/fileUpload-1.0-SNAPSHOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.138 s
[INFO] Finished at: 2015-02-27T15:11:14+08:00
[INFO] Final Memory: 25M/209M
[INFO] ------------------------------------------------------------------------

it seems nothing wrong, no error.

my java file using Loggable is: import com.jcabi.aspects.Loggable;

@Controller
@RequestMapping("/images")
public class FileController {

    /***************************************************
     * URL: /rest/controller/upload  
     * upload(): receives files
     * @param request : MultipartHttpServletRequest auto passed
     * @param response : HttpServletResponse auto passed
     * @return LinkedList<FileMeta> as json format
     ****************************************************/

    @Loggable(Loggable.INFO)
    @RequestMapping(value="/{author}/{subfoler}/upload/", method = RequestMethod.POST)
    public @ResponseBody LinkedList<FileMeta> upload(@PathVariable("author") String author, @PathVariable("subfoler") String subfoler, MultipartHttpServletRequest request, HttpServletResponse response)
    {
        File imagesPath = new File("/tmp/tujia/" + author + "/" + subfoler);
        if(!imagesPath.exists()){
            imagesPath.mkdirs();
        }

        Iterator<String> itr = request.getFileNames();

        MultipartFile mpf = null;
        while(itr.hasNext()){
            mpf = request.getFile(itr.next());
            try {
                FileCopyUtils.copy(mpf.getBytes(), new FileOutputStream(imagesPath.toString() + "/" + mpf.getOriginalFilename()));
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        LinkedList<FileMeta> files = new LinkedList<FileMeta>();
        try{

            String[] fileNames = imagesPath.list();
            for(int i = 0; i < fileNames.length; i++){
                FileMeta imageMeta = new FileMeta();                
                imageMeta.setFileUrl("http://localhost:8080/fileUpload/rest/images/get/" + author + "/" + subfoler + "/" + fileNames[i] + "/");
                imageMeta.setFileName(fileNames[i]);
                files.add(imageMeta);
            }
        } catch(Exception e1) {
            e1.printStackTrace();
        }
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Headers", "Content-Type, Content-Range, Content-Disposition, Content-Description");
        // result will be like this
        // [{"fileName":"app_engine-85x77.png","fileSize":"8 Kb","fileType":"image/png"},...]
        return files;
    }

However, when I run the project , there's not any log. What's wrong? Is there any other configurations?

dakbhavesh commented 9 years ago

Any update on this issue? I was facing the same issue. It seems logging configuration should be of SLF4J.

dsteinkopf commented 9 years ago

It seems I am having the same (similiar?) problem.

What does the ouput "1 fail|abort, 1 error" (see above log output after "started new daemon...") mean? I am also getting this line and see no logging.

Thank You!

dmarkov commented 9 years ago

@yegor256 please dispatch this issue

yegor256 commented 9 years ago

@dannybaby indeed the problem is here:

[INFO] --- jcabi-maven-plugin:0.12:ajc (default) @ fileUpload ---
[INFO] jcabi-aspects 0.18/55a5c13 started new daemon thread jcabi-loggable for watching of @Loggable annotated methods
[INFO] Created temp dir /Users/Lily.L/Tujia/Workspace/fileUpload/target/jcabi-ajc
[INFO] jcabi-aspects 0.18/55a5c13 started new daemon thread jcabi-cacheable for automated cleaning of expired @Cacheable values

1 fail|abort, 1 error
[INFO] ajc result: 0 file(s) processed, 0 pointcut(s) woven, 0 error(s), 0 warning(s)

for some reason, your .class files are not being woven...

yegor256 commented 9 years ago

@dannybaby what is the version of Maven and JDK?

sarthak2707 commented 6 years ago

Not able to do maven clean install @yegor256

AspectJ Internal Error: unable to add stackmap attributes. null
[ERROR] can't determine superclass of missing type com.amazonaws.auth.AWSStaticCredentialsProvider
when weaving type com.zefo.client.config.PrestashopClientApplication
when weaving classes 
when weaving 
when batch building BuildConfig[null] #Files=0 AopXmls=#0
 [Xlint:cantFindType]
[ERROR] can't determine superclass of missing type com.amazonaws.auth.AWSStaticCredentialsProvider
when weaving type com.zefo.client.config.PrestashopClientApplication
when weaving classes 
when weaving 
when batch building BuildConfig[null] #Files=0 AopXmls=#0
 [Xlint:cantFindType]
[WARNING] advice defined in com.jcabi.aspects.aj.MethodLogger has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.ImmutabilityChecker has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.MethodScheduler has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.ExceptionsLogger has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.Repeater has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.MethodValidator has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.SingleException has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.MethodInterrupter has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.QuietExceptionsLogger has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.Parallelizer has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.MethodAsyncRunner has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.jcabi.aspects.aj.MethodCacher has not been applied [Xlint:adviceDidNotMatch]
[INFO] ajc result: 986 file(s) processed, 28 pointcut(s) woven, 2 error(s), 13 warning(s)
[ERROR] #execute(): thrown org.apache.maven.plugin.MojoFailureException(AJC failed, see log above) out of com.jcabi.maven.plugin.AjcMojo#execute_aroundBody0[207] in 1min
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:59.044s
[INFO] Finished at: Mon Feb 12 20:23:58 IST 2018
[INFO] Final Memory: 56M/413M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jcabi:jcabi-maven-plugin:0.8:ajc (default) on project prestaclient: AJC failed, see log above -> [Help 1]
[ERROR]