Class not found in library project using reflection - java

I'm adding a library project(.aar) file into DemoProject where library project internally uses reflection.
But DemoProject shows classNotFoundfor the reflection classes.
Stacktrace.
Suppressed: java.lang.ClassNotFoundException: com.coderconsole.phoneUtils
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Code:
try {
return Class.forName("com.coderconsole.phoneUtils");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
The exception is thrown when using within libraryproject else its working fine.
Any help is highly appreciated.

Related

ESAPI - Getting ClassNotFoundException with ESAPI 2.2.3.1

My Code was working with org.owasp.esapi 2.2.0.0 but after upgrading to 2.2.3.1 I am getting ClassNotFoundException.
My Code is something like:
Properties esapiProps = new Properties();
try {
esapiProps.load( SecurityUtil.class.getResourceAsStream("/ESAPI.properties") );
} catch (IOException | NullPointerException e) {
logger.log(Level.SEVERE, "esapi Exception: ", e);
}
ESAPI.override( new DefaultSecurityConfiguration(esapiProps));
// ----- Then canonicalize an input -----
ESAPI.encoder().canonicalize(input);
I read the release notes and added some properties and esapi-java-logging
my ESAPI.properties (in class path)
ESAPI.printProperties=true
LogLevel=INFO
ESAPI.Encoder=org.owasp.esapi.reference.DefaultEncoder
Encoder.AllowMultipleEncoding=false
Encoder.AllowMixedEncoding=false
Encoder.DefaultCodecList=HTMLEntityCodec,PercentCodec,JavaScriptCodec
ESAPI.Logger=org.owasp.esapi.reference.JavaLogFactory
Logger.ApplicationName=My Test Application
Logger.LogEncodingRequired=false
Logger.LogApplicationName=true
Logger.LogServerIP=true
Logger.LogFileName=ESAPI_logging_file
Logger.MaxLogFileSize=10000000
Logger.UserInfo=true
Logger.ClientInfo=true
my esapi-java-logging.properties (in class path)
handlers= java.util.logging.ConsoleHandler
.level= INFO
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] [%3$-7s] %5$s %n
but I get this exception:
[ERROR ] SRVE0315E: An exception occurred: java.lang.Throwable: org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5095)
at [internal classes]
Caused by: org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:129)
at org.owasp.esapi.ESAPI.encoder(ESAPI.java:101)
.
.
.
at sun.reflect.GeneratedMethodAccessor521.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:63)
... 1 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor522.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:86)
... 8 more
Caused by: org.owasp.esapi.errors.ConfigurationException: java.lang.ClassNotFoundException: org.owasp.esapi.reference.JavaLogFactory LogFactory class (org.owasp.esapi.reference.JavaLogFactory) must be in class path.
... 17 more
Caused by: java.lang.ClassNotFoundException: org.owasp.esapi.reference.JavaLogFactory
at com.ibm.ws.classloading.internal.AppClassLoader.findClassCommonLibraryClassLoaders(AppClassLoader.java:569)
at [internal classes]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.owasp.esapi.util.ObjFactory.loadClassByStringName(ObjFactory.java:158)
at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:81)
... 15 more
If I change my ESAPI.properties and copy what is in https://raw.githubusercontent.com/ESAPI/esapi-java-legacy/develop/configuration/esapi/ESAPI.properties, ClassNotFoundException goes away and I get NullPointerException exception:
[ERROR ] SRVE0315E: An exception occurred: java.lang.Throwable: org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5095)
at [internal classes]
Caused by: org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:129)
at org.owasp.esapi.ESAPI.encoder(ESAPI.java:101)
.
.
.
at sun.reflect.GeneratedMethodAccessor522.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:63)
... 1 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor523.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:86)
... 8 more
Caused by: java.lang.ExceptionInInitializerError
... 20 more
Caused by: java.lang.NullPointerException
... 22 more
You said that you read the release notes. The reason for your problem is a detail that you missed that was documented there. Look in those release notes, in the section labeled:
*** IMPORTANT WORKAROUND for 2.2.1.0 ESAPI Logging ***
There, it states:
Lastly, if you try to use the new ESAPI 2.2.1.0 logging, you will notice that you need to change ESAPI.Logger and also possibly provide some other logging properties as well. This is because the logger packages were reorganized to improve maintainability, but we failed to mention it. To use ESAPI logging in ESAPI 2.2.1.0 (and later), you MUST set the ESAPI.Logger property to one of:
org.owasp.esapi.logging.java.JavaLogFactory - To use the new default, java.util.logging (JUL)
org.owasp.esapi.logging.log4j.Log4JLogFactory - To use the end-of-life Log4J 1.x logger
org.owasp.esapi.logging.slf4j.Slf4JLogFactory - To use the new (to release 2.2.0.0) SLF4J logger
Between that and a careful reading of your exception stack trace:
... deleted...
Caused by: org.owasp.esapi.errors.ConfigurationException: java.lang.ClassNotFoundException: org.owasp.esapi.reference.JavaLogFactory LogFactory class (org.owasp.esapi.reference.JavaLogFactory) must be in class path.
... 17 more
Caused by: java.lang.ClassNotFoundException: org.owasp.esapi.reference.JavaLogFactory
...deleted...
I think that should explain the reason. Those classes were reorganized to different packages to accommodate SLF4J logging.
There is some typo with logger factory config in ESAPI.properties. The classes are in org.owasp.esapi.logging.*.
#ESAPI.Logger=org.owasp.esapi.logging.log4j.Log4JLogFactory
#ESAPI.Logger=org.owasp.esapi.logging.slf4j.Slf4JLogFactory
ESAPI.Logger=org.owasp.esapi.logging.java.JavaLogFactory

