While upgrading application from jdk6 to jdk8, we are getting following error on Message msg = new MimeMessage(session);
SEVERE: Servlet.service() for servlet [default] in context with path [] threw exception [java.lang.reflect.InvocationTargetException] with root cause
java.lang.ClassNotFoundException: com.sun.mail.util.MessageRemovedIOException
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
Has anyone faced the same or related issue while upgrading their java app ?
EDIT: the same code is working with java6.
You've got a mix of JavaMail classes from different versions of JavaMail in your classpath. What application server are you using and what's in the lib directory of your web application?
i used this and it worked:
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.5</version>
</dependency>
I had a similar problem. I am using Maven dependencies to
configure external libraries.
The problem was resolved by switching from the new maven repository
for the Java Mail Api, to the old Maven repository
New Repository(raises the exception):
javax.mail
javax.mail-api
1.5.5
Old repository(works fine):
javax.mail
mail
1.4
I have no idea why using the old repository works, and using the new one doesn't. It would be great if someone was to clarify this.
Related
When I am trying to run my app I have the following error message :
cannot Deploy pro_jpa
deploy is failing=Error occurred during deployment: Exception while deploying the app [pro_jpa] : java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader. Please see server.log for more details.
So I add this to my pom :
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>10.0.1</version>
</dependency>
But it didn't fix the issue even if it supposed to add the needed jar to the app.
I also tried to add the guava.jar to the server lib but it doesn't change anything.
If anyone has an idea thank you.
Add the runtime scope to the dependency in pom.xml, to get it available at runtime:
<scope>runtime</scope>
I have no more this issues when I am working with version 2.3 of the web app it is only appearing when I am using version 3.0.
I am using BoneCP and glassfish so the issue may comes from it.
To solve it I need to add the jar to the domaine itself in glassfish under :
glassfish5\glassfish\domains[domain name]\lib\ext
I end with this jar :
bonecp-0.8.0-rc1.jar
guava-29.0-jre.jar
mysql-connector-java-8.0.20.jar
slf4j-api-1.7.30.jar
I am working with CXF 3.1.8,i want to integrate Swagger,so i added the code below:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-swagger</artifactId>
<version>3.1.7</version>
</dependency>
And in JAXRSServerFactoryBean i added :
JAXRSServerFactoryBean jfb =new JAXRSServerFactoryBean();
Swagger2Feature feature=new Swagger2Feature();
jfb.getFeatures().add(feature);
But i get error when i want to deploy my application:
Caused by: java.lang.NoSuchMethodError:
io.swagger.jaxrs.config.BeanConfig.setUsePathBasedConfig(Z)V
Any help is appreciate.
Please check the version of the swagger-jaxrs dependency that you are using.
I suggest to upgrade the CXF version too. Latest 3.1.x would be 3.1.18, but you should probably use the latest 3.3.0 version. Look here https://github.com/apache/cxf/tree/cxf-3.3.0/distribution/src/main/release/samples/jax_rs for several working samples.
I am getting the following error when my deployed system sends an email.
Caused by: java.lang.NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream
....
....
Caused by: java.lang.ClassNotFoundException: com.sun.mail.util.SharedByteArrayInputStream
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass
I am using:
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.1</version>
</dependency>
This has been working for the past year and now suddenly it is throwing this exception. I have changed any of the versions of javax.mail etc.
I tried adding javax.mail:mail:jar:1.5.0 to the dependencies but when compiling I got an error saying that that jar was illegal. Maven gives the following error: Please use the correct artifact for JavaMail. You should be using com.sun.mail:javax.mail... & Found Banned Dependency: javax.mail:mail:jar:1.5.0
What seems odd to me is that javax.mail.internet.MimeMessage has the following imports:
import com.sun.mail.util.*;
import javax.mail.util.SharedByteArrayInputStream;
So it seems odd that I get this error when creating a MimeMessage in that it is trying to get com.sun.mail.util.SharedByteArrayInputStream instead of javax.mail.util.SharedByteArrayInputStream.
I know similar questions have been posted but the answers always seem to be to use javax.mail.jar which I am already using.
It sounds like you have a very old version of the javax.mail classes on your classpath somewhere. Are you sure there isn't a j2ee.jar or javaee.jar in there somewhere? Look inside all the jar files for javax.mail classes.
To solve it, you need to include the mail.jar as well, which you can get it from your JavaEE SDK folder or JavaMail API official page.
Again, to send Email via JavaMail API, you need to include both javaee.jar and mail.jar libraries.
http://repo2.maven.org/maven2/javax/mail/mail/1.4.1/mail-1.4.1.jar
http://www.oracle.com/technetwork/java/javamail/index.html
I'm trying to develop an application which uses a library with a stax-api as a dependency. Build as stand-alone application it works fine, but when I'm trying to load JAR with dependencies assembled in my application using JCL, I get the following error:
javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found
at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:178)
at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
at org.codehaus.xfire.util.STAXUtils.<clinit>(STAXUtils.java:48)
at org.codehaus.xfire.transport.http.HttpChannel.writeWithoutAttachments(HttpChannel.java:54)
at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.getByteArrayRequestEntity(CommonsHttpMessageSender.java:422)
at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.send(CommonsHttpMessageSender.java:360)
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:123)
at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
at org.codehaus.xfire.client.Client.invoke(Client.java:336)
at eu.unicore.security.xfireutil.client.ReliableProxy.handleRequest(ReliableProxy.java:122)
at eu.unicore.security.xfireutil.client.ReliableProxy.doInvoke(ReliableProxy.java:102)
at eu.unicore.security.xfireutil.client.ReliableProxy.invoke(ReliableProxy.java:69)
at com.sun.proxy.$Proxy71.QueryResourceProperties(Unknown Source)
at de.fzj.unicore.wsrflite.xmlbeans.client.BaseWSRFClient.queryResourceProperties(BaseWSRFClient.java:372)
at de.fzj.unicore.wsrflite.xmlbeans.client.RegistryClient.listServices(RegistryClient.java:199)
at de.fzj.unicore.wsrflite.xmlbeans.client.RegistryClient.listAccessibleServices(RegistryClient.java:214)
at org.caebeans.wsrf.UNICOREModule.initialize(UNICOREModule.java:53)
... 9 more
It's rather strange, this class is assembled into the JAR, I can find it in archive.
I've seen this kind of message when application server libraries are loaded before application ones. Usually there's a setting that lets you specify the inverse order. If, as it seems, you're using Weblogic this may be achieved by inserting the following definition in your weblogic.xml file:
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
Try adding this Maven dependency:
<dependency>
<groupId>stax</groupId>
<artifactId>stax</artifactId>
<version>1.2.0</version>
</dependency>
I am trying to use Apache CXF to talk to a unknown web service. I have followed the Dynamic Client example from Apache.
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Client client = factory.createClient(wsdlURL.toExternalForm(), SERVICE_NAME);
This was working but now i am getting this exception when calling createClient():
java.lang.IllegalStateException: Unable to create schema compiler
Caused by:
javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC]
This looks similar to an existing bug. I am using DOSGi singlebundle 1.2 which includes cxf-minimal-2.2.9.jar; meaning the bug should be fixed in the version I'm using. the jaxb-api is included in my Apache CXF distribution which upon inspection contains jaxb-xjc.
Can anybody provide me some insight as to what I'm doing wrong? I swear this used to work.
"java.lang.ClassNotFoundException: com/sun/tools/ " is often occurs if you use JRE in your IDE intead of JDK.
Make sure, you use JDK in IDE (e.g. eclipse)
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.11</version>
</dependency>
resolved problem
Another solution is to include the cxf-rt-core in your Maven dependencies.