This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General forum!

ssiva raman

Ranch Hand
+ Follow
since Jan 22, 2014
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ssiva raman

Hi Tim,

Thank you for the clarification. could you suggest me a book i can read in more detail.?

thank you
Hi

I'd like to learn RDBMS concepts. can you suggest me a book to read.?

Thanks in advance

The below configuration solved the problem. However , i want to know how the connection pool got exhausted when i've only one connection to the DB.
Any help is appreciated.

change:


Previous:

Tim Holloway wrote:That's the kind of error you get when you have too many connections opened to the database. It generally means that you are not closing connections when you are done with them.

A Connection Pool is a collection of pre-allocated Connections. When you ask the pool for a Connection, it will take one of the Connections that it owns and give it to your application.

But you have to give the connection back when you're finished with it.

Otherwise the pool will run dry and this is what you end up with.



Thank you for the reply , Tim.
If you have seen the code , you would find that i don't have too many connections to the DB and i close the session after each query.
Kindly , point out the mistake in the code.

Thanks again!!
i was following a tutorial to practice hibernate. i'm facing the exception as below. Googled it but no convincing solution. any help ?



ERROR:

Exception in thread "main" org.hibernate.HibernateException: The internal connection pool has reached its maximum size and no connection is currently available!
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.poll(DriverManagerConnectionProviderImpl.java:290)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PoolState.getConnection(DriverManagerConnectionProviderImpl.java:440)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:171)
at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:48)
at org.hibernate.id.enhanced.TableStructure$1.getNextValue(TableStructure.java:125)
at org.hibernate.id.enhanced.NoopOptimizer.generate(NoopOptimizer.java:40)
at org.hibernate.id.enhanced.SequenceStyleGenerator.generate(SequenceStyleGenerator.java:523)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:115)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:194)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:38)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:179)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:32)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:75)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:636)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:629)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:624)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:351)
at com.sun.proxy.$Proxy30.save(Unknown Source)
at com.hibernateexample.HibernateDao.main(HibernateDao.java:19)



Hibernate config file:


Entity:


DAO class:



thanks in advance!!

Stephan van Hulst wrote:Yes, I think this is causing your issue.



you're right, Stephan. thank you for spotting.

By default, component scanning occurs in the package of your main application class, or sub-packages. com.example.Controller is not a sub-package of com.example.demo.



The below change solved the problem. However , i'll rearrange the project hierarchy as you suggested.


You could specify the name of the package to scan for components like this:
It's better however, to instead use a more sensible package hierarchy. For instance, if com.example.demo is the base package of your project, put the main application class in com.example.demo.spring and put your controllers in com.example.demo.spring.controller. This will enable component scanning for the com.example.demo.spring package (and also its sub-packages like com.example.demo.spring.controller) while skipping it for packages that don't need it. That way you could put your business model in com.example.demo, and it won't take up any resources being scanned needlessly.

  • src/main/java/
    • com/example/demo/
      • Movie.java
      • spring/
        • MovieCatalogSvcsApplication.java
        • controller/
          • MovieCatalogController.java

Please use proper Java naming conventions. Package name elements should not be capitalized, and write out names (e.g. Controller instead of Ctrl).



sure, thank you for the suggestions.
7 months ago

Stephan van Hulst wrote:Do you have a main class annotated with @SpringBootApplication? What package is it in? What package is your controller in?



They are in different package. is it a problem?



7 months ago

Stephan van Hulst wrote:Does your application contain a context.xml file?



No, Stephan.
7 months ago
hi Stephan,

thank you for the reply.

yes , I'm using spring boot.

Please find the pom.xml.

7 months ago
I've created a simple rest api. when i tried to hit the resource , i get 404 not found error. i googled but couldn't find any help. can somebody guide me?

P.S: if you need anymore information , let me know.






Error:


2020-10-04 13:50:53.129 DEBUG 18704 --- [nio-8080-exec-2] o.a.coyote.http11.Http11InputBuffer      : Received [GET /catalog/1 HTTP/1.1
User-Agent: PostmanRuntime/7.26.5
Accept: */*
Cache-Control: no-cache
Postman-Token: 2d855b91-4ee7-408f-99f0-5d89780e7902
Host: localhost:8080
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

]
2020-10-04 13:50:53.129 DEBUG 18704 --- [nio-8080-exec-1] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header

java.io.EOFException: null
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1231) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1141) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:791) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:355) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at java.base/java.lang.Thread.run(Thread.java:835) ~[na:na]

7 months ago

Campbell Ritchie wrote:

ssiva raman wrote:. . . i cant afford to use external jars . . .

What does that mean? Don't put your own text in quote tags.



that means , i don't want to use any open source jars like jsoup.jar to navigate through the page that i've connected.
All i need to know is how to head start this thing.

do you think you can help with that?

thank you
siva
4 years ago
Hi ,

Actually , i encountered a requirement that i should have a java application to connect and navigate to report files as xml/jason in jenkins.

my problem is,

which technique i should choose in java for this?

can i do it purely by core java?

i tried it using UrlConnect object and read it , and was successfull. but i find it hard for deeper navigation for embedded links in the connected portal.

i cant afford to use external jars


thank you
siva
4 years ago
hi tim,

thanks for the reply.


that helped.but i want to do that ,unlike NameCaller , without changing the original source code.

do you have anyother idea?
4 years ago