David Acevedo

Greenhorn
+ Follow
since Feb 12, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by David Acevedo

Solved!



In the position 0 of the obj array is the Entity and in the second is the scalar value generated by the column.

I hope this will be useful for somebody

Hello,
I am having some problems getting the information from a query that I did.
I specified a resultSetMapping like this:



In which I am putting the entity and an additional column that I bring in my sql query.

In my session bean I try to execute my query:



I can ensure that the information is stored in the list, I even can check the size of the list and it is correct, but I do not know
how to access the data. To which type of date can I cast the result of the query?.

I am pretty new working with resultSetMapping when combining entities with columns ... please somebody can help me out with
this problem. I have been trying and looking for examples in the forums, but I have not get anything useful.

Thanks in advance for your help.

BR
David

Thanks a lot Ivan, your solution worked perfectly!!

Kumar thanks for your help.
7 years ago
Hi Kumar,

I already tried creating the service with url and the qname, but in that case I have to send the wsdl url.
The url that I have to change is not the url of the wsdl but the one where the webservice is located. :S.

This is part of the wsdl file:



The line 14 contains the url that I have to change.
Just to test the webservice I change the wsdl adding to that url this: ?SessionID=9540f8c0-2a23-11e0-b723-3221365d415d then in that line I temporally put

https://10.285.16.20:443/Services/Service0002/Interface/Service0002.serviceagent/portTypeEndpoint?SessionID=9540f8c0-2a23-11e0-b723-3221365d415d

After that I generate my client again with the new wsdl and it worked perfectly... but the problem is that the value of SessionID constantly changes... then
somehow I have to make it change in my client too :S.

Then the 2 possible solutions are:
1. Make that url change.
2. Set the url to "https://10.285.16.20:443/Services/Service0002/Interface/Service0002.serviceagent/portTypeEndpoint" and somehow send the SessionID parameter

But I still dont have idea how to do it




7 years ago

Kumar Raja wrote:Hi David,

Just curious to know, why you want to change the service URL, when the service hosted is specified in WSDL.



Hi Kumar,
I have to change that url because I also have to send a parameter with a token that I get before using an authentication process.
That token changes everyday, then I cannot fix the whole URL.
The fix part is: http://10.10.10.11:8080/posystem/soaj/updateService which is the one specified in the wsdl
The part that I have to add is the parameter thing.

I thinkg that the correct way would be letting that URL fix and somehow sending the parameter with POST, but I dont know how to set that parameter,
then I thought about the option of putting it in the url. (maybe not the best solution) :S

btw, I genereted my webservice client using the netbeans wizard, when I import the webservice client operation I just get the an instance of my webservice client class
which extends from javax.xml.ws.Service.
I have been exploring the object, and I cold not find where the url to access the webservice is stored. :S






7 years ago
Hi!!

I want to know how can I change the address location to which my webservice client makes the request.
I created my webservice client using a wsdl given to me in which the address location of the webservice is specified in the next line:
<soap:address location="http://10.10.10.11:8080/posystem/soaj/updateService"/>

I want to change this address to the same one plus a post parameter, it will look something like: "http://10.10.10.11:8080/posystem/soaj/updateService?param=312312312"

The value of the parameter constantly changes then I need to change the address.

Any ideas to change that address in code?

Thanks in advance!!

BR,
David
7 years ago
I found the solution:
This is a solution that only applies in a development environment and when it is a self-signed certificate.
Do not use it in a production environment.

http://www.coderanch.com/t/134384/Security/Getting-error-No-subject-alternative

Hello,
I am having some troubles with a self-signed certificate that was given to me to allow my application to use some web services.

I installed the certificate in the operating system (Windows) and in the keystore cacerts.jks in glassfish.
When I try to consume the webservice I am getting the next error:

Error:com.sun.xml.ws.client.ClientTransportException: HTTP transport
error: javax.net.ssl.SSLHandshakeException:
java.security.cert.CertificateException: No subject alternative names present


I have spent more than 5 days looking for a solution but I do not know what can I do.

I read that the problem usually appears when the "cn" in the certificate does not match the address of the server.
The "CN" in my certificate is "PRESS44"
The server address that was given to me is an ip. https://xxx.xxx.xxx.xxx:123

I have read in different forums that I have to regenerate the certificate and change the cn to make it match with the
domain name of the server, in this case to make it match with the ip, but I cannot do it because I cannot change the
certificate.
I have called to the company who gave the certificate but they told that it was right, and that several people was using the
same certificate successfully.

I also tried to access the server address from the browser, and it shows me a message telling me that there is a problem
with the current certificate. It shows an error that says "mismatched address".

Thanks in advance for your help.

BR

David



Hello!
I am trying to use ssl in my server to make a secure connection with a server from one of our customers.
They sent us the certificate file (*.crt) and we are supposed to use it in our server.

