File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven Dependency errors in STS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven Dependency errors in STS" Watch "Maven Dependency errors in STS" New topic
Author

Maven Dependency errors in STS

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Hi everyone, I have a Maven project which I have been working with since June in STS IDE with no issues. But on Monday morning, few days ago now, I opened my workspace and was not able to get it compiled again. The error I'm getting apparently is related to STS not seeing Maven Dependency in WEB-INF/lib. This error is:
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
So the cure for that is to add Maven Dependencies. When I do that (project -> Properties -> Deployment Assembly -> Add -> Java Build Path -> Maven Dependencies) and click Apply And OK, I attempt to "Start the Server"/build again. But this time I get a different build error which is a lot more verbose, the error:

---------------------------------------------------
2012-11-27 13:29:13,670 [pool-2-thread-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot create inner bean '(inner bean)' of type [org.springframework.security.config.authentication.AuthenticationManagerFactoryBean] while setting bean property 'parent'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'proscmAuthenticationProvider' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.proscm.resources.ProscmAuthenticationProvider] for bean with name 'proscmAuthenticationProvider' defined in file [C:\Users\liliyaw\Desktop\springsource\vfabric-tc-server-developer-2.7.0.RELEASE\spring-insight-instance\wtpwebapps\proscm\WEB-INF\classes\META-INF\spring\applicationContext-security.xml]; nested exception is java.lang.ClassNotFoundException: com.proscm.resources.ProscmAuthenticationProvider
-------------------------------------------------------
So the file applicationContext-security.xml did not change. File resources.ProscmAuthenticationProvider does exist and was not updated. Am I missing something? I should mention - this Maven Project is my first one, my experience setting up Maven projects is minimal.

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

What is "STS IDE"?

Exactly what was the spring dependency that you added? (You can find this in the pom.xml file, looking at the source.)

It appears that the spring dependency you are relying on requires another dependency. The thing is, that such a dependency should be automatically included (which is why I asked for the exact dependency text). But if the spring component is not properly configured, you will have to add the "proscm" resource in as a dependency to your project. Or is 'proscm' your project?


JBoss In Action
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Hi Peter, STS is Spring + Eclipse IDE (SpringSourse Tool Suite).
I was able to finally build the project, without doing anything different from what I was already doing. I'm not sure what happened to my IDE - it was finding dependencies fine, then it stopped. Now, I can build fine, but I need to physically delete target folder, where freshly compiled files stored for my edits to the files to take place... From what I found on the web STS and Maven are finicky together and some things are not compatible between the two. So I don't know, I don't want to go through the process of re-installing everything if I don't have to.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

I usually do two things to get m2e and Eclipse to peacefully co-exist:

1) I often do Project > Clean and then clean all projects without automatically rebuilding (this accomplishes the same thing as removing the target folder that you mentioned)

2) I even more often to right-click project > Maven > Update Project (or Update Dependencies for older versions of m2e) and select all projects. This causes m2e to re-evaluate the dependencies and refresh the build classpath that Eclipse uses.

Usually these two actions remove all of the false errors reported by Eclipse.
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Hi Peter, I've tried building as you suggested. The second step takes out my Maven Dependencies and doesn't add them back, so I have to add them back manually. "Clean Project" doesn't get rid of the old target dir entirely - target and m2e-wtp dirs are there, but empty. One thing that's also happening, and equally annoying, in this build precess - now I need to do a maven build, then I need to refresh the project to bring in the fresh target files, then I do tc server build. In the past, I did only the server build and that by it self took care of everything, no cleaning or refreshing of the project.
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2448
    
  28

Check the problem logs in eclipse. It could be that the build failed before maven could process the dependencies which causes eclipse to basically not add any dependencies

What happens when you build the project through command line?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

Are you sure that you create a Maven project? It sounds like you created some other kind of project and are now expecting to use Maven to manage dependencies.
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Yes, I'm confident it's a Maven project, it has the structure of Maven project. It worked fine for a very long time. This morning it is acting out again - same error, can't get it to compile.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maven Dependency errors in STS