Can not deploy a project on Jboss because of a Dozer class not found - ejb-3.0

Hi I'm using Eclipse on a EJB3 project, struts2 and hibernate.Server is JBoss 7.1. Everything worked fine.
Then I've installed Dozer 5.2.2,and added that to the build path (it shows in "referenced libraries" folder, and I've checked in the "configure build path" menu as well)
It works fine in my Junit test cases.
The problem is that when I try to deploy the EJB project , I get an error :
Caused by: java.lang.ClassNotFoundException: org.dozer.DozerBeanMapper from [Module "deployment.EJBprofile.jar:main" from Service Module Loader]
What am I doing wrong?
Thanx for your help

You could install the Dozer as a module if you need it for both your EJB and your WAR. You could also package everything into an EAR and put the Dozer library in the EAR/lib directory.
Also have a look at how class loading works.

Related

Im tying to register a service in eureka and im getting the following error

After setting up my eureka server. I went to the service that i want to register and in the main class i added this annotation #EnableDiscoveryClient. After that i went to application.properties and add this configuration<eureka.client.service-url.default-zone=http://localhost:8761/eureka and after that i added this to the pom spring-cloud-starter-netflix-eureka-client . And after starting the application im getting this exception and i think i did everything right.
java.lang.IllegalArgumentException: Could not find class [org.springframework.cloud.client.loadbalancer.LoadBalancerClientsProperties]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:334) ~[spring-core-5.2.7.RELEASE.jar:5.2.7.RELEASE]
You have to refresh dependencies. If you just add dependency to pom file it wouldn't be installed automatically.
I'm not using maven, but I think the following should work for you. Just run these commands within command line in root directory of project.
mvn dependency:purge-local-repository clean install
mvn dependency:resolve

Tomcat not starting after changing packaging from jar to war

Firstly, after changing the packaging from jar to war for spring boot application, I am not able to do maven build. Getting below error:
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.goel.GameApplication]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/application.properties]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:189)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331)
The above error comes when maven tries to run app tests. So I commented out the test and ran maven build and I was able to get a war file.
But after deploying the same war file in tomcat(aws), I am getting the same error.
I have followed the 3 step approach properly.Ref: https://www.javadream.in/convert-jar-to-war-in-spring-boot/
I have checked that the build-path does not exclude resource or application.properties
I have tried moving from spring IDE to Eclipse IDE.
I have opened the war file and have verified that the application.properties file is present under WEB-INF/classes/application.properties.
I have read and tried many other things but nothing helped. Any pointers will be helpful. Thanks in advance.
Please do let me know if more info is required,
Java Version: 1.8 ,
Maven Version: 3.6.3 ,
spring-boot-starter-parent: 2.5.4
Exploded war file
Screenshot for SSGApplication

Spring Boot 1.4.3 Embedded Tomcat NoSuchMethodError StringManager.getManager

I have update my project to use Spring BOOT 1.4.3. The code compiles and runs without issues from Eclipse Neon 1.
But when I run from command line
mvn clean install -DskipTests
java -jar myweb\target\my-web-1.0-SNAPSHOT.jar
I get runtime error and tomcat is not starting
Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.res.StringManager.getManager(Ljava/lang/Class;)Lorg/apache/tomcat/util/res/StringManager;
at org.apache.catalina.util.LifecycleBase.<clinit>(LifecycleBase.java:43) ~[tomcat-embed-core-8.5.6.jar!/:8.5.6]
Please can you tell why? How to find which tomcat is used at runtime, as my understand is that 8.5.6 is having compile scope(?)
Please help. If the suggestion is to use tomcat.version in properties of POM file or add tomcat-juli dependency, then please help me understand why it is required?
Impatient stackoverflow'ers dont just flog new comers only because you can do. You can easily ask if you want my POM, but I used just spring-boot-starter-web thats it.
For this kind of problem, it's often due to multiple jar having the same class inside your classpath, so :
Find where this class / method could come from, by opening the type popup (CTRL + SHIFT + T in Eclipse). It will display you every jar in your classpath that contains the class.
Open the class in each jar to see which one contains your method and which one don't.
Display the dependency hierarchy of your project with mvn dependency:tree
If the 2 jars are in your classpath, you might exclude the one that don't contain the method.

Read emails on Tomcat: ClassNotFoundException: javax.mail.MessagingException

My application is running on Tomcat 7.
I'm trying to read emails from inbox, and for that I use a normal Java class.
There is also a Servlet that calls the method readMails in the mentioned class.
Now I get an exception:
java.lang.ClassNotFoundException: javax.mail.MessagingException
...
I use IntelliJ IDEA with Maven, I changed the dependency of javax.mail a lot (see http://mvnrepository.com/artifact/javax.mail), but the exception keeps coming up.
I've also changed the Version of Tomcat (7 and 8), and the version of "Project SDK" (1.7 and 1.8) and "Project language level" (7 and 8).
I've read somewhere that there is a difference between reading emails via IMAP with normal Java application and running it on Tomcat.
In a previous project I read emails successfully with a normal Java application.
Can anyone help me with this exception?
JavaMail API is not included by default among Tomcat libraries.
Make sure that JavaMail dependency (mail-X.X.jar) is either packaged together with your application (in WEB-INF/lib) or is in a folder that Tomcat class loaders read (for example $CATALINA_HOME/lib), as described here:
http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
Thanks, it works now.
I put the jar file (javax.mail: javax.mail-api-1.5.4.jar) downloaded by maven (.m2/repository/ ...) into WEB-INF/lib (in my project).
I also needed to put another jar file into WEB-INF/lib (com.sun.mail: javax.mail-1.5.4.jar) due to this exception:
java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger
javax.mail.Session.initLogger(Session.java:226)
javax.mail.Session.<init>(Session.java:210)
javax.mail.Session.getDefaultInstance(Session.java:321)
I added
<packaging>war</packaging>
to my pom.xml. This way maven puts the dependencies in the target folder.

Deploy project without /WEB-INF/lib by placing libs in Tomcat's common.loader

I would like to deploy my project without /WEB-INF/lib.
I created a folder /usr/share/tomcat7/mylib and move all the files from /WEB-INF/lib. I ordered this directory for common.loader, but the application has stopped running.
java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
...
The error is due to org.hibernate.validator.internal.engine.ConfigurationImpl not spring libraries. Check for hibernate-validator jar

Resources