Caused by: java.lang.ClassNotFoundException: Log - java

When doing a remote EJB lookup (from JBoss 4.3) in J2SE, I'm encountering the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: LLog;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2499)
at java.lang.Class.getDeclaredField(Class.java:1951)
at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1659)
at java.io.ObjectStreamClass.access$700(ObjectStreamClass.java:72)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:480)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:468)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:468)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:365)
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:602)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1622)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1706)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1344)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at java.rmi.MarshalledObject.get(MarshalledObject.java:159)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:737)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:654)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at com.example.ShoppingBasketServiceClient.main(ShoppingBasketServiceClient.java:44)
Caused by: java.lang.ClassNotFoundException: Log
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 32 more
Here is teh codez, line 44 is the one doing the lookup:
package com.example;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ShoppingBasketServiceClient {
public static void main(String[] args) throws NamingException {
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
props.setProperty("java.naming.provider.url", "jnp://localhost:1099");
String Lookup = "ejb/ShoppingBasketService/remote";
try {
InitialContext ic = new InitialContext(props);
// ShoppingBasketServiceRemote shoppingBasketService = (ShoppingBasketServiceRemote) ic.lookup(Lookup);
Object shoppingBasketService = (Object) ic.lookup(Lookup);
} catch (NamingException e) {
System.out.println("Exception:" + e);
}
}
}
I'm confused as to why it's looking for a Log class (and why the exception is not package-qualified)?
ShoppingBasketServiceRemote is just an interface that imports the javax.ejb.Remote annotation and extends another interface - neither make any reference to a Log class? Additionally, you'll see my example only casts the result to Object (but the result is the same if I swap out for the service interface)?

ShoppingBasketServiceRemote is just an interface that imports the
javax.ejb.Remote annotation and extends another interface - neither
make any reference to a Log class?
Examine all the objects referenced in the interface & their
transitive dependencies. Something will point to the "Log" class.
Also check the remote server for errors, maybe the error is on the
remote server
Try doing a simple
Class.forName("ShoppingBasketServiceRemote") - you might see it failing with the same error.
Additionally, you'll see my example only casts the result to Object
(but the result is the same if I swap out for the service interface)?
Casting the object happens after your jvm is able to load the object returned by ic.lookup(Lookup) - so the error will happen whether you cast or not.

Related

NoClassDefFoundError when trying to initialize ehcache via XML file

I have randomly this problem when I try to initialize ehcache:
Caused by: org.jboss.weld.exceptions.WeldException: WELD-000049 Unable to invoke [method] #PostConstruct private cerebro84.util.cache.CacheManagerServiceBean.initialize() on cerebro84.util.cache.CacheManagerServiceBean#3ee90439
at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:405)
at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.postConstruct(ManagedBean.java:178)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:298)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
at cerebro84.util.cache.CacheManagerServiceBean$Proxy$_$$_WeldClientProxy.getFromCache(CacheManagerServiceBean$Proxy$_$$_WeldClientProxy.java)
at cerebro84.util.cache.CacheMethodInterceptor.getResultFromCache(CacheMethodInterceptor.java:29)
...
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:168)
at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:403)
... 210 more
Caused by: java.lang.NoClassDefFoundError: net/sf/saxon/trans/XPathException
at net.sf.saxon.IdentityTransformerHandler.startDocument(IdentityTransformerHandler.java:110)
at com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader$State.<init>(DomLoader.java:83)
at com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader.startElement(DomLoader.java:118)
at com.sun.xml.bind.v2.runtime.unmarshaller.ProxyLoader.startElement(ProxyLoader.java:60)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:528)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:507)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:178)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:244)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:281)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:281)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:369)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:348)
at org.ehcache.xml.ConfigurationParser.<init>(ConfigurationParser.java:177)
at org.ehcache.xml.XmlConfiguration.parseConfiguration(XmlConfiguration.java:178)
at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:166)
at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:134)
at org.ehcache.jsr107.EhcacheCachingProvider$ConfigSupplier.getConfiguration(EhcacheCachingProvider.java:327)
at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:127)
at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:78)
at org.ehcache.jsr107.EhcacheCachingProvider.getCacheManager(EhcacheCachingProvider.java:186)
at cerebro84.util.cache.CacheManagerServiceBean.initialize(CacheManagerServiceBean.java:38)
... 220 more
The weird behavior is that if I restarted the container (weblogic), it works fine. This is the class I use to initialize the cache, trimming down to the bare essential:
import javax.annotation.PostConstruct;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.enterprise.context.ApplicationScoped;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
#Slf4j
#ApplicationScoped
public class CacheManagerServiceBean {
private static final String EHCACHE_CONFIG_FILE_PATH = "/ehcache.xml";
#Getter
private CacheManager cacheManager = null;
#Getter
private boolean cacheEnabled = false;
#PostConstruct
private void initialize() {
logger.info("Instantiating cache manager");
try {
this.cacheManager = Caching.getCachingProvider().getCacheManager(
getClass().getResource(EHCACHE_CONFIG_FILE_PATH).toURI(),
getClass().getClassLoader());
cacheEnabled = true;
} catch (Exception|NoClassDefFoundError e) {
logger.error("Unable to enable cache", e);
}
}
}
I tried to add the following line
<wls:package-name>net.sf.saxon.*</wls:package-name>
to /META-INF/weblogic-application.xml, but this did't help. Saxon is a direct dependancy of the module:
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.5.1-8</version>
</dependency>
The module is packaged as jar in a ear multimodule application.
Does anybody have any idea on how to make sure that the class XPathException is always found by saxon? Thank you in advance.
Problems like this are usually caused by having several different versions of Saxon on the classpath at the same time.

