Roo project import error in eclipse(sts) - java

I get an error when I want to import my project to sts(eclipse). I generate this project with spring roo and its work an other laptop so I just want to import and run on tomcat server somebody know what is this, I watch the dependecies and this class is there (I use Windows):
2012-10-16 23:32:42,540 [main] ERROR
org.springframework.web.context.ContextLoader - Context initialization
failed org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManager' defined in file
[D:\projects.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\roo-jquery-bootstrap\WEB-INF\classes\META-INF\spring\applicationContext.xml]:
Cannot resolve reference to bean 'entityManagerFactory' while setting
bean property 'entityManagerFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'entityManagerFactory' defined in file
[D:\projects.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\roo-jquery-bootstrap\WEB-INF\classes\META-INF\spring\applicationContext.xml]:
Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: Cannot find class
[org.hibernate.ejb.HibernatePersistence] at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at
... 41 more

I solved that it was an eclipse bug i restarted the eclipse and the application worked..

Related

Could not resolve placeholder in jar file

I faced the problem that during execution of my Spring Boot app in IntelliJ IDEA (Java) all works fine. But when I created jar file and tried to run the app in console, I have UnsatisfiedDependencyException because could not resolve placeholder.
Detailed description of Exception is below:
WARN org.springframework.context.annotation.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controllerBattle': Unsatisfied dependency expressed through field 'controllerMarket'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controllerMarketBean': Unsatisfied dependency expressed through field 'meteorRain'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'meteorRainBean': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'priceMeteorRain' in value "${priceMeteorRain}"
I researched this problem and found similar problem raised 2 years ago:
Spring boot Could not resolve placeholder
But it was related to kotlin and it was left unsolved.
Are there ways to solve this problem for Java?
I'll be grateful for your help.

Java application running in Eclipse but not as standalone jar

I have built a java application using spring-boot and maven. When I am running this application from eclipse it is running perfectly fine, but when I try to run this application as a standalone jar through java -jar, it is giving me this error
Error
o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'placeRefillOrderControllerImpl':
Unsatisfied dependency expressed through field 'placeRefillOrderService'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException
Error creating bean with name 'placeRefillOrderServiceImpl':
Unsatisfied dependency expressed through field 'placeRefillOrderBiz'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'placeRefillOrderBizImpl':
Unsatisfied dependency expressed through field 'placeRefillOrderConnector'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'getConnector': Unsatisfied dependency expressed through field 'refillOrderRequestTransformer'; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'refillOrderRequestTransformer':
Lookup method resolution failed; nested exception is
java.lang.IllegalStateException: Failed to introspect Class [com.sams.pharmacy.soapconnector.helper.RefillOrderRequestTransformer] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader#439f5b3d]

Unable to deploy spring boot jar application

I'm developping a spring boot application and it works fine when I run the command:
mvn spring-boot:run
But when deploying jar file with the command:
java -jar target\jarfile.jar
I get the following error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeResource': Unsatisfied dependency expressed through field 'hrServicesSilo'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hrServicesSilo': Unsatisfied dependency expressed through field 'employeeService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeService': Unsatisfied dependency expressed through field 'employeeRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.intranet.si.model.hr.Employee
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
What am I doing wrong?
I can see a repository so I assume you use spring-data. It is strange that it works in maven and not working after packaging so you can try the following:
Check that you use spring-maven-plugin to package your application.
Try to add #EntityScan("com.intranet.si.model.hr") (can also be com.intranet.si.model to recursivly catch all models in the package and sub-packages) to one of your configuration classes or to the application class (the one annotated with #SpringBootApplication). This will notify spring + hibernate where to scan for entities. Also make sure your entity is annotated with #Entity.
I guess that you already have #EnableJpaRespotories in one of your configuration files but make sure it is configured as well.

Tomcat work directory empty

My Spring project was successfully deployed on another Linux server. But when I tried deploying it on this Linux server, it won't deploy. When I go to the homepage, I get the error "HTTP Status 404 - The requested resource is not available".
I compared the Tomcat directory of both servers and see only differences in the "work" directory. On this server (the one having problem), under "work\Catalina\localhost\MyProject" directory of Tomcat, I see that it's empty. Turns out that the files got put under "work\Catalina\localhost\_" instead. What's causing Tomcat to do this?
In my tomcat log file, I'm getting this:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SampleService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wdc.hydra.dao.DatatypeDAO com.wdc.hydra.service.DatatypeServiceImpl.datatypeDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SampleDAO': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Sample' defined in class path resource [Sample-dao-context.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
Does anyone know why this is happening? Thanks.
How does the Spring Container defined? whether its by XmlWebApplicationContext / FileSystemXmlApplicationContext / ClasspathXmlApplicationContext and if its through FileSystemXmlApplicationContext then your directory structure in both the linux servers should be same. like wise others too.

DispatcherServlet - Context initialization failed in Roo project

I develop a Roo project and deploy to a Tomcat 6 server.
Up until now everything was working fine.
I deleted and re-added an entity.
Now everytime when I start Tomcat I get this exception in the Spring Tool Suite:
SEVERE: StandardWrapper.Throwable
Throwable occurred: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.MappedInterceptor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'applicationConversionService' while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [myproject.web.ApplicationConversionServiceFactoryBean] for bean with name 'applicationConversionService' defined in ServletContext resource [/WEB-INF/spring/webmvc-config.xml]; nested exception is java.lang.ClassNotFoundException: myproject.web.ApplicationConversionServiceFactoryBean
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [myproject.web.ApplicationConversionServiceFactoryBean] for bean with name 'applicationConversionService' defined in ServletContext resource [/WEB-INF/spring/webmvc-config.xml]; nested exception is java.lang.ClassNotFoundException: myproject.web.ApplicationConversionServiceFactoryBean
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
...
What do I need to do to make it work again?
spring is complainig about a bean not being available (probably the one you say you deleted).
exception is java.lang.ClassNotFoundException: myproject.web.ApplicationConversionServiceFactoryBean
try to search the config xml files & remove the reference made to this class, things should be back after that,
I had the same exact issue.
The problem was that I disabled the "Project > Build Automatically" feature, so I had to manually build the project.
Once I manually built the project everything went back to normal. :)
So, don't forget to build the project before deploying it, or just re-enable the "Project > Build Automatically" feature.
Hope it helps.
Your app deployed to Tomcat doesn't have a jar file in WEB-INF/lib that contains the class myproject.web.ApplicationConversionServiceFactoryBean. I don't know what that class is or where you'd find it, but it's missing.
my workaround (worked with eclipse and roo 1.1.5 as eclipse plugin)
open ApplicationConversionServiceFactoryBean.java class
delete class annotation #RooConversionService
wait for roo update
add back class annotation #RooConversionService
wait for roo update and try again
Inside of STS, click ->project->clean
It clean and discard all build problems and built states, The next time a build occurs the projects will be rebuilt from scratch.

Categories