I did not have idea about ssl and secure connections so I did some basic tutorials, I generated my keys using keytool and after
tested that loading https://localhost:8181. Everything seem working fine, but when I imported the customer certificate using keytool and I change
the name of the alias in my glassfish domain, https://localhost:8181 did not load again.

I checked with keytool -list and the certificate that I imported appears in the list with the other certificates that I created. Everything looks the same
but when I set the alias of that certificate in glassfish, https://localhost:8181 doesnt load.

Just to test I exported a crt file using one of the generated keys that was working. After that I imported the crt file and the https://localhost:8181 did not load again.
Then I think the problem is when I import the crt file, or maybe I am doing sth very stupid .

I have tried different parameters to import the crt file like:

keytool -import -file certificate.crt -alias cert

keytool -import -file certificate.crt -keystore keystore.jks -alias cert

keytool -import -v -trustcacerts -file certificate.crt -keystore keystore.jks -alias cert


Thanks for your help!!!

BR
David


Matthew Brown wrote:Try calling flush() before detaching?



Thanks, It works now.
I have a doubt, I am doing that query 2 times every 5 seconds, in this conditions do you think "flush" can affect my application performance?

Hi,
I have a problem with my code, I am trying to insert some information in the database and after that detach my object.

Basically what I am doing is:



When I use that code, nothing is inserted in the database, if I remove the "em.detach(operacion)" line it is going to work.
How can I insert the information in the database and after that detach my object??
What am I doing wrong?

Thanks for in advance for your help
Hello, I am having some problems with a query that I am trying to use in my JEE project. This query doesnt return an entity but a group of values. I created a class representing the result and a query with the jpa constructor expression but it is not working.
The problem is that in the query I added some alias to the results, and when I try to run the project it says that it cannot parse the query.

My Query:


When I use that the server returns :

Exception Description: Syntax error parsing the query [SELECT NEW vo.VOOperacionesAgrupadas (o.nemotecnico as nemotecnico, o.esCompra as esCompra, i.equivUltimo as equivUltimo, sum(o.saldo) as saldo, sum(o.utilidad) as utilidad, sum(o.tasaCompraVenta)/count(o.nemotecnico) as promedioTasaCompra, (i.equivUltimo-sum(o.tasaCompraVenta)/count(o.nemotecnico))*100 as puntosBasicos) FROM Operaciones o, Instrumentos i WHERE o.idUsuario = :idUsuario AND o.nemotecnico = i.nemotecnico AND o.estaCerrada = 'false' Group by o.nemotecnico, o.esCompra, i.equivUltimo], line 1, column 53: syntax error at [as].
Internal Exception: MismatchedTokenException(8!=82)
GRAVE: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing the query [SELECT NEW vo.VOOperacionesAgrupadas (o.nemotecnico as nemotecnico, o.esCompra as esCompra, i.equivUltimo as equivUltimo, sum(o.saldo) as saldo, sum(o.utilidad) as utilidad, sum(o.tasaCompraVenta)/count(o.nemotecnico) as promedioTasaCompra, (i.equivUltimo-sum(o.tasaCompraVenta)/count(o.nemotecnico))*100 as puntosBasicos) FROM Operaciones o, Instrumentos i WHERE o.idUsuario = :idUsuario AND o.nemotecnico = i.nemotecnico AND o.estaCerrada = 'false' Group by o.nemotecnico, o.esCompra, i.equivUltimo], line 1, column 53: syntax error at [as].
Internal Exception: MismatchedTokenException(8!=82)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1328)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:425)
at PyGOBeans.OperacionesFacade.consultarOperacionesAgrupadas(OperacionesFacade.java:376)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1056)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1128)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5292)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:615)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:797)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:567)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:157)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:139)
at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:858)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:797)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:367)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5264)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5252)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:190)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
at $Proxy288.consultarOperacionesAgrupadas(Unknown Source)
at FrontEnd.AdministrarOperaciones.consultarOperacionesGroupByNemotecnico(AdministrarOperaciones.java:175)
at FrontEnd.AdministrarOperaciones.processRequest(AdministrarOperaciones.java:90)
at FrontEnd.AdministrarOperaciones.doGet(AdministrarOperaciones.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at BackEnd.AllowedClientsFilter.doFilter(AllowedClientsFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
Caused by: Exception [EclipseLink-8024] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [SELECT NEW vo.VOOperacionesAgrupadas (o.nemotecnico as nemotecnico, o.esCompra as esCompra, i.equivUltimo as equivUltimo, sum(o.saldo) as saldo, sum(o.utilidad) as utilidad, sum(o.tasaCompraVenta)/count(o.nemotecnico) as promedioTasaCompra, (i.equivUltimo-sum(o.tasaCompraVenta)/count(o.nemotecnico))*100 as puntosBasicos) FROM Operaciones o, Instrumentos i WHERE o.idUsuario = :idUsuario AND o.nemotecnico = i.nemotecnico AND o.estaCerrada = 'false' Group by o.nemotecnico, o.esCompra, i.equivUltimo], line 1, column 53: syntax error at [as].
Internal Exception: MismatchedTokenException(8!=82)
at org.eclipse.persistence.exceptions.JPQLException.syntaxErrorAt(JPQLException.java:362)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.handleRecognitionException(JPQLParser.java:304)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.addError(JPQLParser.java:245)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.reportError(JPQLParser.java:362)
at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.recoverFromMismatchedElement(Unknown Source)
at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(Unknown Source)
at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.mismatch(Unknown Source)
at org.eclipse.persistence.internal.libraries.antlr.runtime.BaseRecognizer.match(Unknown Source)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.constructorExpression(JPQLParser.java:2635)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectExpression(JPQLParser.java:2045)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectItem(JPQLParser.java:1351)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectClause(JPQLParser.java:1266)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.selectStatement(JPQLParser.java:352)
at org.eclipse.persistence.internal.jpa.parsing.jpql.antlr.JPQLParser.document(JPQLParser.java:276)
at org.eclipse.persist
GRAVE: ence.internal.jpa.parsing.jpql.JPQLParser.parse(JPQLParser.java:133)
at org.eclipse.persistence.internal.jpa.parsing.jpql.JPQLParser.buildParseTree(JPQLParser.java:94)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:198)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:173)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:125)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:109)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1326)
... 59 more
Caused by: MismatchedTokenException(8!=82)
... 74 more