JavaFX MediaPlayer throws java.lang.reflect.InvocationTargetException

I've been trying to experiment with the JavaFX MediaPlayer class, and found the following example code in a different thread:
import java.net.URI;
import java.net.URISyntaxException;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.stage.Stage;
public class test extends Application {
#Override
public void start(Stage primaryStage)
{
//Add a scene
Group root = new Group();
Scene scene = new Scene(root, 500, 200);
URI file = null;
try {
file = new URI("/home/thomas/voodoo.mp3");
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("POOR URI SYNTAX");
}
Media pick = new Media(file.toString());
MediaPlayer player = new MediaPlayer(pick);
player.play();
//Add a mediaView, to display the media. Its necessary !
//This mediaView is added to a Pane
MediaView mediaView = new MediaView(player);
((Group)scene.getRoot()).getChildren().add(mediaView);
//show the stage
primaryStage.setTitle("Media Player");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
I adjusted the file path to point to a real audio file (/home/thomas/voodoo.mp3) and tried running it, but the console output is the following:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: uri.getScheme() == null! uri == '/home/thomas/voodoo.mp3'
at com.sun.media.jfxmedia.locator.Locator.<init>(Locator.java:211)
at javafx.scene.media.Media.<init>(Media.java:393)
at test.start(test.java:28)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$5(GtkApplication.java:139)
... 1 more
Exception running application test
Is there something wrong with my setup, or with my code?
Thanks for the help!
EDIT:
Changed to Media pick = new Media(new File("/home/thomas/voodoo.mp3").toURI().toString()); as per Nash's suggestion, but it still doesn't work. The console output is a little different now, though.
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511)
at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:414)
at test.start(test.java:20)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$5(GtkApplication.java:139)
... 1 more
Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:274)
at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:118)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:467)
... 11 more
Exception running application test
The problem is your url /home/thomas/voodoo.mp3 that is not valid, indeed the scheme is missing as described into your error message (uri.getScheme() == null! uri == '/home/thomas/voodoo.mp3'), it should start with file:// as it is a file in your local file system such that it should be file:///home/thomas/voodoo.mp3.
But since it is too error prone to build the URI as you currently do because you must ensure that it is properly URL encoded (spaces should be for example replaced with %20) and you need to provide a valid scheme, you had better to use new File(path).toURI().toString() as proposed by Nash.
Try
Media pick = new Media(new File("/home/thomas/voodoo.mp3").toURI().toString());

Documents4j IllegalStateException

