I am using serialization to communicate with my server. This way My applet retrieves a JTree created in the server. In eclipse and appletViewer my applet works perfectly but when I try to launch my applet from my server I got this error on my console
java.io.InvalidClassException: javax.swing.JComponent; local class
incompatible: stream classdesc serialVersionUID = 5858390075012080263,
local class serialVersionUID = -1030230214076481435
I tried to get serialVersionUID for every class of my project with serialver but none of them have serialVersionUID = 5858390075012080263.
the error is occuring when I try to deserialize my object .
In addition to this ,the error says
java.io.InvalidClassException: javax.swing.JComponent.
How to determine the JComponent that causes this error? Is it my JTree? How can I set the serialVersionUID? By creating a class that extends this JComponent and set the serialVersionUID?
Problem solved. I have 4 different JREs on my system. It was a problem with the JVM itself not my classes. Now I use the same JRE everywhere and everything works fine .
Related
I am attempting to shave some time off my tests in Quarkus by saving off resources in static members of utilities in my test sources. Examples here being test containers and a Selenium web driver. I am saving these off so that ideally between tests/ profile changes, I can keep the same instances of these services that took a long time to instantiate.
However, it seems that when the tests re-run the test server, the static members that hold these are wiped out, thus killing the benefits I was trying to achieve.
How can I keep these static members from being wiped out, or otherwise keep some data between server instances?
Example of where I am trying to do this:
https://github.com/Epic-Breakfast-Productions/OpenQuarterMaster/blob/main/software/open-qm-base-station/src/test/java/com/ebp/openQuarterMaster/baseStation/testResources/lifecycleManagers/TestResourceLifecycleManager.java
public class TestResourceLifecycleManager implements QuarkusTestResourceLifecycleManager {
public static final String EXTERNAL_AUTH_ARG = "externalAuth";
private static MongoDBContainer MONGO_EXE = null;
private static KeycloakContainer KEYCLOAK_CONTAINER = null;
...
In this example, I realize the test resources might not get torn down as planned, but ideally that could be handled in a lifecycle event, but am still working on why the static members disappear. One step at a time.
I am creating a managed object inside App.java (which is the main class of my module). I am using guice library with dropwizard framework and getting this exception only when running with IntelliJ if I run the same code with mvn it works perfectly fine which is weird and beyond my theory. So if someone has experienced something like this or have some theory behind this then please share. feel free to ask any detail.
environment.lifecycle().manage(new Managed() {
#Override
public void start() throws Exception {
}
#Override
public void stop() throws Exception {
}
});
Exception stacktrace:-
Exception in thread "main" com.google.inject.CreationException: Unable to create injector, see the following errors:
1) Injecting into inner classes is not supported. Please use a 'static' class (top-level or nested) instead of com.phonepe.growth.App$4.
at ru.vyarus.dropwizard.guice.module.installer.InstallerModule.bindExtension(InstallerModule.java:191) (via modules: ru.vyarus.dropwizard.guice.module.GuiceSupportModule -> ru.vyarus.dropwizard.guice.module.installer.InstallerModule)
1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:470)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
at com.google.inject.Guice.createInjector(Guice.java:99)
at ru.vyarus.dropwizard.guice.injector.DefaultInjectorFactory.createInjector(DefaultInjectorFactory.java:20)
at ru.vyarus.dropwizard.guice.GuiceBundle.createInjector(GuiceBundle.java:191)
at ru.vyarus.dropwizard.guice.GuiceBundle.run(GuiceBundle.java:138)
at ru.vyarus.dropwizard.guice.GuiceBundle.run(GuiceBundle.java:93)
at io.dropwizard.setup.Bootstrap.run(Bootstrap.java:200)
at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:42)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:85)
at io.dropwizard.cli.Cli.run(Cli.java:75)
at io.dropwizard.Application.run(Application.java:79)
at com.phonepe.growth.App.main(App.java:48)
This is actually a bug in guicey classpath scan (.enableAutoConfig).
Your application class is covered by a scan and so inner classes are also visible: when you start app from idea "Managed" inner class (created by the compiler for new Managed() {...}) is detected and registered as an extension which also means registration in guice context. But guice can't instantiate the inner class and throws an error.
You can enable extra diagnostic messages with .printLifecyclePhasesDetailed() (on guice bundle) and see that additional extension is indeed appear when running from idea.
Most certainly, when you run app from maven it builds into jar first and then launched. In this case, classpath scan works a bit differently and doesn't see inner classes (inside jar).. so everything works.
Please note that you don't need to instantiate and register managed object (and other common objects) manually: you can simply declare managed as a separate class and guicey will find it and properly register (both in guice and dropwizard). This is the expected way of extensions registrations, especially together with classpath scan.
I'd like to implement my own custom ClassLoader. Basically it should do exactly what the default OSGi ClassLoader does.
I am using Karaf/Felix, so in my case that's org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader
The reason for implementing my own class loader is: I use JNI to load a DLL (with System.load()). But every time I redeploy my bundle I get a UnsatisfiedLinkError exception (Native Library xyz.dll already loaded in another classloader).
This is because the DLL is already loaded by the JVM - and stays as long as the ClassLoader that loaded it is NOT garbage collected.
So I want to do something like this:
CustomClassLoader cl = new CustomClassLoader();
Class ca = cl.findClass("myPackage.MyClass");
Object a = ca.newInstance();
Method p = ca.getMethod("myMethod");
p.invoke(a);
p = null;
ca = null;
a = null;
cl = null;
System.gc();
Hopefully after that the CustomClassLoader is garbage collected - and the DLL is unloaded from the container.
What I found strange: Even so each bundle has it's own ClassLoader, an osgi:uninstall <bundle> does not unload the DLL - which means that the bundles ClassLoader is still alive (and not garbage collected).
You also asked this question on the Apache Felix users list. My answer there was to leverage the native code mechanism that OSGi provides, as this solves your problems without you having to mess with classloaders. The mechanism provided by OSGi specifically addresses the case of updating a bundle with native code, so it should solve your problem nicely.
I have an requirement in my application to send files from one application to another over HTTP/FTP protocol. I found following link which tells that the same can be done using Active MQ with supoort of Blob messages:
activemq.apache.org/blob-messages.html
I configured ActiveMq 5.8 on my windows machine, included required dependency for ActiveMQ lib in my pom.xml and i am able to send the simple javax.jms.TextMessage and javax.jms.MapMessage with org.springframework.jms.core.JmsTemplate
But while i moved to send BlobMessage using following method, a compile time error arises while creating the BlobMessage object from javax.jms.Session object which says
The method createBlobMessage(File) is undefined for the type Session
Here is the method i am using:
public void sendFile(){
jmsTemplate.send(
new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
BlobMessage message = session.createBlobMessage(new File("/foo/bar"));
return jmsTemplate.send(message);
}
}
);
}
Please help to resolve this compile time error.
Regards,
Arun
The BlobMessage methods are not JMS spec methods so they won't appear in the javax.jms.Session interface, you need to cast to org.apache.activemq.ActiveMQSession in order to use the BlobMessage specific functionality.
I am having trouble getting started with the webdriver dart library.
I was hoping for some simple examples.
I do have the seleniumn server standalone running in the background.
I am very new to dart and very experienced with ruby and watir-webdriver.
I was expecting something similar to the code below
import 'package:webdriver/webdriver.dart';
main() {
var url = "http://google.com";
var driver = new WebDriver();
b = driver.newSession(browser:'firefox');
b.getUrl(url);
}
But the error I am getting is
Unhandled exception:
No constructor 'WebDriver' declared in class 'WebDriver'.
Looking at the source
class WebDriver extends WebDriverBase {
WebDriver(host, port, path) : super(host, port, path);
So it seems like the constructor is there; and the defaults are in the WebDriverBase to go to the remote server. What am I doing wrong? I have scoured the internet trying to find simple examples with no luck
Currently, there are known issues with local and session storage, script execution, and log access.
To use these bindings, the Selenium standalone server must be running. You can download it at http://code.google.com/p/selenium/downloads/list.
There are a number of commands that use ids to access page elements. These ids are not the HTML ids; they are opaque ids internal to WebDriver. To get the id for an element you would first need to do a search, get the results, and extract the WebDriver id from the returned Map using the 'ELEMENT' key. see http://commondatastorage.googleapis.com/dartlang-api-docs/13991/webdriver.html