ResourceAwareScheduler is not found in Storm 2.1.0

I am using Storm 2.1.0 and would like to use the Resource Aware Scheduler. I followed instructions from the documentation and added the following line to my conf/storm.yaml:
storm.scheduler: “org.apache.storm.scheduler.resource.ResourceAwareScheduler”
But when I execute ./bin/storm nimbus it crashes and I can see the following log in logs/nimbus.log:
2020-06-25 16:02:09.962 o.a.s.d.n.Nimbus main [INFO] Using custom scheduler: “org.apache.storm.scheduler.resource.ResourceAwareScheduler”
2020-06-25 16:02:09.963 o.a.s.u.Utils main [ERROR] Received error in thread main.. terminating server...
java.lang.Error: java.lang.RuntimeException: java.lang.ClassNotFoundException: “org.apache.storm.scheduler.resource.ResourceAwareScheduler”
at org.apache.storm.utils.Utils.handleUncaughtException(Utils.java:653) ~[storm-client-2.1.0.jar:2.1.0]
at org.apache.storm.utils.Utils.handleUncaughtException(Utils.java:632) ~[storm-client-2.1.0.jar:2.1.0]
at org.apache.storm.utils.Utils.lambda$createDefaultUncaughtExceptionHandler$2(Utils.java:1014) ~[storm-client-2.1.0.jar:2.1.0]
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1057) [?:1.8.0_252]
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1052) [?:1.8.0_252]
at java.lang.Thread.dispatchUncaughtException(Thread.java:1959) [?:1.8.0_252]
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: “org.apache.storm.scheduler.resource.ResourceAwareScheduler”
at org.apache.storm.utils.ReflectionUtils.newInstance(ReflectionUtils.java:48) ~[storm-client-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.makeScheduler(Nimbus.java:658) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.<init>(Nimbus.java:569) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.<init>(Nimbus.java:474) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.<init>(Nimbus.java:468) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.launchServer(Nimbus.java:1307) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.launch(Nimbus.java:1332) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.main(Nimbus.java:1337) ~[storm-server-2.1.0.jar:2.1.0]
Caused by: java.lang.ClassNotFoundException: “org.apache.storm.scheduler.resource.ResourceAwareScheduler”
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_252]
at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_252]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) ~[?:1.8.0_252]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_252]
at java.lang.Class.forName0(Native Method) ~[?:1.8.0_252]
at java.lang.Class.forName(Class.java:264) ~[?:1.8.0_252]
at org.apache.storm.utils.ReflectionUtils.newInstance(ReflectionUtils.java:46) ~[storm-client-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.makeScheduler(Nimbus.java:658) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.<init>(Nimbus.java:569) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.<init>(Nimbus.java:474) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.<init>(Nimbus.java:468) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.launchServer(Nimbus.java:1307) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.launch(Nimbus.java:1332) ~[storm-server-2.1.0.jar:2.1.0]
at org.apache.storm.daemon.nimbus.Nimbus.main(Nimbus.java:1337) ~[storm-server-2.1.0.jar:2.1.0]
I understand that the class is not found but wasn't expecting this. I just downloaded the latest version of Storm from their official website (binary version), I checked on the source code if the class exists (it does), Zookeeper is up and running, and I followed the given instruction to enable this scheduler. I probably forgot something but I totally don't know what.
But anyway, let's continue this investigation. In Nimbus.java it initializes the scheduler:
private static IScheduler makeScheduler(Map<String, Object> conf, INimbus inimbus) {
String schedClass = (String) conf.get(DaemonConfig.STORM_SCHEDULER);
IScheduler scheduler = inimbus == null ? null : inimbus.getForcedScheduler();
if (scheduler != null) {
LOG.info("Using forced scheduler from INimbus {} {}", scheduler.getClass(), scheduler);
} else if (schedClass != null) {
LOG.info("Using custom scheduler: {}", schedClass);
scheduler = ReflectionUtils.newInstance(schedClass);
} else {
LOG.info("Using default scheduler");
scheduler = new DefaultScheduler();
}
return scheduler;
}
The following log tells me that it's trying to get the correct scheduler:
... Nimbus main [INFO] Using custom scheduler: “org.apache.storm.scheduler.resource.ResourceAwareScheduler”
An then, it calls ReflectionUtils.newInstance() which is implemented in ReflectionUtils.java:
public static <T> T newInstance(String klass) {
try {
return newInstance((Class<T>) Class.forName(klass));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Exception seems to be raised from here because it is not able to find the class ResourceAwareScheduler. I double checked and the class exist at the given location. At this stage I got to admit that it reaches my knowledge of Java. Am I suppose to manually import this class in ReflectionUtils.java? It has the full path to the class, so I suppose it is not necessary. How should I configure this Maven project to include this class?
Any help with this will be gladly appreciated.
I finally found the problem. There is a difference between:
storm.scheduler: “org.apache.storm.scheduler.resource.ResourceAwareScheduler”
and
storm.scheduler: "org.apache.storm.scheduler.resource.ResourceAwareScheduler"
Even the highlighting for code from StackOverflow should have helped me. I feel stupid. It's a gentle reminder that copy-pasting, even from official documentation, is bad! Hope this will help other bros.

Attach an agent remotely using Bytebuddy

I am trying to attach an agent for a process using bytebuddy .I found that we can use ByteBuddyAgent.attach(file,"18467"); for this. But when i am trying to do this following errors occurring.
This is agent i used
File file = (new File("Agent.jar"));
Error
java.lang.IllegalStateException: Error during attachment using: net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound#e26db604
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:378)
at net.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:227)
at net.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:202)
at net.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:189)
at common.netty.echo.EchoHttpServer.main(EchoHttpServer.java:95)
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 net.bytebuddy.agent.Attacher.install(Attacher.java:77)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:373)
... 4 more
Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
... 10 more
Any idea for this ? and When i try to use this attachment from another agent as follows
public class Agent {
public static void premain(String args, Instrumentation instrumentation) {
System.out.println("Premain");
File file ;
try {
file = (new File("Agent.jar"));
ByteBuddyAgent.attach(file,"18467");
}
catch (Exception e)
{
e.printStackTrace();
}
}
I am getting this error
Error
java.lang.IllegalStateException: Error during attachment using: net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound#423f0955
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:378)
at net.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:227)
at net.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:202)
at net.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:189)
at common.netty.echo.Agent.premain(Agent.java:111)
at common.netty.echo.EchoHttpServer.<clinit>(EchoHttpServer.java:56)
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 net.bytebuddy.agent.Attacher.install(Attacher.java:77)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:373)
... 5 more
Caused by: java.lang.UnsatisfiedLinkError: Native Library /usr/lib/jvm/java-8-oracle/jre/lib/amd64/libattach.so already loaded in another classloader
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1907)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at sun.tools.attach.LinuxVirtualMachine.<clinit>(LinuxVirtualMachine.java:342)
at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
... 11 more
Any suggestion on this!!
As for the first error message: does the target VM run the attachment listener? You can try to force starting the thread by setting -XX:+StartAttachListener which should be set by default. What JVM version are you running?
The other error message indicates that the attachment library was already loaded by another class loader. See this answer for further details: java.lang.UnsatisfiedLinkError: Native Library XXX.so already loaded in another classloader

