caused by:java.lang.NoClassDefRoundError:com/mchange/v2/ser/indirector - mysql

When I try to use c3p0 to test a mysql database connection, Eclipse shows the following error:
caused by:java.lang.NoClassDefFoundError:com/mchange/v2/ser/indirector,
I googled and was unable to find an answer.
Could anyone help me? I am a java rookie, thanks!

First, make sure that your project is properly loading mchange-commons-java, where the stuff you are com.mchange.v2.ser.* lives. It is a transitive dependency of c3p0.
Hopefully you are using c3p0-0.9.5. Try changing the c3p0 config param contextClassLoaderSource to library to avoid some ClassLoader confusions.

I think you are only placing c3p0 jar in tomcat lib.
If you copy mchange-commons-java jar also than this issue will be resolved.

I have the same problem. And I am using IntelliJ IDEA. Perhaps you can fix it by follow steps:
Add c3p0 and mchange-commons-java to your 'libs' folder and add them
as 'Library';
Open 'File->Project Structure->Project
Settings->Artifacts', then find c3p0-* and mchange-commons-java in
the 'Available Elements', and 'Extract Into Output Root'.
Then
build artifacts again.

In my case I was missing mchange-commons-java-0.2.11 (use your version) jar that contained the com/mchange/v2/ser/indirector class. We need this and c3p0-0.9.5.2 jars to be kept in app/WEB-INF/lib directory.
Just adding that worked!!!

Related

The "GenerateDepsFile" task failed unexpectedly

