Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Debug web app classpath problems

  1. #1
    Join Date
    Mar 2012
    Posts
    22

    Default Debug web app classpath problems

    I have a Spring project named AppGen, building with Maven, that worked fine in STS 2.9.2.RELEASE.
    I refactored a bit and moved some classes to a second project named commons.rest and added a dependency
    to it from AppGen/pom.xml - compiles/validates fine in Eclipse.
    However, after this refactoring, when I launch tc Server, I get classloader exceptions, shown at the bottom

    The Servers view in STS shows the server, with AppGen [Synchronized] and when I expand that,
    it shows commons.rest [Synchronized] beneath AppGen. (The class com.sas.commons.rest.Collection exists in commons.rest in src/main/java.)

    How do I figure out what's broken - i.e. what the constructed classpath is, and why my class is not found?

    if I close the commons.rest project (so that AppGen reconfigures its Maven class path to use the jar in the Maven repo instead of the commons.rest classes directory), the app starts up correctly. But I want to keep both projects open for developing/testing.

    Is this an STS problem, or an Eclipse WebTools problem, or something else?

    thanks

    traceback:
    Code:
    java.lang.ClassNotFoundException: com.sas.commons.rest.Collection
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
        at java.lang.Class.getDeclaredMethods(Class.java:1791)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:383)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:321)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:830)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:493)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)

  2. #2
    Join Date
    Mar 2012
    Posts
    22

    Default

    side note: as per this StackOverflow thread, my commons.rest project was already correctly listed in the Deployment Assembly. However, under both cases (commons.rest project open or closed), the Deployment Assembly
    shows the dependency as

    commons.rest WEB-INF/lib/sas.commons.rest-0.1.0-SNAPSHOT.jar

    That jar exists only in ~/.m2/repository/com/sas/commons/rest/sas.commons.rest/0.1.0-SNAPSHOT/sas.commons.rest-0.1.0-SNAPSHOT.jar and in the project's target directory (as a result of a Maven build there).

  3. #3
    Join Date
    Sep 2008
    Location
    Hamburg, Germany
    Posts
    1,637

    Default

    Hey!

    Can you attach a sample project that reproduces the problem?

    Thanks,
    -Martin
    Martin Lippert
    SpringSource, a division of VMware
    SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/martinlippert

  4. #4
    Join Date
    Mar 2012
    Posts
    22

    Default

    Hi, Martin.

    yes, I was able to strip this down to two basic projects A and B that exhibit this problem. The attached sts-webtools-cnfe.zip contains the two Eclipse projects, A and B. Deploy A with B open and I get the ClassNotFoundException; if I do a 'mvn install' on B, then close B and restart the server, it finds the class in B-0.1.0-SNAPSHOT.jar

    HTH,
    djb
    Attached Files Attached Files

  5. #5
    Join Date
    Sep 2008
    Location
    Hamburg, Germany
    Posts
    1,637

    Default

    Hey!

    Thanks for attaching the sample application. I tried those projects with a fresh STS 2.9.2 installation as well as the upcoming STS 3.0.0 and both versions seem to work. I cannot start the app, it fails with a database connection problem, but it automatically deployed a B-0.1.0-SNAPSHOT.jar in the lib folder of the deployed app while I had project B open in my workspace.

    Are you using a standard STS 2.9.2 installation or did you install that manually into an existing Eclipse? Just asking because the STS distribution comes with m2e and m2e-wtp pre-installed. Maybe there is something missing in your installation? Just a rough guess here, but that would explain why it is not working in your environment.

    HTH,
    Martin
    Martin Lippert
    SpringSource, a division of VMware
    SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/martinlippert

  6. #6
    Join Date
    Mar 2012
    Posts
    22

    Default

    Thanks, Martin.

    I am using the full STS that I downloaded from springsource - I think I originally downloaded 2.9.1.RELEASE (based on my directory structure) then used the update site to update to 2.9.2.RELEASE. I'm running on Linux (Ubunto 11.10) with JDK 1.6.0.32. Maven/m2e works fine (i.e. the Maven classpath works and resolves jars and classes from my pom.xml); webtools runs fine otherwise, etc.

    In my original question I asked how I could diagnose this - i.e. where does STS deploy this, so I can check what gets deployed and what is in the WEB-INF/lib. You said you verified the B jar was deployed - how do I check that on my system?

    I'll also try downloading 2.9.2.RELEASE and start from scratch with it.

    thanks

  7. #7
    Join Date
    Sep 2008
    Location
    Hamburg, Germany
    Posts
    1,637

    Default

    Hey!

    If you are running the tc Server Developer Edition that comes with STS 2.9.x, you can take a look at that installation directory, then go to the instance that you are using (by default the spring-insight-instance), and browse to the wtpwebapps directory. There you should find your projects being deployed to tc Server.

    HTH,
    Martin
    Martin Lippert
    SpringSource, a division of VMware
    SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/martinlippert

  8. #8
    Join Date
    Mar 2012
    Posts
    22

    Default

    I found the internal deployment directory:

    /u/sasdjb/eclipse-workspaces/springsource/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps

    so now I can look at the <webapp>/WEB-INF/lib folder. For my A/B project in the attachment,
    I also see

    /u/sasdjb/eclipse-workspaces/springsource/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/A/WEB-INF/lib/B-0.1.0-SNAPSHOT.jar

    but still get CNFE

    I downloaded STS 2.9.2, ran with my existing workspace, and started Tomcat 7 and got a new error

    Code:
    SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
    java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
    	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
    	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4638)
    	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
    	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
    	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	at java.lang.Thread.run(Thread.java:662)
    Aug 3, 2012 9:39:55 AM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Skipped installing application listeners due to previous error(s)
    Doing a Server -> Clean... fixed that, but I still get a CNFE on the class in my B project if B is open.

  9. #9
    Join Date
    Sep 2008
    Location
    Hamburg, Germany
    Posts
    1,637

    Default

    Hey!

    What do you see in the "spring-insight-instance" directory of your tc Server? Are the libs there correctly deployed as well?

    -Martin
    Martin Lippert
    SpringSource, a division of VMware
    SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/martinlippert

  10. #10
    Join Date
    Mar 2012
    Posts
    22

    Default

    There is no sas.commons.rest-0.1.0-SNAPSHOT.jar anywhere in my spring-insight-instance directory, although the other jars from the Maven pom.xml dependencies are all there. Also, spring-insight-instance contains classes/**/*.class files from my main AppGen project, but nothing from my dependent commons.rest project.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •