Hello
In this end, this is just a classpath problem. The rub is I'm debugging my webapp on the server via Spring source's eclipse based IDE.
The first call to the web services fails because
java.lang.ClassNotFoundException: org.john.app.domain.AccreditedPostsecondaryInstitu tion
See full backtrace below.
I have a project which I want to use as a jar in support of a web app project. The offending class is in this jar. Both projects are based on maven.
'mvn install' is invoked to install the jar into the local repository. I believe this worked because I see it in
~/.m2/repository/org/john/reaper/1.0-SNAPSHOT/reaper-1.0-SNAPSHOT.jar
Using Spring Source's Eclipse based IDE ( STS 2.9.2 - http://www.springsource.org/sts ), I added
andCode:<dependency> <groupId>org.john</groupId> <artifactId>reaper</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
to pom.xml. I believe this worked because the project builds within eclipse and it shows up in maven's list of dependencies.Code:<repository> <id>JK local</id> <name>john's repo</name> <url>file:///home/jkern/.m2/repository</url> </repository>
Also, the desired jar file ends up in the war file.Code:$ mvn dependency:tree [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'dependency'. [INFO] ------------------------------------------------------------------------ [INFO] Building BuscandoColetivo [INFO] task-segment: [dependency:tree] [INFO] ------------------------------------java------------------------------------ [INFO] [dependency:tree {execution: default-cli}] [INFO] org.john:buscando:war:1.0.0-BUILD-SNAPSHOT [INFO] +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile [INFO] | +- org.springframework:spring-aop:jar:3.1.1.RELEASE:compile [INFO] | +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile [INFO] | +- org.springframework:spring-core:jar:3.1.1.RELEASE:compile [INFO] | +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile [INFO] | \- org.springframework:spring-asm:jar:3.1.1.RELEASE:compile [INFO] +- org.springframework:spring-webmvc:jar:3.1.1.RELEASE:compile [INFO] | +- org.springframework:spring-context-support:jar:3.1.1.RELEASE:compile [INFO] | \- org.springframework:spring-web:jar:3.1.1.RELEASE:compile [INFO] +- org.aspectj:aspectjrt:jar:1.6.9:compile [INFO] +- org.slf4j:slf4j-api:jar:1.5.10:compile [INFO] +- org.slf4j:jcl-over-slf4j:jar:1.5.10:runtime (scope not updated to compile) [INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.10:runtime (scope not updated to compile) [INFO] +- log4j:log4j:jar:1.2.15:runtime (scope not updated to compile) [INFO] +- javax.inject:javax.inject:jar:1:compile [INFO] +- javax.servlet:servlet-api:jar:2.5:provided (scope not updated to compile) [INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided [INFO] +- javax.servlet:jstl:jar:1.2:compile [INFO] +- junit:junit:jar:4.7:test [INFO] +- org.mongodb:mongo-java-driver:jar:2.7.1:compile [INFO] +- org.springframework.data:spring-data-mongodb:jar:1.0.2.RELEASE:compile [INFO] | +- org.springframework:spring-tx:jar:3.1.1.RELEASE:compile [INFO] | \- org.springframework.data:spring-data-commons-core:jar:1.2.1.RELEASE:compile [INFO] +- org.springframework:spring-dao:jar:2.0.8:compile [INFO] | +- aopalliance:aopalliance:jar:1.0:compile [INFO] | \- commons-logging:commons-logging:jar:1.1:compile [INFO] | +- logkit:logkit:jar:1.0.1:compile [INFO] | \- avalon-framework:avalon-framework:jar:4.1.3:compile [INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.4.2:compile [INFO] | \- org.codehaus.jackson:jackson-core-asl:jar:1.4.2:compile [INFO] \- org.john:reaper:jar:1.0-SNAPSHOT:compile [INFO] +- net.sf.opencsv:opencsv:jar:2.0:compile [INFO] +- org.jsoup:jsoup:jar:1.6.3:compile [INFO] \- cglib:cglib:jar:2.2:compile [INFO] \- asm:asm:jar:3.1:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6 seconds [INFO] Finished at: Thu Jul 05 15:27:18 PDT 2012 [INFO] Final Memory: 17M/41M [INFO] ------------------------------------------------------------------------ $
Unfortunately, when debugging on the server via STS, the WebappClassLoader can find a class which is in reaper-1.0-SNAPSHOT.jar. Why doesn't it get copied to the server directory? I noticed one difference in STS's dependency manager. reaper-1.0-SNAPSHOT.jar is representing with a folder icon while all others use a jar icon. This might make sense since reaper-1.0-SNAPSHOT.jar is local while the others are remote. Do I need to set a container specific path in STS? Or perhaps, explicitly tell STS to export this jar?Code:$ jar -tvf target/buscando-1.0.0-BUILD-SNAPSHOT.war | grep reap 29808 Mon Jul 09 19:07:50 PDT 2012 WEB-INF/lib/reaper-1.0-SNAPSHOT.jar
-jk
Code:SEVERE: Servlet.service() for servlet [appServlet] in context with path [/BuscandoColetivo] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/john/app/domain/AccreditedPostsecondaryInstitution] with root cause java.lang.ClassNotFoundException: org.john.app.domain.AccreditedPostsecondaryInstitution at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556) at org.john.buscando.services.InstitutionRepository.findBounded(InstitutionRepository.java:42) at org.john.buscando.MapController.getInstitutions(MapController.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.traceNextValve(HttpRequestOperationCollectionValve.java:116) at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:98) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:636)


Reply With Quote