im trying to use documents4j (https://bintray.com/raphw/maven/documents4j) in order to convert a docx file to pdf with this code:
Thank you very much in advance, i have no idea of making it works
package documents4j;
import java.io.File;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import com.documents4j.api.DocumentType;
import com.documents4j.api.IConverter;
import com.documents4j.job.LocalConverter;
public class HelloPDF {
public static void main(String[] args) {
File wordFile = new File("c:/datos/Resultados.docx"), target = new File("c:/datos/Resultados.pdf");
IConverter converter = LocalConverter.builder().baseFolder(new File("c:/datos/"))
.workerPool(20, 25, 2, TimeUnit.SECONDS)
.processTimeout(5, TimeUnit.SECONDS).build();
Future<Boolean> conversion = converter.convert(wordFile).as(DocumentType.DOCX).to(target).as(DocumentType.PDF)
// .prioritizeWith(1000) // optional
.schedule();
}
}
But im encountering an illegalstateexcepcion
Exception in thread "main" java.lang.IllegalStateException: class com.documents4j.conversion.msoffice.MicrosoftWordBridge could not be created by a (File, long, TimeUnit) constructor
at com.documents4j.conversion.ExternalConverterDiscovery.make(ExternalConverterDiscovery.java:32)
at com.documents4j.conversion.ExternalConverterDiscovery.makeAll(ExternalConverterDiscovery.java:42)
at com.documents4j.conversion.ExternalConverterDiscovery.loadConfiguration(ExternalConverterDiscovery.java:85)
at com.documents4j.conversion.DefaultConversionManager.<init>(DefaultConversionManager.java:22)
at com.documents4j.job.LocalConverter.makeConversionManager(LocalConverter.java:79)
at com.documents4j.job.LocalConverter.<init>(LocalConverter.java:51)
at com.documents4j.job.LocalConverter$Builder.build(LocalConverter.java:186)
at documents4j.HelloPDF.main(HelloPDF.java:20)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.documents4j.conversion.ExternalConverterDiscovery.make(ExternalConverterDiscovery.java:30)
... 7 more
Caused by: java.lang.NoClassDefFoundError: com/documents4j/util/Reaction$IExceptionBuilder
at com.documents4j.conversion.msoffice.AbstractMicrosoftOfficeBridge.tryStart(AbstractMicrosoftOfficeBridge.java:34)
at com.documents4j.conversion.msoffice.MicrosoftWordBridge.startUp(MicrosoftWordBridge.java:44)
at com.documents4j.conversion.msoffice.MicrosoftWordBridge.<init>(MicrosoftWordBridge.java:39)
... 12 more
Caused by: java.lang.ClassNotFoundException: com.documents4j.util.Reaction$IExceptionBuilder
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 15 more
[Shutdown hook: com.documents4j.job.LocalConverter] INFO com.documents4j.job.ConverterAdapter - Tried to deregister shut down hook in shut down period
java.lang.IllegalStateException: Shutdown in progress
at java.lang.ApplicationShutdownHooks.remove(ApplicationShutdownHooks.java:82)
at java.lang.Runtime.removeShutdownHook(Runtime.java:237)
at com.documents4j.job.ConverterAdapter.deregisterShutdownHook(ConverterAdapter.java:121)
at com.documents4j.job.ConverterAdapter.cleanUp(ConverterAdapter.java:107)
at com.documents4j.job.ConverterAdapter.shutDown(ConverterAdapter.java:98)
at com.documents4j.job.LocalConverter.shutDown(LocalConverter.java:109)
at com.documents4j.job.ConverterAdapter$ConverterShutdownHook.run(ConverterAdapter.java:134)
Exception in thread "Shutdown hook: com.documents4j.job.LocalConverter" java.lang.NullPointerException
at com.documents4j.job.LocalConverter.shutDown(LocalConverter.java:100)
at com.documents4j.job.ConverterAdapter$ConverterShutdownHook.run(ConverterAdapter.java:134)
Ok, i have found the answer. The problem was that i have not all the libraries included, i add:
documents4j-util-all-1.0.3
documents4j-util-standalone-1.0.3
And it finally works

"duplicate class definition bug occured" using jaxb in jboss

I'm using jaxb inside a jboss 5.0.1GA container, and seeing a strange exception at startup. It appears once only.
From the stacktrace you can see that it is during the class initialisation of FrameworkUtil class.
FrameworkUtil line 119 looks like this:
JAXBContext j = JAXBContext.newInstance(Validate.class, Response.class ....<more classes>);
Validate.java has this in it:
#XmlRootElement(name="validate")
public class Validate {
List<String> userGroups;
#XmlElementWrapper(name="userGroups")
#XmlElement(name="item")
public String[] getUserGroups() {
if (userGroups != null) {
return userGroups.toArray(new String[userGroups.size()]);
}
else return null;
}
public void setUserGroups(String[] userGrps) {
userGroups = new ArrayList<String>();
if (userGrps != null) {
for (String userGrp : userGrps) {
userGroups.add(new String(userGrp));
}
}
}
}
In the stack trace is a reference to Validate. But sometimes the stacktrace is different, and refers to the same field (userGroups) in Response.class instead.
Here's the stack trace:
Mar 19, 2015 11:20:50 AM com.sun.xml.bind.v2.runtime.reflect.opt.Injector inject
WARNING: duplicate class definition bug occured? Please report this : com/mycompany/ecommerce/message/beans/Validate$JaxbAccessorM_getUserGroups_setUserGroups_[Ljava_lang_String;
java.lang.ClassFormatError: Illegal class name "com/mycompany/ecommerce/message/beans/Validate$JaxbAccessorM_getUserGroups_setUserGroups_[Ljava_lang_String;" in class file com/mycompany/ecommerce/messa
ge/beans/Validate$JaxbAccessorM_getUserGroups_setUserGroups_[Ljava_lang_String;
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at sun.reflect.GeneratedMethodAccessor209.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:205)
at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:85)
at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:89)
at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:114)
at com.sun.xml.bind.v2.runtime.reflect.Accessor$GetterSetterReflection.optimize(Accessor.java:369)
at com.sun.xml.bind.v2.runtime.property.ArrayProperty.<init>(ArrayProperty.java:65)
at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.<init>(ArrayERProperty.java:84)
at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.<init>(ArrayElementProperty.java:96)
at com.sun.xml.bind.v2.runtime.property.ArrayElementLeafProperty.<init>(ArrayElementLeafProperty.java:66)
at sun.reflect.GeneratedConstructorAccessor172.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.sun.xml.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:124)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:179)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:515)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:330)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:432)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at com.mycompany.global.er.util.FrameworkUtil.<clinit>(FrameworkUtil.java:119)
Did you check this bug out ?
Seems to be fixed in version 2.2.11 of jaxb implementation.
Maybe you could try and replace jaxb JAR files, they're probably in you server's lib, unless your webapp overwrites them in it's own lib folder.
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>

