Struts2 Dispatcher initialization failure with maven - jetty - spring

I have the following problem:
I am working on a Web-Project using Struts2 with Tiles supported by a combination of Hibernate and Spring. In addition I am using Maven (which I'm new to) and the jetty server container. So my coworker told me what to do: just check out the project from the svn-repository and run the command (sudo) mvn jetty:run. According to my coworker this should work just fine, as it does when he checks out the project. But I always get the same error:
2011-08-22 10:09:20,568 ERROR org.apache.struts2.dispatcher.Dispatcher.error:38 -
Dispatcher initialization failed
Unable to load configuration. - [unknown location]
I already tried to re-check out the project, cleaned and updated maven, but still, the same error.
I think it has something to do with a missing struts2 .jar-file, but I thought maven downloads all necessary libraries automatically. Please give me a hint what could be missing, I'm sure it's something simple I overlooked.
Thanks in advance.

Related

Jar file not getting added in to a external Libraries in Intellij

I am trying to work on a spring-security project in which i have added the spring security dependency via pom.xml file.But as my maven completed its build successfully,its not getting added in the external library.
Please find my the screenshots below:
pom.xml file:
External Library
Dependencies added after successful maven build :
Tried to create a new project to check whether the above issues persist there as well,but there its working as expected as i am able to get the required java files.So the issue is only relevant to the above project.
I even tried to do the steps mentioned from the below links apart from the maven life cycle steps,but that also did not work out
link

How can I deploy a Camel Route on JBoss Fuse?

I've developed a camel route in a Fuse Project using blueprint, now I would like to deploy the route in the Fuse Server.
I'm not sure if this is a problem but the blueprint.xml returns me this error
White spaces are required between publicId and systemId at line 1
I've tried deploying the project following some guides online: tried to use drag and drop function in jboss dev studio dragging the project folder into server window but nothing happened.
Also tried use maven building and deploying as a maven project via osgi:install but it returns me this error :
Error executing command: Error installing bundles: Unable to start bundle file:/home/pajarittu/jboss_workspace/prova_sub/target/camel-subscribe-1.0.0-SNAPSHOT.jar: Unresolved constraint in bundle camel-subscribe [293]: Unable to resolve 293.0: missing requirement [293.0] osgi.wiring.package; (osgi.wiring.package=org.json)`
Do you know how to solve this problems or different ways to deploy the service? thanks in advance for the the answers.
First of all I recommend looking at this blog post:
http://lhein.blogspot.de/2014/07/improved-server-adapters-for-jboss-fuse.html
I described there how the deployment works now in tooling.
Then you should also make sure that if you choose Fuse 6.1 you can't use Java 8 to run it. I think the last error you posted exactly is caused by this. (I could be wrong though ;) )
Finally Claus is right. If you want to run Camel on Fuse runtime you should make sure you installed all the needed features / camel components in order to sucessfully run your routes.
Hope that helps,
Lars
You can take a look at an example which used camel , REST and camel route is deployed on JBOSS fuse 6.1
https://github.com/TheMaheshBiradar/fuse-middlware-services
.

Spring Boot Run Configuration Issues

I am trying to run my spring boot application (via Run As -> Spring Boot Application) in a tomcat8 container on STS and I am receiving these errors:
Caused by: java.lang.IllegalStateException: Expected method not found: java.lang.NoSuchMethodException: org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext.addApplicationListener(org.apache.catalina.deploy.ApplicationListener)
at org.springframework.util.ClassUtils.getMethod(ClassUtils.java:627)
at org.springframework.boot.autoconfigure.websocket.TomcatWebSocketContainerCustomizer.addListener(TomcatWebSocketContainerCustomizer.java:85)
at org.springframework.boot.autoconfigure.websocket.TomcatWebSocketContainerCustomizer.access$100(TomcatWebSocketContainerCustomizer.java:36)
at org.springframework.boot.autoconfigure.websocket.TomcatWebSocketContainerCustomizer$1.customize(TomcatWebSocketContainerCustomizer.java:50)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.configureContext(TomcatEmbeddedServletContainerFactory.java:355)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.prepareContext(TomcatEmbeddedServletContainerFactory.java:184)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:154)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 7 more
I have searched around for this quite a bit and have found little to guide me in figuring out what the problem is. After going through the spring boot code in the debugger I see that the object named "instance" referenced in the TomcatWebSocketContainerCustomizer.addListener() uses reflection to retrieve a handle to it. This object is associated with the tomcat 7.0.53 jar ($HOME/.m2/repository/org/apache/tomcat/tomcat-catalina/7.0.53/tomcat-catalina-7.0.53.jar). I do not see this in any of my maven dependencies and have tried several techniques to force it to tomcat 8.0.20, nothing seems to work.
After banging my head for a while I started looking at the run configuration for the project in STS (via Run As -> Run Configurations). I found that the Source tab shows tomcat 7.0.53 above version 8.0.20 along with several dependencies that aren't referenced in maven. I am at a loss on where these values come from and not sure how to edit it. For some reason when I try to manually delete these legacy jar files STS doesn't allow me to delete any of them.
Does anyone have an idea of where these dependencies may be coming from and how I can remove them?
They do reference my $HOME/.m2/path/to/tomcat-catalina/<version> dir, so I could simply remove them from my .m2 and theoretically it may work but I'd rather not do this if I don't have to.
I am using spring boot 1.2.x and all of them have this problem.
thanks.
I've got two ideas that you might try.
1) It is possible, that this may be manifestation of this bug in STS 3.6.4: https://issuetracker.springsource.com/browse/STS-4085
The depencies you aren't expecting to see may be coming from the maven 'test' scope. (The bug explicitly mentions 'srt/test' but the same happens with jar dependencies). You can verify whether this bug is the cause by using the regular "Run As Java Application" on your main class.
If that works, then it is almost certainly this bug. If it also fails with a similar error then its something else... then try:
2) You must be getting the unwanted tomcat version from somewhere, probably indirectly as dependency of something else.
Try using the m2e 'dependency hierarchy' to find where it came from like so:
open pom.xml
Click the 'Dependency Hierarchy' tab.
Type 'tomcat' in the 'Filter' box.
I finally figured it out.
In my $WORKSPACE/.metadata/.plugins/org.eclipse.m2e.core/workspacestate.properties it lists all poms, jars and wars from my workspace build with the maven plugin. I noticed that a pom in the file points to the exact version tomcat that is being loaded in my spring boot project. Once I deleted these projects from my STS I can successfully launch the spring boot app :-)
When I re-import the maven projects back to STS the error occurs again, then disappears when I remove them.
These projects have no connection to the project that I am trying to launch. Therefore I think the bug is in m2e.
I'll file a bug and update this post when it is complete.
thanks #Kris for working through it with me.

Spring Boot v1.2 AbstractMethodError due to RepositoryInformation

Im building an application based on Spring Boot v1.2. While my application boots successfully and executes well (so far.. ), I'm unable to test using the spring boot framework because of an AbstractMethodError.
The last few lines of the trace are as below
Caused by: java.lang.AbstractMethodError: org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor.postProcess(Lorg/springframework/aop/framework/ProxyFactory;Lorg/springframework/data/repository/core/RepositoryInformation;)V
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:84)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1627)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
... 55 more
To analyze the above error, I checked the jar files from classpath involving the above classes. So the info is available as below
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-aop-4.1.2.RELEASE.jar!/org/springframework/aop/framework/ProxyFactory.class
jar:file:/C:/rearch/mavenrepo/org/springframework/data/spring-data-commons/1.9.1.RELEASE/spring-data-commons-1.9.1.RELEASE.jar!/org/springframework/data/repository/core/RepositoryInformation.class
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-data-jpa-1.3.3.jar!/org/springframework/data/jpa/repository/support/LockModeRepositoryPostProcessor.class
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-test-4.1.2.RELEASE.jar!/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.class
I'm not exactly sure on why spring-data-commons is coming up from maven repostory folder, while the others are being served from the project library.
While I debug that, I meanwhile need your help in figuring out the version compatibility between the above libraries.
I wasnt able to exactly pin point on what exactly is causing the error. Please help!
Thanks
The issue was with the intellij configuration of libraries which conflicts with Spring boot application. I manually replaced the required libraries from Maven repository and that worked out for me.
Per request from Elron..
Open the project folder in explorer and verify if the third party library versions in your project matches the ones you actually expect it to be. If something doesnt match, just replace the file with the one you expect it to be. In my case, since I use Maven, I didnt see a need for explicitly saving those libraries in a new lib folder under the project. So, I just deleted all of the files inside the lib folder and things started working again.
For fix this error, change the spring-data-jpa version to 1.5.0.RELEASE
I have faced this issue .
Get rid of spring-data-commons and change spring-data-jpa version to 1.9.0.RELEASE.
For more details , please follow this link :-
Spring Data Rest PagingAndSortingRepository AbstractMethodError (RepositoryFactorySupport)

How to run a project containg drools in Tomcat7?

I have created a Dynamic web project which also uses drools for providing some functionality. When i put the WAR file in Tomcat7 and the server, the drools part does not work.
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
After this line which is first line relating to drools, nothing happens.
Is some configuration required to run my project containing drools 5.5.0 Final in the Tomcat7.
Please help me. I am badly stuck and I am new to drools.
You'll have to add some facts to the working memory and execute(fire) the rules. Check out these examples on GitHub
P.S. Probably not related to Tomcat in any way. Might be worth while to try getting the rules executed from command line app first.
You need to check all the dependencies that are added to your web application (WEB-INF/lib) make sure that drools has all the required deps there, because if not it will not be able to create the knowledge builder. Most of the time if it is failing is because that you forgot to add the deps in the web app.
The following project in GitHub is a web application, containing some REST-style endpoints for validating IBANs. It uses Drools 5.5 to perform that evaluation.
https://github.com/gratiartis/sctrcd-payment-validation-web/
It generates a .war which can be loaded into Tomcat, and could be a useful starting point. The knowledge base is wrapped within a Spring service:
https://github.com/gratiartis/sctrcd-payment-validation-web/blob/master/src/main/java/com/sctrcd/payments/validation/RuleBasedIbanValidator.java
Following through how that creates a knowledge base and session might help you see where your code is going wrong.
As a bonus, you can run it up in Tomcat using "mvn tomcat7:run" to test it out immediately.

Resources