What can I do?? I have been stuck in this problem for 2 weeks :s I have tried almost everything..

Thanks in advance for your help!

Jesper Young wrote:Welcome to JavaRanch. Please UseCodeTags when you post source code.



Ok Jesper, I will take that into account for the next time
8 years ago

Henry Wong wrote:

David Acevedo wrote:
am I wrong? which one is my mistake??
Maybe I am missing something but I don't have idea what help!!!



Not all days are 24 hours long. For countries that observe "daylight savings", switchover days can be either 23 hours or 25 hours long, depending on the change.

Henry



Thanks a lot!!! Henry.
I am not used to the daylight savings I would never considered that
8 years ago
I was coding a method that gets the number of days between two dates. When I was testing the method I found that sometimes it returns a result that differs with the correct answer in 1 day. I check step by step my method and I found this problem.
I don't know what I am doing wrong, but I don't have idea how to solve it, it is too strange.

---------------------
private int getNumberOfDaysBetween(Date date1, Date date2) {
long fechaInicialMs = date1.getTime();
long fechaFinalMs = date2.getTime();
long dif = fechaFinalMs - fechaInicialMs;
double dias = Math.floor(dif / (1000 * 60 * 60 * 24));
return (int) dias;
}

client:

Date test1 = new Date(2010, 2, 24);
Date test2 = new Date(2010, 2, 25);
System.out.println("Result: " + getNumberOfDaysBetween(test2, test1));

With this input it returns 1 that is ok, but when the input is:

Date test1 = new Date(2010, 2, 27);
Date test2 = new Date(2010, 2, 28);
System.out.println("Result: " + getNumberOfDaysBetween(test2, test1));
With this input it returns 0

Then I checked what the getTime method was bringing and I found that for the date 2010/03/28 (Date test1 = new Date(2010, 2, 27)) it brings less milliseconds.
Each day has 86400000 milliseconds (1000*24*60*60) but for that specific date the method getTime() counts just 82800000 then for that reason when I use the method floor() in my method it returns 0.

I printed what getTime returns for different dates in order you appreciate the problem:
Date getTime()
Sat Mar 19 00:00:00 EET 3910 61227093600000
Sun Mar 20 00:00:00 EET 3910 61227180000000
Mon Mar 21 00:00:00 EET 3910 61227266400000
Tue Mar 22 00:00:00 EET 3910 61227352800000
Wed Mar 23 00:00:00 EET 3910 61227439200000
Thu Mar 24 00:00:00 EET 3910 61227525600000
Fri Mar 25 00:00:00 EET 3910 61227612000000
Sat Mar 26 00:00:00 EET 3910 61227698400000
Sun Mar 27 00:00:00 EET 3910 61227784800000
Mon Mar 28 00:00:00 EEST 3910 61227867600000
Tue Mar 29 00:00:00 EEST 3910 61227954000000
Wed Mar 30 00:00:00 EEST 3910 61228040400000
Thu Mar 31 00:00:00 EEST 3910 61228126800000

If you check the difference between each day is exactly 86400000 ms, but with 2010/03/28 it doesn't work.

am I wrong? which one is my mistake??
Maybe I am missing something but I don't have idea what help!!!






8 years ago