A Misa

Ranch Hand
+ Follow
since Aug 07, 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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by A Misa

Hello there!

I am still struggling with Spring, but now i have moved on to the security part. I was following some tutorials and I find myself stuck, the security won't work, but I don't receive any errors either.
I have implemented the SecurityConfig class:



Also, the implementation of UserDetailsService:



The UserDAO implementation contains findByUserName:



Any idea what else i should configure in order to make it work? I know there are a lot of tutorials out there on security, but that's the problem: there are too many different ways of doing this and i find it difficult to make sense of it.
4 years ago
UPDATE

Well, i have figured it out. Seems like, instead of my current sessionFactory creation, I should have had something like:




Which means i externalized the properties from hibernate.cfg.xml like that:



Which is pretty ok for me, I am not really into xml configurations. But i still don't understand why i cannot import the properties from hibernate.cfg.xml. It should be a way of loading them, even though this kind of configuration isn't the newest or the most up to date.
4 years ago
I know that this question has been answered before, but none of the responses seem to help me, since i am not using a datasource in my project.
I a have a Maven project, integrated with Spring and Hibernate, connecting to a SQL Server 2014 database.
This is my pom.xml, where you can see the versions:



This is hibernate.cfg.xml:



And the class where i create the session factory:



I use Tomcat 8. Whenever i run it, i get UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
I have tried adding the details for the c3p0 connection pool as i have seen in an earlier post and i don't get the error anymore, but the server doesn't start up either, just hangs there after creating the pool.
Can someone, please, help with that?
4 years ago
Hello!

I have a pretty nasty and frustrating problem with a Maven Web Application, holding me back for some time.
Apparently, from my previous google searches, this is a common Spring MVC error, but i am not able to find the solution i need among the ones offered on the internet so far. Note that i am a beginner in Spring and in MVC concepts in general.

I have a web application which is supposed to manage a building administration (inhabitants, rent calculations, etc). I use Spring MVC, Hibernate, Java 1.8, Tomcat 8 server container, and SQL Server 2014.
Firstly, this is my POJO for the bulding residents, a type called Inhabitant:



This is my dispatcher-servlet.xml:



This is my web.xml:


This is my jsp registration form, which should map to the Inhabitant object:


And finally, the controller class, which should effectively map the data from the jsp form with the java entity, Inhabitant:



Now, this is the error i get whenever i try to run my application on the server:

message java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'inhabitant' available as request attribute

description The server encountered an internal error that prevented it from fulfilling this request.

exception
org.apache.jasper.JasperException: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'inhabitant' available as request attribute
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:471)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


root cause
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'inhabitant' available as request attribute
org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:117)
org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422)
org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
org.apache.jsp.login.index_jsp._jspx_meth_form_005finput_005f0(index_jsp.java:322)
org.apache.jsp.login.index_jsp._jspx_meth_form_005fform_005f0(index_jsp.java:216)
org.apache.jsp.login.index_jsp._jspService(index_jsp.java:148)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


I have tried a thousand things, but i just can't get it to work. So, please, can someone point out what i'm doing wrong? How can i correctly build the java object based on the information from the jsp form?

Thanks in advance!
4 years ago
I have a question related to aspect oriented programming in correlation with Java Web Services.

I have an application which is basically an inventory for a company's clients addresses. The data model has defined some pointcuts, so our custom rules get triggered in specific points (such as create, update, delete when we call the specific API which manipulates the address entities).

Now, i am creating an address entity through a java web service and persist it in the database. To create it, i call the specific cretion method provided by the application API. In this moment, the custom rules for creation are automatically fired and do some validation. Everything is fine until one of this custom rules crashes, throwing a custom exception. The problem i have is that i am not able to catch that exception in the web service. I mean, it gets thrown and everything, i can see it in the logs, but my handler doesn't see it and continues with the creation of my entity.

The error is caught only if i explicitly call the validation rule in my web service, but i don't want to do that, since i have a lot of rules for a particular entity and i would like to know if there's some sort of special error handling for this kind of problems.

PS: I am using JBoss rule engine.