I tried to compile my new application in MonoDevelop and I got this error:
/usr/share/dotnet/sdk/2.2.203/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(5,5): Error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
System.TypeLoadException: Could not load type of field 'Microsoft.NET.Build.Tasks.DependencyContextBuilder:_filteredPackages'
(12) due to: Could not resolve type with token 01000027 from typeref
(expected class 'NuGet.Packaging.Core.PackageIdentity' in assembly
'NuGet.Packaging, Version=5.0.0.6, Culture=neutral,
PublicKeyToken=31bf3856ad364e35') assembly:NuGet.Packaging,
Version=5.0.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35
type:NuGet.Packaging.Core.PackageIdentity member:(null)
at Microsoft.NET.Build.Tasks.TaskBase.Execute () [0x00000] in :0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00029] in <58f0218f988743a48dd7c84cbe933f4e>:0
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6]
in <58f0218f988743a48dd7c84cbe933f4e>:0 (MSB4018) (passcracker)
I cannot compile any application. Please help.
I had the same problem using .Net Standard 2.1, and I solved it for myself by cleaning the solution and then rebuilding it.
Just moved my projects to a new machine (copying, not pulling from GIT) and started getting this. Deleting the bin and obj folders in each project solved this issue.
Your combination of Mono MSBuild and .NET Core SDK is incompatible because they use different versions of the internal NuGet library. To resolve this problem, you can:
Downgrade .NET Core SDK to 2.1.5xx or 2.2.1xx (for example, 2.1.505 or 2.2.108)
Upgrade Mono to 6.0
You can find a detailed explanation of this problem and possible solutions here: https://rider-support.jetbrains.com/hc/en-us/articles/360004180039
This appears to be a known issue.
The only fix at this stage seems to be to downgrade to .NET Core v2.2.105.
To downgrade:
Uninstall the latest .NET Core version (v2.2.2+).
Download and install v2.2.105.
Run the following CMD in the *.sln folder. This will delete all your OBJ and BIN folders automatically. And your issue will be solved.
FOR /d /r . %%d in (bin,obj) DO ( IF EXIST "%%d" ( ECHO %%d | FIND /I "\node_modules\" > Nul && ( ECHO.Skipping: %%d ) || ( ECHO.Deleting: %%d rd /s/q "%%d" )))
I had the same problem in migration from .Net Framework 4.5 to .NET 6.0 (with the 70 project).
All of the above answers are correct, but they were not enough for my problem.
I use this answer:
Deleting the bin and obj and .vs folders then Clean Solution and
Rebuild Solution
it's working in Build Mode, not Rebuild. And the problem remained.
I update the Version of SDK , but not enough and I have the problem.
I realized this:
duplicate property (or variables) with the same name (or similar Name) in derived classes.
It was a good solution and a few problems were solved.
finally (after the 3 days), The biggest problem I noticed was that I had Loop References.
I fixed The Loop References in projects and the error is solved.
Change the name of the file. For instance, Add prefix _ or #; so, it cannot be used.
Restart Visual Studio, then try to build. If still problem is there, needs to restart the machine.
I had this error happen and the slove for me was correcting the Package version number in .csproj file .
<Version>2.0.7.</Version> <!--casued the error-->
<Version>2.0.7</Version> <!--this fixed the error-->
Removing the trailing '.' fixed this for me.
I had .net standard project built on .net standard 2.0. Yesterday I updated my Visual Studio 2019 to 16.3.0 to leverage .Net Core 3.0. But all of sudden build of project targeting on standard 2.0 started throwing "GenerateDepsFile" task failed unexpectedly error.
I was able to resolve this issue by changing the target framework to 2.1.
If you have <DelaySign>false</DelaySign> in your .csproj file remove it to solve this Problem.
in vs code i got this error, after trying some solution from forms, i found solution in deleting bin and obj foldersfrom project and build again.
this solved my problem.
vs code version: 1.53.1
dotnet version : 5
I had it after updating vs 2019 community,
Delete bin & obj folders,
then clean & build the solution.
I had this error and after reading comments, I was able to resolve by combining comments - First deleted bin folder, obj folder, executed clean command, deleted enter image description here and then rebuilded.

JDBC driver not found error in monkeyrunner/jython

I need to Insert something in the DB. im using JDBC as a connector, jython the script, mysql the DB and the script is running in CentOS.
my code looks something like this:
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
from com.ziclix.python.sql import zxJDBC
db=zxJDBC.connect("jdbc:mysql://XXX.XXX.XXX.XXX:3306/dbname","USER","PASSWORD","org.gjt.mm.mysql.Driver")
c=db.cursor() c.execute("INSERT INTO tablename values ('X','X','X')")
before that, I downloaded and decompressed the file from here (in the desktop)
I added the path to classpath by doing this
export PATH=/home/XX/Desktop/mysql-connector-java-5.1.22
and when I ran the script, it gave me this error
zxJDBC.DatabaseError.driver [org.gjt.mm.mysql.Driver] not found
what have I done wrong? is the name of the driver name correct? because I just copied it in one of the tutorials that I've seen. or probably did I install the driver correctly?
Thanks.
this is how I managed to solve the error:
Download the JDBC driver here
Extract the tar.gz file anywhere you want.
You will find mysql-connector-java-5.1.22-bin.jar inside that folder. Copy that and paste to (in my case) /%android-sdk%/tools/lib
Add the new location of mysql-connector-java-5.1.22-bin.jar to classpath
do the script like this
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice,
MonkeyImage
from com.ziclix.python.sql import zxJDBC
db=zxJDBC.connect("jdbc:mysql://XXX.XXX.XXX.XXX:3306/dbname","USER","PASSWORD","com.mysql.jdbc.Driver")
c=db.cursor()
c.execute("INSERT INTO tablename values ('X','X','X')")
db.commit()
Hope this helps to those who will need it in the future. :)
How are you running jython? If you're using the standalone install, i.e. java -jar jython.jar, then from the Java Documentation ...
-jar
When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.
... you can't add anything to the classpath. Repackaging the required classes into the jython jar is one approach or this answer has an alternative solution - basically add the jython.jar to the classpath too (either using -cp or CLASSPATH) and run the org.python.util.jython class directly.
I got the sample problem in windows7,I slove this problem by this:
download the JDBC driver
add the mysql-connector-java-ver-bin.jar to envionment variables:
such as:
CLASSPATH : C:\xxx-path\mysql-connector-java-5.1.41-bin.jar
then I slove this problem

Hudson | NullPointerException while loading jobs

We are using hudson version 2.0.0.
Few days back after restarting hudson, i found that some of the jobs were missing.
Found that its due to the following NPE.
Dec 9, 2011 11:39:34 AM hudson.model.Hudson$5 onTaskFailed
SEVERE: Failed Loading job ABC
java.lang.NullPointerException
at hudson.model.Project.createTransientActions(Project.java:206)
at hudson.model.AbstractProject.updateTransientActions(AbstractProject.java:627)
at hudson.model.AbstractProject.onLoad(AbstractProject.java:287)
at hudson.model.Project.onLoad(Project.java:87)
at hudson.model.Items.load(Items.java:109)
at hudson.model.Hudson$13.run(Hudson.java:2376)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
at hudson.model.Hudson$4.runTask(Hudson.java:707)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTaskThreadPoolExecutor.java
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Upgrading to 2.1.2 didnt help. I removed all the plugins and re-installed, but in vain.
Has anybody else faced this?
Thanks,
Gayathri
OK I found the problem.
To fix this issue, I had to add the line that contains <publishers/> to each config.xml file in projects that failed to load (towards the end of XML file):
</builders>
<buildWrappers/>
<publishers/>
</project>
Somehow without this, Hudson/Jenkins barfs and hides in the corner crying.
Jobs will go missing from the dashboard when there is a parse error in the config.xml.
You can inspect these errors in Hudson / Manage Hudson / System Log looking for
Caused by: com.thoughtworks.xstream.converters.ConversionException: Could not call hudson.scm.CVSSCM.readResolve() : null :
It means the auto parameter migration failed and you have to edit the config.xml in the Jobs root by hand, the debug information in the log provides the offending line number. Commenting out the item usually works. Sometimes manual reconfiguring is needed.
Jobs will go missing from the history between restarts when the file build.xml is not generated in the build/<jobref> directory. If there is an exception in any plugin, it may cause the creation of this file to be skipped, and it will not show in history after a restart. Again looking in the log using Hudson / Manage Hudson / System Log is the quickest way to find the offending plugin. Disabling usually resolves the problem.
Please note that searching for "Missing Hudson Builds" will point to many different plugins/versions that all cause this problem. You should look in YOUR log to find what is causing the problem in YOUR installation, and only disabling the plugin that is causing YOUR problem.
A warning about "failed to generate build.xml" would save a lot of hours. I should open a bug on that.

Connecting a MySQL database to Glassfish classpath is not set or classname is wrong

I'm swapping out a derby database for a MySQL one. I had everything working before but after what I thought was the proper configuration I'm getting the error:
Caused by: javax.resource.ResourceException: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource
Full error output from console:
Caused by: javax.resource.ResourceException: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource
at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:292)
at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:114)
at com.sun.gjc.spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.java:1292)
at com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:148)
at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:101)
at com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:87)
I've double checked some of the names, the connection pool and other resources.I've also added the MySQL driver .jars to the library of glassfish in both projects. The database was definitely working correctly through eclipse because I was able to view tables and display the resources inside the database context of eclipse. So I know that at least THOSE drivers are working correcly. Also the persistence.xml file looks good. it references the jdbc/mydatabase jndi reference like it should and default JTA is selected as the manament type.
Does anyone have another suggestion? Thank you
I've also added the MySQL driver .jars to the library of glassfish in both projects.
It was apparently not done right. The JAR has to go in /glassfish/domains/[domainname]/lib/ext folder of the Glassfish installation where [domainname] usually defaults to domain1. You can and should not configure it from the Eclipse side on.
Looks like I am replying very late, but however people who would be referring to this thread may find the following information being useful. So I am posting it here:
Download the connector Jar from http://dev.mysql.com/downloads/connector/j/5.0.html
unzip the pack and copy mysql-connector-java-verno-bin.jar
past the same at [GlassFish Installation Directory]/domains/[domain name]/lib folder
restart your domain and ping to check your connection in JDBC Connection Pools
There you go. If your MySql is running then it will ping the DB successfully
I copied the jar file to $glassfish_install_folder\glassfish\lib, after that it worked. I use glassfish 4.0.
Check this link from oracle.
I encountered this issue in 2018 and would like to note that if you are using glassfish 4 (current is 5) then it seems you have to use the Connector/J 5.1.47 version for it to work. If you use the current version (Connector/J 8.0.13) then exception mentioned in the original question keeps appearing, no matter where you place the .jar file.
With Connector/J 5.1.47 it works perfectly.
Solution is
> asadmin add-library /path/to/mysql-connector-java-bin.jar
Check this link:
https://blog.payara.fish/using-mysql-with-payara
I encountered this issue in 2019 and would like to note that if you are using docker image payara/server-full (I am using 5.194 so far) as I do the location to place the driver jar is:
/opt/payara/appserver/glassfish/domains/production/lib/
In the end I am doing something like this in the Dockerfile of payara server:
RUN wget http://central.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.2.0/mariadb-java-client-2.2.0.jar \
-O /opt/payara/appserver/glassfish/domains/production/lib/mariadb-java-client-2.2.0.jar

MessagePack and Glassfish

I'm trying to use MessagePack in a WAR application in Glassfish, but I'm getting this exception (although JavaAssist already is a library of the project):
java.lang.NoClassDefFoundError: javassist/ClassPath at
org.msgpack.template.builder.BuilderSelectorRegistry.initForJava(BuilderSelectorRegistry.java:58)
at
org.msgpack.template.builder.BuilderSelectorRegistry.(BuilderSelectorRegistry.java:38)
at
org.msgpack.template.TemplateRegistry.(TemplateRegistry.java:38)
at org.msgpack.MessagePack.register(MessagePack.java:149)
this happern When I call
org.msgpack.MessagePack.register()
Any ideas?
I posted the error in the MessagePack's JIRA and this is the answer:
I added this libraries to my classpath:
javassist.jar msgpack-0.5.2-devel.jar slf4j-api-1.6.2.jar
slf4j-ext-1.6.2.jar slf4j-simple-1.6.2.jar
Copying them directly to the lib folder of glassfish, to: C:\Program
Files\glassfish-3.1\glassfish\domains\domain1\lib
I'm gonna work now in adding them as part of my war
Thank you very much again.