Facebook Login Android SDK ClassNotFoundException: com.facebook.gdp.LightWeightLoginParameters

The app works in debug, but it crashes in a loop in release mode. The app is not crashing, the Facebook dialog is.
I'm not using facebook's LoginButton, but just a normal button and then registering callback with the LoginManager.
I have tried minifyEnabled false
I searched google and haven't seen anyone else with the same class missing.
I'm using 4.27.0 of the SDK.
12-02 00:32:50.429 3720-4954/? E/Parcel: Class not found when unmarshalling: com.facebook.gdp.LightWeightLoginParameters
java.lang.ClassNotFoundException: com.facebook.gdp.LightWeightLoginParameters
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at android.os.Parcel.readParcelableCreator(Parcel.java:2517)
at android.os.Parcel.readParcelable(Parcel.java:2471)
at android.os.Parcel.readValue(Parcel.java:2374)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2727)
at android.os.BaseBundle.unparcel(BaseBundle.java:269)
at android.os.BaseBundle.getString(BaseBundle.java:992)
at android.content.Intent.getStringExtra(Intent.java:6702)
at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:336)
at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1094)
at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5822)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:5627)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:176)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3612)
at android.os.Binder.execTransact(Binder.java:573)
Caused by: java.lang.ClassNotFoundException: com.facebook.gdp.LightWeightLoginParameters
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:1346)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:1406)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:400) 
at android.os.Parcel.readParcelableCreator(Parcel.java:2517) 
at android.os.Parcel.readParcelable(Parcel.java:2471) 
at android.os.Parcel.readValue(Parcel.java:2374) 
at android.os.Parcel.readArrayMapInternal(Parcel.java:2727) 
at android.os.BaseBundle.unparcel(BaseBundle.java:269) 
at android.os.BaseBundle.getString(BaseBundle.java:992) 
at android.content.Intent.getStringExtra(Intent.java:6702) 
at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:336) 
at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1094) 
at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5822) 
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:5627) 
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:176) 
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3612) 
at android.os.Binder.execTransact(Binder.java:573) 
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
12-02 00:32:50.429 3720-4954/? W/Bundle: Failed to parse Bundle, but defusing quietly
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.facebook.gdp.LightWeightLoginParameters
at android.os.Parcel.readParcelableCreator(Parcel.java:2545)
at android.os.Parcel.readParcelable(Parcel.java:2471)
at android.os.Parcel.readValue(Parcel.java:2374)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2727)
at android.os.BaseBundle.unparcel(BaseBundle.java:269)
at android.os.BaseBundle.getString(BaseBundle.java:992)
at android.content.Intent.getStringExtra(Intent.java:6702)
at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:336)
at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1094)
at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5822)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:5627)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:176)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3612)
at android.os.Binder.execTransact(Binder.java:573)
I was facing same kind of error and finally somehow got to know that my app was not properly live on facebook developer console.
For further assistance visit this link https://stackoverflow.com/a/26135600/1925394

