Tomcat work directory empty - java

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.

Related

Spring Boot & ActiveMQ Artemis: NoClassDefFoundError during start of application

When trying to create a Spring Boot Java application with ActiveMQ Artemis I get the following exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'artemisConfiguration' defined in class path resource [org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.activemq.artemis.core.config.Configuration]: Factory method 'artemisConfiguration' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/activemq/artemis/api/core/QueueConfiguration
From the above exception I have difficult to understand what config might be missing or is it something else? I am using Spring Boot 2.7.3.
It is implemented to the letter as described in the this guide (native and embedded).
The fundamental problem is this:
java.lang.NoClassDefFoundError: org/apache/activemq/artemis/api/core/QueueConfiguration
This means that the JVM can't find this class. This class is in the artemis-commons module. You need to put this on your application's classpath.

Eclipse tomcat on web application start java.lang.ClassNotFoundException: org.mockito.Mockito

I can not start web app in eclipse embedded tomcat, but if I deploy war file in standalone tomcat then it works.
The exception I get is:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name defined in class path resource Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Factory method threw exception; nested exception is java.lang.NoClassDefFoundError: org/mockito/Mockito
The file exception is referring to is annotated with #Configuration and is located in src/test/java;
purpose of the file is to create mock beans for test cases.
The fix to the problem is this link:
How to prevent eclipse from deploying test classes on Tomcat?
The cause of the problem was, when eclipse was assembling a war file it would include src/test/java dir in it, and the dependencies were missing for test cases.
because in pom dependencies for test had test which means that maven will not include those jar files in final bucked product meaning war file.

WebLogic 10.3.7 File Upload returns "Error creating bean with name 'portletMultipartResolver'"

I am using Spring Portlet mvc with file upload. When I was using WebLogic 10.3.0 it was working fine. I am migrating to WebLogic 10.3.7. Here with the same code I am getting below error:
javax.portlet.PortletException:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'portletMultipartResolver' defined in
PortletContext resource Instantiation of bean failed; nested exception
is org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class
[org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver]:
Constructor threw exception; nested exception is
java.lang.NoClassDefFoundError: javax/portlet/ActionRequest
WebLogic server is not able to find ActionRequest.class. I have tried several options like placing jar file (netuix_common.jar) which contains ActionRequest.class inside the application war file but still it didn't work.
What can I try to resolve this?
java.lang.NoClassDefFoundError - you get this error when weblogic server finds this class in its classloader but not the one with the correct version.
you did the right thing by adding it to the application war file, you may want to add the flag of " prefer-web-inf-classes "
https://docs.oracle.com/cd/E23943_01/web.1111/e13712/weblogic_xml.htm#WBAPP601

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.

Why isn't eclipse compiling my web app?

When I start my Tomcat server, linked to my Java EE project, I get the error listed below. Two other people are using the same repository with Eclipse/Tomcat/Java and are not having any problems. It creates my package hierarchy, but the classes are missing. Tomcat develops my WEB-INF/classes/com folders, but the contents are all empty. Can anyone help me with this? Thank you.
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/LightStanza-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.lightfoundryllc.lightstanza.login.LoginValidator] for bean with name 'loginValidator' defined in ServletContext resource [/WEB-INF/LightStanza-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.lightfoundryllc.lightstanza.login.LoginValidator
thanks for your help. I set my environment variables for TOMCAT_HOME and PATH and things seem to be working now :).

Categories