java.lang.NumberFormatException in db2jcc.jar - java

I am hitting this exception in a Java application. I extract the JAR file and try to check what is the root cause of this, but I fail to get it, because I can't debug on it.
I have the source JAR file, but every time I attach it in my workspace, it still shows me "the source attachment does not contain the source for the file ad.class".
The following is the error stack:
Caused by: java.lang.NumberFormatException: For input string: "A"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:59)
at java.lang.Integer.parseInt(Integer.java:460)
at java.lang.Integer.parseInt(Integer.java:510)
at com.ibm.db2.jcc.c.ad.<init>(ad.java:80)
at com.ibm.db2.jcc.b.f.<init>(f.java:55)
at com.ibm.db2.jcc.b.b.ib(b.java:1760)
at com.ibm.db2.jcc.c.p.a(p.java:2490)
at com.ibm.db2.jcc.b.b.a(b.java:470)
at com.ibm.db2.jcc.b.b.<init>(b.java:264)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:163)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 12 more
How can I debug this?

I think, the problem lies where you passed DBCP connection pool values - min count, max count etc. You have passed "A" in place of an integer.
Please check your spring context file or properties file where you provided database connection parameters.

I found the solution, its cause by the db2jcc.jar is too old for the db2 version. I found the solution here and manage to fix it.
https://www-01.ibm.com/support/docview.wss?uid=swg21625290

"A" is not a number you're probably trying to insert a string value into a variable or array that only allows numbers, make sure you declare your variables and arrays correctly. If your put atention in the error you are tryingtry put a String value into integer. I hope you can solved your error with my help pass a good day

Related

How to use String ressource in Java file in Android without a Layout

I have a Java class that mainly contains strings. It does not have a layout as it is neither a Fragment nor an Activity. It is more used as an auxilliary class. I would like to assign the String values in the class by using the Resource strings as I would like to automatically translate the Strings. Howvever, I can't access the string resources from Java. I use the following code:
static String more = getString(R.string.more);
And in the XML file I have the ressource:
<string name="more">More</string>
I get the error message
Cannot resolve method 'getString'
I also tried static String more = getContext().getString(R.string.more);
but I got the error message:
Cannot resolve method 'getContext'
Would anyone mind helping me on that? I'd appreciate every comment.
Update: I tried to use the answer from "MikaelM"
Resources.getSystem().getString(R.string.more)
However, I get an "exception in initializer error" and when I use the initial String again, I do not get this error. So I still can't get the String from the ressource. DO you have an idea what I can do? I'd appreciate every further comment.
So the error is caused by "Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f120038"
The strange thing is that the resource in fact exists (I checked this several times).
getString(R.string...
is not the same as
Resources.getSystem().getString(android.R.string...
Only the second variant you can use in the static context. Alas, you can get this way only system resources.
If you need to get your own resources, no one-line solution exists. Use https://stackoverflow.com/a/4391811/715269 solution of #Cristian. And notice: it is a very good solution, even more, it is the solution meant to be used by the creators of Android.
You should be able to get your string with:
Resources.getSystem().getString(R.string.more)
See more here, getString Outside of a Context or Activity

Getting MultiLangDaemon Exception

I implemented a kinesis stream consumer client using node wrapper and getting this MultiLangDaemon execution error as shown below.
Starting MultiLangDaemon ... java.lang.IllegalArgumentException: No enum constant software.amazon.kinesis.common.InitialPositionInStream.TRIM_HORIZON at java.lang.Enum.valueOf(Enum.java:238) at software.amazon.kinesis.common.InitialPositionInStream.valueOf(InitialPositionInStream.java:21) at software.amazon.kinesis.multilang.config.MultiLangDaemonConfiguration$2.convert(MultiLangDaemonConfiguration.java:208) at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:491) at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1007) at software.amazon.kinesis.multilang.config.KinesisClientLibConfigurator.lambda$getConfiguration$0(KinesisClientLibConfigurator.java:65) at java.lang.Iterable.forEach(Iterable.java:75) at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2064) at software.amazon.kinesis.multilang.config.KinesisClientLibConfigurator.getConfiguration(KinesisClientLibConfigurator.java:63) at software.amazon.kinesis.multilang.MultiLangDaemonConfig.<init>(MultiLangDaemonConfig.java:101) at software.amazon.kinesis.multilang.MultiLangDaemonConfig.<init>(MultiLangDaemonConfig.java:74) at software.amazon.kinesis.multilang.MultiLangDaemonConfig.<init>(MultiLangDaemonConfig.java:58) at software.amazon.kinesis.multilang.MultiLangDaemon.buildMultiLangDaemonConfig(MultiLangDaemon.java:171) at software.amazon.kinesis.multilang.MultiLangDaemon.main(MultiLangDaemon.java:220) No enum constant software.amazon.kinesis.common.InitialPositionInStream.TRIM_HORIZON
I already cross checked properties file with details shown below listed there
initialPositionInStream, processingLanguage,streamName,executableName etc.
TRIM_HORIZON is set as value for initialPositionInStream Not sure why software.amazon.kinesis.common.InitialPositionInStream this object missing this value?
I am using node consumer client as mentioned here
https://docs.aws.amazon.com/streams/latest/dev/kinesis-record-processor-implementation-app-nodejs.html
Just want to help community by answering this specific error fix. It was .properties file update for that respective parameter key name. Although I am getting couple of other java.lang.RuntimeException that will try to resolve and ask for resolution in separate threads.

