Announcement Announcement Module
Collapse
No announcement yet.
Debug web app classpath problems Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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).

    Comment


    • #3
      Hey!

      Can you attach a sample project that reproduces the problem?

      Thanks,
      -Martin

      Comment


      • #4
        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

        Comment


        • #5
          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

          Comment


          • #6
            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

            Comment


            • #7
              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

              Comment


              • #8
                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.

                Comment


                • #9
                  Hey!

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

                  -Martin

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      Hey!

                      But it does work with your attached sample project? The B snapshot JAR appears in the spring insight instance directory?

                      -Martin

                      Comment


                      • #12
                        I deleted my tc Server server instance but alas I could not add it back - there are no templates, so the
                        wizard cannot complete. (That feels like a STS bug).

                        I reinstalled STS 2.9.2.FINAL and the server is there in a new (empty) workspace, but not in my original workspace. There does not seem to be a server export/import ability.

                        After reinstalling, my small test case works (I simplified it even more, removed all the Roo stuff and
                        narrowed it down to just a Dynamic Web project C with a JSP that loads a class from project a basic Java project, D)
                        and that worked, but only after I cleaned up D's Deployment Path in the Deployment Assembly preferences.

                        Comment


                        • #13
                          Hey!

                          Originally posted by DavidBiesack View Post
                          I deleted my tc Server server instance but alas I could not add it back - there are no templates, so the
                          wizard cannot complete. (That feels like a STS bug).
                          Yes, that doesn't sound correct. Do you have a valid tc Server runtime environment configuration in your STS installation? Can you check that, just in case there went something wrong? If you have your tc Server installation configured correctly, does that tc Server installation still contains the folder "templates"?

                          Thanks for taking a look!
                          -Martin

                          Comment


                          • #14
                            Thanks for the hint.
                            The server definition in my Window -> Preferences -> Server -> Runtime Environments was old - it
                            had the old tcServer from a previous (2.9.1.FINAL) install of STS (tc Server 2.6.4 instead
                            of 2.7.0).

                            I updated that to point to my current STS install and it now works.

                            Perhaps the STS server plugin should ensure that Server Runtime Environments contains the bundled tc Server - otherwise upgrades such as mine (using an existing workspace) may fail. It's probably rare - requires manually deleting the server from the Servers view.

                            thanks

                            Comment


                            • #15
                              Hey!

                              Glad to hear that we found the problem and that it is working again!!!
                              And I agree to your comment about the updating behavior, we should improve that. Thanks for the suggestions there!!!

                              Cheers,
                              -Martin

                              Comment

                              Working...
                              X