Gdata API blogger example

I'm having trouble running this sample code for the gdata java library:
import java.net.URL;
import com.google.gdata.client.Query;
import com.google.gdata.client.blogger.BloggerService;
import com.google.gdata.data.Feed;
public class AccessBloggerSample {
public static void main(String[] args) throws Exception {
BloggerService service = new BloggerService("Testing-Blogger");
service.setUserCredentials("tmerachli#gmail.com", "XXX");
System.out.println("Google: " + BloggerService.getVersion());
URL feedUrl = new URL("http://minhchaunyc.blogspot.com/feeds/posts/default ");
Query query = new Query(feedUrl);
System.out.println("service: ");
Feed resultFeed = service.getFeed(query, Feed.class);
System.out.println("blogs: " + resultFeed.getEntries().size());
}
}
And I get the following error:
java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:555)
at AccessBloggerSample.main(AccessBloggerSample.java:23)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:555)
at AccessBloggerSample.main(AccessBloggerSample.java:23)
at __SHELL0.run(__SHELL0.java:6)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at bluej.runtime.ExecServer$3.run(ExecServer.java:724)`
Any ideas why I'm getting this? I'm compiling and running my code through BlueJ and I extracted all the jar files into the lib directory of BlueJ and the code compiles.
You need to add guava to your Java Build-Patproject: http://code.google.com/p/guava-libraries/

Categories