Why I got java.lang.nullpointerexception in elasticsearch build node?

I've test my apps using elasticsearch with very simple line of code. Like this :
Node node = nodeBuilder()
.settings(Settings.settingsBuilder().put("cluster.name", "elasticsearch").put("clster.transport.sniff", true).put("path.home", "/home/kenny/Program/Java/elastic"$
.node();
But I got error like this :
Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:78)
at java.io.InputStreamReader.<init>(InputStreamReader.java:113)
at org.elasticsearch.node.internal.InternalSettingsPreparer.randomNodeName(InternalSettingsPreparer.java:198)
at org.elasticsearch.node.internal.InternalSettingsPreparer.finalizeSettings(InternalSettingsPreparer.java:177)
at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:101)
at org.elasticsearch.node.Node.<init>(Node.java:128)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:152)
at TryElastic.main(TryElastic.java:56)
I don't know how to solve this problem, I've try and looking for the solution. Line 56 at error log, refer to ".node()" method above. So, dou you have suggestion or there are something that I've to add in my code
Thanks.....
The only way this can happen is due to a misconfiguration of path.home.
When Elasticsearch tries to generate a random node name for your instance, it looks for a file at {path.home}/config/names.txt
If the file cannot be found, you'll get a (rather unfriendly and unhelpful) NullPointerException.
So the solution is to check that "/home/kenny/Program/Java/elastic" is really the top-level of an ES installation.
See here for docs on the correct directory layout.

Reading R-Errors through JRI

i'm using JRI, to talk to R through Java. If i try to get the result of my R-Code as Double i get a NullPointer. Normally this is caused by an error of R. Is it possible to get the output of the R-Console into Java in order to read the error?
Ok. Here is what I did, to solve the problem.
because my REngine is a singleton i was able to perform those R-Expressions, after the creation:
re.eval("log<-file('"+filepath+"')");
re.eval("sink(log, append=TRUE)");
re.eval("sink(log, append=TRUE, type='message')");
this codes writes every R-Output into the file specified by the String filepath. For non-singletons i would recommend to extend the REngine...

Java : Help Regarding Exception Report with server Logs

i am fairly new in java and currently working in Struts 1.3. My question is more related with java.
Following is the scenario and i am not sure regarding the best approach to be followed.
I want to make a error reporting functionality in my project where in I'm copying stacktrace and inserting it in the database's table say "errorlog" table with type of exception,date, user etc and other fields. But now what i have to do is :
I have to identify the package name, file, method and line number in which the exception occurred with the help of server logs that i have when exception occurs.
But the problem is that the log gives you the exception, file and the line number but it also contains errors that are not in my packages as in HttpServlet.service(HttpServlet.java:710) etc given below:
java.lang.NullPointerException
com.candidate.query.CandSearchAction.execute(CandSearchAction.java:34)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.proc ess(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
In above case, i got a null pointer exception in my CandSearchAction.java line number 34.
Now i want to know how to differentiate or extract only the line that points to my java/jsp file, so that i can filter them accordingly.
Can anyone please help regarding this situation or how to approach this problem.. is there any library that i can use or anything that could help me.
Waiting for a response that would help me.
If your code follows the same basic structure you used in your example, you could parse the stack trace for anything starting with 1 of your package names and only use those lines.

Categories