Unable to create a connection pool in Java + MySQL + Vibur-dbcp

I am trying to create a conection pool whit vibur-dbcp for an app for desktop in JavaFX , i got a MySQL database in AWS and works great when i connect from Workbench butt when i connect from the app the response time increments, i check my code and the reason is because the app creates to many connections creating to much overheat (firts the app have a embedded SQLite databese and the conections weren't a problem) i remake the estructure of my code butt i still need to make alot of conections.
looking for a solution i find that conection pool is the way, i find a good number of solutions Apache commons, C3P0, HikariCP and Vibur DBCP i try to use all but at the moment i can't make one to work, i look for a tutorial but i only can find old implementations (Java 6 or older) for servlets and only snippets and all are very confusing for me (im a begginer in DB), my favorite option is HikariCP but i can make the pool to work, my next option is Vibur at the moment i have this code for the conection.
private Connection connection;
//creates the pool
public DataSource createDataSourceWithStatementsCache() {
ViburDBCPDataSource ds = new ViburDBCPDataSource();
ds.setJdbcUrl("dbURL");
ds.setUsername("dbUser");
ds.setPassword("dbPass");
ds.setPoolInitialSize(10);
ds.setPoolMaxSize(100);
ds.setConnectionIdleLimitInSeconds(30);
ds.setTestConnectionQuery("isValid");
ds.setLogQueryExecutionLongerThanMs(500);
ds.setLogStackTraceForLongQueryExecution(true);
ds.setStatementCacheMaxSize(200);
ds.start();
return ds;
}
//Getts the conection
public Connection conectarBD(){
try {
connection = createDataSourceWithStatementsCache().getConnection();
} catch (SQLException ex) {
Logger.getLogger(coneccionBD.class.getName()).log(Level.SEVERE, null, ex);
}
return connection;
}
public void desconectarBD(){
try {
connection.close();
} catch (SQLException ex) {
Logger.getLogger(coneccionBD.class.getName()).log(Level.SEVERE, null, ex);
}
}
i get this error
Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: org/vibur/objectpool/listener/Listener
at HE.MVC.Modelo.Laboratoriales.Conexion.createDataSourceWithStatementsCache(Conexion.java:36)
at HE.MVC.Modelo.Laboratoriales.Conexion.conectarBD(Conexion.java:63)
at HE.MVC.Modelo.MedicamentosAbituales.cargaTabla(MedicamentosAbituales.java:186)
at HE.MVC.Vistas.Paciente.NuevopacienteController.iniciaTablas(NuevopacienteController.java:351)
at HE.MVC.Vistas.Paciente.NuevopacienteController.initialize(NuevopacienteController.java:1156)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at HE.HEstadistica.LanzaNuevoPaciente(HEstadistica.java:304)
at HE.MVC.Vistas.Paciente.EscenaPacientesController$7$1.run(EscenaPacientesController.java:347)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.vibur.objectpool.listener.Listener
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 17 more
what im asking is two things
1.- what i making wrong in this code?.
2.- is there a book, manual, page o videos for learning conecction pool (HikariCP explanation for begginers it would be wonderful) where i can learn how to make this work?
#CorrOrtiz, regarding your first question, what #hotzst suggests in his comment below your question is correct. For Vibur DBCP there are two jar files that you need as dependencies for your application: vibur-dbcp-9.0.jar and vibur-object-pool-9.0.jar. The exception that you're getting means that you're most likely missing the second dependency, although if you've added the vibur-dbcp dependency via Maven then you should have transitively got the second dependency, too.

Categories