Thanks!
4 years ago
I already have a piece of working code, but it uses an adjacecny matrix and the algorithm is a bit different. Graphs are not my strongest skill, but am i right to think it would be space comsuming to mantain a huge adjacency matrix(i might have thousands of nodes according to my model)?
4 years ago
am working on some project where i have to rename an entity. This implies saving a new object containing the old and the new name of the entity. This is how the soft works.

Now, what i have to do is check if a circular dependency is attempted when someone tries to rename an object. For example:



When someone tries to rename C into A, this should be signaled.

I am not sure how to approach this problem. My thought was to create a directed graph having the edges[A, B], [B, C], [C, A] and the apply some cycle detecting algorithms to find the circular dependencies (Tarjan or something).

Would that be efficient considering that the graph will not be connected? It is possible to have the aforementioned example and then:



I have come up with the following dfs approach:


and calling it like this:


And it successfully finds the connected components, but does not recognize any cycle, only if i remove the G[root][i] condition, that would be the first cycle from 0 to 0. What am i missing?
4 years ago
Hello!

I have a question related to the Weblogic deployment plan. I am investigating a case for an application, where i deploy a web service and its corresponding plan.xml. This file has the config-root tag pointing to another path on the machine, to a different Plan.xml. This second one is similar to the first, but overrides more modules. Its config-root tag is pointing to the same location as this second file, its own path is set there.

My question is why would there be the need to have a Plan pointing another Plan, instead of overriding all the configuration in a single one? Moreover, what exactly is accomplished setting this second plan to point to itself? Why would this solution work better than any other?

I don't currently have access to the information about how this process was created and i don't seem to find nowhere on the internet more tricks about config-root.
5 years ago

Winston Gutkowski wrote:
Well, that strikes me as a prerequisite for doing any testing; so I'd find out.
Winston



Well, i didn't even know where to start from, so the bad testing was not as useless as it seems.
Your answers got me on the right track in investigating this and thanks for that.

If i come up with a resolution which can help someone with the same kind of trouble, i'll post it here.

Thank you!
5 years ago
Thanks for pointing that out. I was checking out the code and didn't pay attention to the actual xml.

I cannot read this from a file. It's a request to a server, automatically built up based on some configuration file and accessed by its dao. After multiple operations, it gets in the format you've already seen and I don't really understand where it loses information or gets messed up.
5 years ago
Here you go:



This is a hardcoding for the test.
5 years ago
Hi!

I said i only suppose that, i thought if it could be possible and that's why i wanted an experienced advice.
Meanwhile, i investigated more this problem and here's what happens:

I have my xml request stored as a string. On it i apply the method removeEmptyTags(). And this is the moment it crashes. To remove the empty tags, this method calls another three methods: one for converting the string to document element, one for removing the empty tags and lastly, one which converts it back to string. I localized the problem to be in the first of these methods - the conversion from string to element. The stringToElement method does this:



and further more, stringToDocument does this:



So, i think it messes up the parsing and fails in cascade through all these methods up until throwing the error message i posted previously.
I hope i explained more clearly this time.

Thanks!
5 years ago
Hello!

I am facing a pretty interesting problem right now with processing a piece of xml code.

It's actually an xml request on which a bunch of methods are applied. In order to process it, it is converted to a String, but it already has some nested quotes inside. And i suppose that this convertion to String wraps the hole thing in another pair of quotes. Hence, the exception org.xml.sax.SAXParseException, followed by the message : "The element type 'myTag' must be terminated by the matching end-tag '</myTag>'".

How should i handle this error? Can i replace with something else the nested quotes when making the conversion? With what? What is the best approach?

Thanks!
5 years ago
Hello!

I am a bit confused about something.

I compiled a java application in Eclipse Kepler on 32 bits (using, of course a 32 bit jvm). I deployed it on a server using a jvm on 64 bits. When restarting the server, i got the"unsupported major minor 51 exception".
Note that i used the same java version for compiling my project as the server used.
It did not work until i compiled with another 64 bit eclipse (hence 64 bit java).

I find it strange since jvm is platform independent. Would it matter if i deploy 32 bit java compiled project on server using 64 bit java version?
5 years ago