Connecting mysql Database to Local WildFly Server - java

I'm running a local wildfly server
and i run mysql script in MySQL workbench, the name of database schema is testapp
I created folder in D:\wildfly-8.1.0.Final\modules\system\layers\base\com\mysql\main
I've got here mysql-connector-java-5.1.37-bin jar file and module.xml
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.37-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
then i added dataresource code into standalone.xml
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/testappDS" pool-name="testappDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/testapp</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>test</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
But when i make a request from Postman
xxx.xx.x.xxx:8080/restful/test/hospitals/location?lat=24.000000000&lng=46.000000000
it gives me ERROR Internal Server Error (500)
in Command Prompt it shows this error
11:41:44,739 ERROR [stderr] (default task-1) at
com.sun.jersey.server.impl.ur
i.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
11:41:44,740 ERROR [stderr] (default task-1) at
com.sun.jersey.server.impl.ur
i.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
11:41:44,741 ERROR [stderr] (default task-1) at
com.sun.jersey.server.impl.ur
i.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
11:41:44,742 ERROR [stderr] (default task-1) at
com.sun.jersey.server.impl.ur
i.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
11:41:44,743 ERROR [stderr] (default task-1) at
com.sun.jersey.server.impl.ap
plication.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
11:41:44,743 ERROR [stderr] (default task-1) at
com.sun.jersey.server.impl.ap
plication.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
11:41:44,745 ERROR [stderr] (default task-1) at
com.sun.jersey.server.impl.ap
plication.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
11:41:44,746 ERROR [stderr] (default task-1) at
com.sun.jersey.server.impl.ap
plication.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
11:41:44,747 ERROR [stderr] (default task-1) at
com.sun.jersey.spi.container.
servlet.WebComponent.service(WebComponent.java:409) 11:41:44,748 ERROR
[stderr] (default task-1) at com.sun.jersey.spi.container.
servlet.ServletContainer.service(ServletContainer.java:558)
11:41:44,749 ERROR [stderr] (default task-1) at
com.sun.jersey.spi.container.
servlet.ServletContainer.service(ServletContainer.java:733)
11:41:44,750 ERROR [stderr] (default task-1) at
javax.servlet.http.HttpServle t.service(HttpServlet.java:790)
11:41:44,751 ERROR [stderr] (default task-1) at
io.undertow.servlet.handlers.
ServletHandler.handleRequest(ServletHandler.java:85) 11:41:44,752
ERROR [stderr] (default task-1) at io.undertow.servlet.handlers.
security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.jav
a:61) 11:41:44,753 ERROR [stderr] (default task-1) at
io.undertow.servlet.handlers.
ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
11:41:44,754 ERROR [stderr] (default task-1) at
org.wildfly.extension.underto
w.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssoci
ationHandler.java:78) 11:41:44,755 ERROR [stderr] (default task-1)
at io.undertow.server.handlers.P
redicateHandler.handleRequest(PredicateHandler.java:25) 11:41:44,756
ERROR [stderr] (default task-1) at io.undertow.servlet.handlers.
security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociatio
nHandler.java:113) 11:41:44,757 ERROR [stderr] (default task-1) at
io.undertow.servlet.handlers.
security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCal
lHandler.java:56) 11:41:44,758 ERROR [stderr] (default task-1) at
io.undertow.server.handlers.P
redicateHandler.handleRequest(PredicateHandler.java:25) 11:41:44,759
ERROR [stderr] (default task-1) at io.undertow.security.handlers
.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.jav
a:45) 11:41:44,760 ERROR [stderr] (default task-1) at
io.undertow.servlet.handlers.
security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidenti
alityConstraintHandler.java:61) 11:41:44,761 ERROR [stderr] (default
task-1) at io.undertow.security.handlers
.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.j
ava:58) 11:41:44,762 ERROR [stderr] (default task-1) at
io.undertow.servlet.handlers.
security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSess
ionHandler.java:70) 11:41:44,763 ERROR [stderr] (default task-1) at
io.undertow.security.handlers
.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
11:41:44,764 ERROR [stderr] (default task-1) at
io.undertow.server.handlers.P
redicateHandler.handleRequest(PredicateHandler.java:25) 11:41:44,765
ERROR [stderr] (default task-1) at org.wildfly.extension.underto
w.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
11:41:44,766 ERROR [stderr] (default task-1) at
io.undertow.server.handlers.P
redicateHandler.handleRequest(PredicateHandler.java:25) 11:41:44,767
ERROR [stderr] (default task-1) at io.undertow.server.handlers.P
redicateHandler.handleRequest(PredicateHandler.java:25) 11:41:44,768
ERROR [stderr] (default task-1) at io.undertow.servlet.handlers.
ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
11:41:44,769 ERROR [stderr] (default task-1) at
io.undertow.servlet.handlers.
ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
11:41:44,770 ERROR [stderr] (default task-1) at
io.undertow.servlet.handlers.
ServletInitialHandler.access$000(ServletInitialHandler.java:73)
11:41:44,771 ERROR [stderr] (default task-1) at
io.undertow.servlet.handlers.
ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
11:41:44,772 ERROR [stderr] (default task-1) at
io.undertow.server.Connectors .executeRootHandler(Connectors.java:177)
11:41:44,773 ERROR [stderr] (default task-1) at
io.undertow.server.HttpServer
Exchange$1.run(HttpServerExchange.java:727) 11:41:44,774 ERROR
[stderr] (default task-1) at java.util.concurrent.ThreadPo
olExecutor.runWorker(ThreadPoolExecutor.java:1142) 11:41:44,775 ERROR
[stderr] (default task-1) at java.util.concurrent.ThreadPo
olExecutor$Worker.run(ThreadPoolExecutor.java:617) 11:41:44,776 ERROR
[stderr] (default task-1) at java.lang.Thread.run(Thread.j ava:745)
11:41:44,788 SEVERE [com.sun.jersey.spi.container.ContainerResponse]
(default ta sk-1) The RuntimeException could not be mapped to a
response, re-throwing to the HTTP container:
java.lang.NullPointerException
at com.mycompany.jeresyrest.Hospitals.nearBySearch(Hospitals.java:87) [c
lasses:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1 .8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62) [rt.jar:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43) [rt.jar:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_45]
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMe
thodInvokerFactory.java:60) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMeth
odDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchPr
ovider.java:205) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDi
spatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
[jersey-bundle-1.19.jar:
1.19]
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethod
Rule.java:302) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHa
ndPathRule.java:147) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(Resourc
eClassRule.java:108) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHa
ndPathRule.java:147) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(R
ootResourceClassesRule.java:84) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequ
est(WebApplicationImpl.java:1542) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequ
est(WebApplicationImpl.java:1473) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleReque
st(WebApplicationImpl.java:1419) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleReque
st(WebApplicationImpl.java:1409) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponen
t.java:409) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(Servlet
Container.java:558) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(Servlet
Container.java:733) [jersey-bundle-1.19.jar:1.19]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-s
ervlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHand
ler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.hand
leRequest(ServletSecurityRoleHandler.java:61)
[undertow-servlet-1.0.15.Final.jar :1.0.15.Final]
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(
ServletDispatchingHandler.java:36)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Fin al]
at org.wildfly.extension.undertow.security.SecurityContextAssociationHan
dler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandle
r.handleRequest(SSLInformationAssociationHandler.java:113)
[undertow-servlet-1.0 .15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandle
r.handleRequest(ServletAuthenticationCallHandler.java:56)
[undertow-servlet-1.0.
15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRe
quest(AbstractConfidentialityHandler.java:45)
[undertow-core-1.0.15.Final.jar:1.
0.15.Final]
at io.undertow.servlet.handlers.security.ServletConfidentialityConstrain
tHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
[underto w-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleR
equest(AuthenticationMechanismsHandler.java:58)
[undertow-core-1.0.15.Final.jar:
1.0.15.Final]
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandl
er.handleRequest(CachedAuthenticatedSessionHandler.java:70)
[undertow-servlet-1.
0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(Se
curityInitialHandler.java:76)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.han
dleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest
(ServletInitialHandler.java:240)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final ]
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(Se
rvletInitialHandler.java:227)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(Servlet
InitialHandler.java:73)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(Se
rvletInitialHandler.java:146)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:7
27) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142) [rt.jar:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617) [rt.jar:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_45]
11:41:44,815 ERROR [io.undertow.request] (default task-1) UT005023:
Exception ha ndling request to /restful/test/hospitals/location:
java.lang.NullPointerExcep tion
at com.mycompany.jeresyrest.Hospitals.nearBySearch(Hospitals.java:87) [c
lasses:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1 .8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62) [rt.jar:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43) [rt.jar:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_45]
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMe
thodInvokerFactory.java:60) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMeth
odDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchPr
ovider.java:205) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDi
spatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
[jersey-bundle-1.19.jar:
1.19]
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethod
Rule.java:302) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHa
ndPathRule.java:147) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(Resourc
eClassRule.java:108) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHa
ndPathRule.java:147) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(R
ootResourceClassesRule.java:84) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequ
est(WebApplicationImpl.java:1542) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequ
est(WebApplicationImpl.java:1473) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleReque
st(WebApplicationImpl.java:1419) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleReque
st(WebApplicationImpl.java:1409) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponen
t.java:409) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(Servlet
Container.java:558) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(Servlet
Container.java:733) [jersey-bundle-1.19.jar:1.19]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-s
ervlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHand
ler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.hand
leRequest(ServletSecurityRoleHandler.java:61)
[undertow-servlet-1.0.15.Final.jar :1.0.15.Final]
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(
ServletDispatchingHandler.java:36)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Fin al]
at org.wildfly.extension.undertow.security.SecurityContextAssociationHan
dler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandle
r.handleRequest(SSLInformationAssociationHandler.java:113)
[undertow-servlet-1.0 .15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandle
r.handleRequest(ServletAuthenticationCallHandler.java:56)
[undertow-servlet-1.0.
15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRe
quest(AbstractConfidentialityHandler.java:45)
[undertow-core-1.0.15.Final.jar:1.
0.15.Final]
at io.undertow.servlet.handlers.security.ServletConfidentialityConstrain
tHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
[underto w-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleR
equest(AuthenticationMechanismsHandler.java:58)
[undertow-core-1.0.15.Final.jar:
1.0.15.Final]
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandl
er.handleRequest(CachedAuthenticatedSessionHandler.java:70)
[undertow-servlet-1.
0.15.Final.jar:1.0.15.Final]
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(Se
curityInitialHandler.java:76)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.han
dleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH
andler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest
(ServletInitialHandler.java:240)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final ]
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(Se
rvletInitialHandler.java:227)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(Servlet
InitialHandler.java:73)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(Se
rvletInitialHandler.java:146)
[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
[undertow-core-1.0.15.Final.jar:1.0.15.Final]
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:7
27) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142) [rt.jar:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617) [rt.jar:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_45]
any solutions?

Related

Hostname problem with Wildfly 10 and RabbitMQ JDNI configuration

I'm following this documentation to configure JNDI for Wildfly 10 with RabbitMQ
https://www.rabbitmq.com/jms-client.html
The reason i'm using JNDI is to my application has no dependency with any JMS Provider's library. It means, in my application, i use javax.jms-api-2.0.jar only for integration with RabbitMQ or ActiveMQ... later.
This is my configuration in Wildfly standalone.xml file.
<object-factory name="java:global/jms/ConnectionFactory1" module="com.rabbitmq.jms"
class="com.rabbitmq.jms.admin.RMQObjectFactory">
<environment>
<property name="className" value="javax.jms.ConnectionFactory"/>
<property name="virtualHost" value="/"/>
<property name="host" value="rabbitmq_server"/>
<property name="port" value="5672"/>
</environment>
</object-factory>
This is the soure code for integration.
Context context = new InitialContext();
ConnectionFactory connectionFactory
= (ConnectionFactory) context.lookup("java:global/jms/ConnectionFactory1");
if (connectionFactory == null) {
System.out.println("Cannot initiallize connection factory.");
return;
}
Connection connection = connectionFactory.createConnection(
"guest",
"guest");
if (connection == null) {
System.out.println("Initiallize connection failed.");
return;
}
Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
if (session == null) {
System.out.println("Initiallize session failed.");
return;
}
My problem is:
At this configuration,
If i set the value is IP address => it is ok
If I set the value is hostname (already mapping with IP address in my hosts file) => it always create connection to localhost.
Anyone has faced with this issue before?
12:00:12,318 ERROR [stderr] (default task-15) com.rabbitmq.jms.util.RMQJMSException: RabbitMQ connection was refused. RabbitMQ broker may not be available.
12:00:12,319 ERROR [stderr] (default task-15) at com.rabbitmq.jms.admin.RMQConnectionFactory.instantiateNodeConnection(RMQConnectionFactory.java:170)
12:00:12,319 ERROR [stderr] (default task-15) at com.rabbitmq.jms.admin.RMQConnectionFactory.createConnection(RMQConnectionFactory.java:117)
12:00:12,319 ERROR [stderr] (default task-15) at com.mypackage.web.servlet.WhiteListRegistration.test(WhiteListRegistration.java:68)
12:00:12,320 ERROR [stderr] (default task-15) at com.mypackage.web.servlet.WhiteListRegistration.processRequest(WhiteListRegistration.java:106)
12:00:12,320 ERROR [stderr] (default task-15) at com.mypackage.web.servlet.WhiteListRegistration.doPost(WhiteListRegistration.java:180)
12:00:12,320 ERROR [stderr] (default task-15) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
12:00:12,321 ERROR [stderr] (default task-15) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
12:00:12,321 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
12:00:12,321 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
12:00:12,322 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
12:00:12,322 ERROR [stderr] (default task-15) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
12:00:12,323 ERROR [stderr] (default task-15) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
12:00:12,323 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
12:00:12,324 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
12:00:12,325 ERROR [stderr] (default task-15) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
12:00:12,325 ERROR [stderr] (default task-15) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
12:00:12,326 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
12:00:12,326 ERROR [stderr] (default task-15) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
12:00:12,327 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
12:00:12,327 ERROR [stderr] (default task-15) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
12:00:12,327 ERROR [stderr] (default task-15) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
12:00:12,327 ERROR [stderr] (default task-15) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
12:00:12,328 ERROR [stderr] (default task-15) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
12:00:12,328 ERROR [stderr] (default task-15) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
12:00:12,328 ERROR [stderr] (default task-15) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
12:00:12,329 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
12:00:12,380 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
12:00:12,381 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
12:00:12,381 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
12:00:12,381 ERROR [stderr] (default task-15) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
12:00:12,381 ERROR [stderr] (default task-15) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
12:00:12,381 ERROR [stderr] (default task-15) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
12:00:12,381 ERROR [stderr] (default task-15) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
12:00:12,381 ERROR [stderr] (default task-15) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
12:00:12,382 ERROR [stderr] (default task-15) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
12:00:12,382 ERROR [stderr] (default task-15) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
12:00:12,382 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
12:00:12,383 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
12:00:12,383 ERROR [stderr] (default task-15) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
12:00:12,384 ERROR [stderr] (default task-15) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
12:00:12,384 ERROR [stderr] (default task-15) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
12:00:12,385 ERROR [stderr] (default task-15) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
12:00:12,386 ERROR [stderr] (default task-15) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
12:00:12,387 ERROR [stderr] (default task-15) at java.lang.Thread.run(Thread.java:748)
12:00:12,391 ERROR [stderr] (default task-15) Caused by: java.net.ConnectException: Connection refused: connect
12:00:12,392 ERROR [stderr] (default task-15) at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
12:00:12,393 ERROR [stderr] (default task-15) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
12:00:12,394 ERROR [stderr] (default task-15) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
12:00:12,394 ERROR [stderr] (default task-15) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
12:00:12,394 ERROR [stderr] (default task-15) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
12:00:12,396 ERROR [stderr] (default task-15) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
12:00:12,397 ERROR [stderr] (default task-15) at java.net.Socket.connect(Socket.java:589)
12:00:12,398 ERROR [stderr] (default task-15) at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60)
12:00:12,398 ERROR [stderr] (default task-15) at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62)
12:00:12,398 ERROR [stderr] (default task-15) at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:156)
12:00:12,398 ERROR [stderr] (default task-15) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1106)
12:00:12,399 ERROR [stderr] (default task-15) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1063)
12:00:12,434 ERROR [stderr] (default task-15) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1021)
12:00:12,434 ERROR [stderr] (default task-15) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1182)
12:00:12,435 ERROR [stderr] (default task-15) at com.rabbitmq.jms.admin.RMQConnectionFactory.instantiateNodeConnection(RMQConnectionFactory.java:159)
12:00:12,435 ERROR [stderr] (default task-15) ... 43 more
Ya, i just found out that the hostname cannot contains some special character such as _.
Then i removed this from rabbitmq_server to rabbitmqserver then everything is good now.
Hope someone get the issue like me can fix it follow this.

Download file from a remote server with Rest API using JAX RS

I need to download file from a remote server using JAX RS and this is my code:
package rest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
#Path("/restwb")
public class FileResource {
#GET
#Path("/{companyName}/{Type}/{cl}/{fname}")
#Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response downloadFile(#PathParam("fname") String fileName, #PathParam("companyName") String CompName,
#PathParam("Type") String Type, #PathParam("cl") String cl) throws FileNotFoundException {
Response response = null;
try {
File file = new File(getClass().getClassLoader()
.getResource(CompName + "/" + Type + "/" + cl + "/" + fileName + ".png").getFile());
FileInputStream inputStream = new FileInputStream(file);
ResponseBuilder rb = Response.ok(inputStream);
rb.header("Content-Disposition", "attachment; filename=" + file.getName());
response = rb.build();
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
}
My Question is how can i save an image in my remote server and then to download it.I test it in localhost it work correctly but if i test it in remote server i can 't to save and download.
2019-03-11 13:20:48,385 INFO
[com.sun.jersey.server.impl.application.WebApplicationImpl]
(ServerService Thread Pool -- 71) Initiating Jersey application,
version 'Jersey: 1.19.2 08/25/2016 12:00 AM' 2019-03-11 13:20:49,300
INFO [org.wildfly.extension.undertow] (ServerService Thread Pool --
71) WFLYUT0021: Registered web context: /RestWS 2019-03-11
13:20:49,321 INFO [org.jboss.as.server] (External Management Request
Threads -- 7) WFLYSRV0010: Deployed "RestWS.war" (runtime-name :
"RestWS.war") 2019-03-11 13:24:54,763 ERROR [stderr] (default task-8)
java.io.FileNotFoundException:
/content/RestWS.war/WEB-INF/classes/Intercable/IOS/Iphone/a_red.png
(No such file or directory) 2019-03-11 13:24:54,764 ERROR [stderr]
(default task-8) at java.io.FileInputStream.open0(Native Method)
2019-03-11 13:24:54,764 ERROR [stderr] (default task-8) at
java.io.FileInputStream.open(FileInputStream.java:195) 2019-03-11
13:24:54,764 ERROR [stderr] (default task-8) at
java.io.FileInputStream.(FileInputStream.java:138) 2019-03-11
13:24:54,764 ERROR [stderr] (default task-8) at
rest.FileResource.downloadFile(FileResource.java:43) 2019-03-11
13:24:54,765 ERROR [stderr] (default task-8) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2019-03-11
13:24:54,765 ERROR [stderr] (default task-8) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2019-03-11 13:24:54,765 ERROR [stderr] (default task-8) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2019-03-11 13:24:54,765 ERROR [stderr] (default task-8) at
java.lang.reflect.Method.invoke(Method.java:498) 2019-03-11
13:24:54,765 ERROR [stderr] (default task-8) at
com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
2019-03-11 13:24:54,765 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
2019-03-11 13:24:54,768 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
2019-03-11 13:24:54,768 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
2019-03-11 13:24:54,768 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
2019-03-11 13:24:54,768 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
2019-03-11 13:24:54,768 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
2019-03-11 13:24:54,768 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
2019-03-11 13:24:54,768 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
2019-03-11 13:24:54,768 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
2019-03-11 13:24:54,769 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
2019-03-11 13:24:54,769 ERROR [stderr] (default task-8) at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
2019-03-11 13:24:54,769 ERROR [stderr] (default task-8) at
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
2019-03-11 13:24:54,769 ERROR [stderr] (default task-8) at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
2019-03-11 13:24:54,769 ERROR [stderr] (default task-8) at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
2019-03-11 13:24:54,769 ERROR [stderr] (default task-8) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
2019-03-11 13:24:54,769 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
2019-03-11 13:24:54,769 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
2019-03-11 13:24:54,769 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
2019-03-11 13:24:54,770 ERROR [stderr] (default task-8) at
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
2019-03-11 13:24:54,770 ERROR [stderr] (default task-8) at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2019-03-11 13:24:54,770 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
2019-03-11 13:24:54,770 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
2019-03-11 13:24:54,770 ERROR [stderr] (default task-8) at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2019-03-11 13:24:54,770 ERROR [stderr] (default task-8) at
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
2019-03-11 13:24:54,770 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
2019-03-11 13:24:54,770 ERROR [stderr] (default task-8) at
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
2019-03-11 13:24:54,771 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
2019-03-11 13:24:54,771 ERROR [stderr] (default task-8) at
io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
2019-03-11 13:24:54,771 ERROR [stderr] (default task-8) at
io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
2019-03-11 13:24:54,772 ERROR [stderr] (default task-8) at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2019-03-11 13:24:54,772 ERROR [stderr] (default task-8) at
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
2019-03-11 13:24:54,772 ERROR [stderr] (default task-8) at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2019-03-11 13:24:54,772 ERROR [stderr] (default task-8) at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
2019-03-11 13:24:54,772 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
2019-03-11 13:24:54,772 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
2019-03-11 13:24:54,772 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
2019-03-11 13:24:54,773 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
2019-03-11 13:24:54,773 ERROR [stderr] (default task-8) at
io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
2019-03-11 13:24:54,773 ERROR [stderr] (default task-8) at
io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
2019-03-11 13:24:54,773 ERROR [stderr] (default task-8) at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
2019-03-11 13:24:54,773 ERROR [stderr] (default task-8) at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
2019-03-11 13:24:54,773 ERROR [stderr] (default task-8) at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
2019-03-11 13:24:54,773 ERROR [stderr] (default task-8) at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
2019-03-11 13:24:54,773 ERROR [stderr] (default task-8) at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
2019-03-11 13:24:54,774 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
2019-03-11 13:24:54,774 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
2019-03-11 13:24:54,774 ERROR [stderr] (default task-8) at
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
2019-03-11 13:24:54,774 ERROR [stderr] (default task-8) at
io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
2019-03-11 13:24:54,774 ERROR [stderr] (default task-8) at
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
2019-03-11 13:24:54,774 ERROR [stderr] (default task-8) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2019-03-11 13:24:54,774 ERROR [stderr] (default task-8) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2019-03-11 13:24:54,774 ERROR [stderr] (default task-8) at
java.lang.Thread.run(Thread.java:748)

JMS + Wildfly 8.2.0 Final: The following keys are invalid for configuring a connector: http-upgrade-endpoint

I'm trying to use JMS on Wildfly 8.2.0.
I created one queue called GrinderRemoteQueue with jndi name java:jboss/exported/jms/queue/grinderRemote, using the default Remote Connection Factory. Below there is the section of standalone-full.xml config file for jms configuration.
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
<hornetq-server>
<journal-file-size>102400</journal-file-size>
<connectors>
<http-connector name="http-connector" socket-binding="http">
<param key="http-upgrade-endpoint" value="http-acceptor"/>
</http-connector>
<http-connector name="http-connector-throughput" socket-binding="http">
<param key="http-upgrade-endpoint" value="http-acceptor-throughput"/>
<param key="batch-delay" value="50"/>
<param key="host" value="127.0.0.1"/>
<param key="port" value="5445"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
</connectors>
<acceptors>
<http-acceptor http-listener="default" name="http-acceptor"/>
<http-acceptor http-listener="default" name="http-acceptor-throughput">
<param key="batch-delay" value="50"/>
<param key="direct-deliver" value="false"/>
<param key="host" value="127.0.0.1"/>
<param key="port" value="5445"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
</acceptors>
<security-settings>
<security-setting match="#">
<permission type="send" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
</security-setting>
</security-settings>
<address-settings>
<address-setting match="#">
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
<expiry-address>jms.queue.ExpiryQueue</expiry-address>
<max-size-bytes>10485760</max-size-bytes>
<page-size-bytes>2097152</page-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
</address-setting>
</address-settings>
<jms-connection-factories>
<connection-factory name="InVmConnectionFactory">
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/ConnectionFactory"/>
</entries>
</connection-factory>
<connection-factory name="RemoteConnectionFactory">
<connectors>
<connector-ref connector-name="http-connector"/>
</connectors>
<entries>
<entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
</entries>
</connection-factory>
<pooled-connection-factory name="hornetq-ra">
<transaction mode="xa"/>
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/JmsXA"/>
<entry name="java:jboss/DefaultJMSConnectionFactory"/>
</entries>
</pooled-connection-factory>
</jms-connection-factories>
<jms-destinations>
<jms-queue name="ExpiryQueue">
<entry name="java:/jms/queue/ExpiryQueue"/>
</jms-queue>
<jms-queue name="DLQ">
<entry name="java:/jms/queue/DLQ"/>
</jms-queue>
<jms-queue name="GrinderRemoteQueue">
<entry name="java:jboss/exported/jms/queue/grinderRemote"/>
<durable>true</durable>
</jms-queue>
</jms-destinations>
</hornetq-server>
</subsystem>
For test this configuration I created a new Dynamic Web Project in Eclipse Luna, using the following class:
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSContext;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.hornetq.jms.client.HornetQConnectionFactory;
public class TestJMS {
public void Test() throws NamingException, JMSException {
HornetQConnectionFactory connectionFactory = null;
Connection connection = null;
Session session = null;
MessageProducer producer = null;
MessageConsumer consumer = null;
Destination destination = null;
TextMessage message = null;
Context context = null;
try {
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
env.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
env.put(Context.SECURITY_PRINCIPAL, "jmsuser");
env.put(Context.SECURITY_CREDENTIALS, "*********");
context = new InitialContext(env);
connectionFactory = (HornetQConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
System.out.println("lookup: jms/GrinderRemoteConnectionFactory success!");
destination = (Destination) context.lookup("jms/queue/grinderRemote");
System.out.println("lookup: java:/jms/queue/grinderRemote success!");
JMSContext createContext = connectionFactory.createContext("jmsuser", "Logitech550!", JMSContext.AUTO_ACKNOWLEDGE);
System.out.println("connectionFactory.createContext success!");
createContext.createConsumer(destination);
System.out.println("createContext.createConsumer success!");
connection = connectionFactory.createConnection("jmsuser", "your password");
System.out.println("connectionFactory.createConnection success!");
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(destination);
System.out.println("session.createProducer success!");
connection.start();
int count = Integer.parseInt("1");
String content = "Hello, World!";
// Send the specified number of messages
for (int i = 0; i < count; i++) {
message = session.createTextMessage(content);
producer.send(message);
System.out.println("Message sent successfully: " + message);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (context != null) {
context.close();
}
// closing the connection takes care of the session, producer, and consumer
if (connection != null) {
connection.close();
}
}
}
}
Running this class I got this output:
18:23:50,323 INFO [stdout] (default task-2) lookup: jms/GrinderRemoteConnectionFactory success!
18:23:50,341 INFO [stdout] (default task-2) lookup: java:/jms/queue/grinderRemote success!
18:23:50,374 ERROR [stderr] (default task-2) javax.jms.JMSRuntimeException: Failed to create session factory
18:23:50,374 ERROR [stderr] (default task-2) at org.hornetq.jms.client.JmsExceptionUtils.convertToRuntimeException(JmsExceptionUtils.java:86)
18:23:50,375 ERROR [stderr] (default task-2) at org.hornetq.jms.client.HornetQConnectionFactory.createContext(HornetQConnectionFactory.java:152)
18:23:50,375 ERROR [stderr] (default task-2) at it.vr.pms.TestJMS.Test(TestJMS.java:62)
18:23:50,375 ERROR [stderr] (default task-2) at it.vr.pms.Base.doGet(Base.java:81)
18:23:50,375 ERROR [stderr] (default task-2) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
18:23:50,376 ERROR [stderr] (default task-2) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
18:23:50,376 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
18:23:50,376 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
18:23:50,376 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
18:23:50,377 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
18:23:50,377 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
18:23:50,377 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
18:23:50,378 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
18:23:50,378 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
18:23:50,378 ERROR [stderr] (default task-2) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
18:23:50,379 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63)
18:23:50,379 ERROR [stderr] (default task-2) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
18:23:50,379 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
18:23:50,379 ERROR [stderr] (default task-2) at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
18:23:50,380 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
18:23:50,380 ERROR [stderr] (default task-2) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
18:23:50,380 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
18:23:50,381 ERROR [stderr] (default task-2) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
18:23:50,381 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)
18:23:50,381 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247)
18:23:50,381 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76)
18:23:50,382 ERROR [stderr] (default task-2) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166)
18:23:50,382 ERROR [stderr] (default task-2) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197)
18:23:50,382 ERROR [stderr] (default task-2) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759)
18:23:50,382 ERROR [stderr] (default task-2) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
18:23:50,383 ERROR [stderr] (default task-2) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
18:23:50,383 ERROR [stderr] (default task-2) at java.lang.Thread.run(Unknown Source)
18:23:50,383 ERROR [stderr] (default task-2) Caused by: javax.jms.JMSException: Failed to create session factory
18:23:50,384 ERROR [stderr] (default task-2) at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:676)
18:23:50,384 ERROR [stderr] (default task-2) at org.hornetq.jms.client.HornetQConnectionFactory.createContext(HornetQConnectionFactory.java:142)
18:23:50,384 ERROR [stderr] (default task-2) ... 30 more
18:23:50,385 ERROR [stderr] (default task-2) Caused by: java.lang.IllegalStateException: The following keys are invalid for configuring a connector: http-upgrade-endpoint
18:23:50,385 ERROR [stderr] (default task-2) at org.hornetq.core.client.impl.ClientSessionFactoryImpl.checkTransportKeys(ClientSessionFactoryImpl.java:1507)
18:23:50,385 ERROR [stderr] (default task-2) at org.hornetq.core.client.impl.ClientSessionFactoryImpl.<init>(ClientSessionFactoryImpl.java:207)
18:23:50,385 ERROR [stderr] (default task-2) at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:867)
18:23:50,386 ERROR [stderr] (default task-2) at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:672)
I think that the main problem is java.lang.IllegalStateException: The following keys are invalid for configuring a connector: http-upgrade-endpoint, but I can't understand where I'm wrong.
Thanks in advance for replies.
Enrico
Update all libraries on your client to use wildfly libraries but not jbossAS'
-hornet (module)
-jboss-client (it's at bin/client directory)
-remoting (module)
-etc (module)

Invoking servlet from java

I'm trying to write a java class named Sender.java that invoke a servlet.
This is the code for Sender.java :
public class Sender {
public static void main(String args[]){
try{
URL gwtServlet = new URL("http://localhost/FileReceiver/Receiver");
HttpURLConnection servletConnection = (HttpURLConnection) gwtServlet.openConnection();
servletConnection.setRequestMethod("POST");
servletConnection.setDoOutput(true);
servletConnection.setDoInput(true);
servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches (false);
OutputStream os = servletConnection.getOutputStream();
ObjectOutputStream out = new ObjectOutputStream(os);
out.writeInt(1);
out.flush();
out.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
and here the code for the servlet Receiver.java :
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
InputStream is = request.getInputStream();
//until here is ok
ObjectInputStream ois = new ObjectInputStream(is);
int p = ois.readInt();
writer.println("the number p is : " + p);
ois.close();
} catch (Exception exc) {
exc.printStackTrace();
}
}
When I try to run on server (WildFly 8.x) the servlet, I have this error:
14:52:20,193 ERROR [stderr] (default task-7) java.io.EOFException
14:52:20,193 ERROR [stderr] (default task-7) at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
14:52:20,193 ERROR [stderr] (default task-7) at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
14:52:20,193 ERROR [stderr] (default task-7) at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
14:52:20,193 ERROR [stderr] (default task-7) at java.io.ObjectInputStream.<init>(Unknown Source)
14:52:20,193 ERROR [stderr] (default task-7) at fileServlet.servlet.Receiver.doPost(Receiver.java:67)
14:52:20,193 ERROR [stderr] (default task-7) at fileServlet.servlet.Receiver.doGet(Receiver.java:46)
14:52:20,193 ERROR [stderr] (default task-7) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
14:52:20,193 ERROR [stderr] (default task-7) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
14:52:20,193 ERROR [stderr] (default task-7) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
14:52:20,193 ERROR [stderr] (default task-7) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
14:52:20,193 ERROR [stderr] (default task-7) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
14:52:20,194 ERROR [stderr] (default task-7) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
14:52:20,194 ERROR [stderr] (default task-7) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
14:52:20,194 ERROR [stderr] (default task-7) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
14:52:20,194 ERROR [stderr] (default task-7) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
14:52:20,194 ERROR [stderr] (default task-7) at java.lang.Thread.run(Unknown Source)
I got that the problem is about InputStream is = request.getInputStream(); because I can see this from the debugger (is is null) but I don't know why this happens.
Can someone help me? thank you in advance.
If you want to do an HTTP POST from a Java client to a Servlet, the following requirement must be met:
The Content-Type header must be application/x-www-form-urlencoded. This is usually the default. If you want to send file data or any relevant data stream set your Content-Type to multipart/form-data. This requires the information sent to conform to RFC2388.
Values sent from the connection OutputStream to the Servlet must be an encoded (application/x-www-form-urlencoded) key/value pair (separated by a &).
The Content-Length header must be the length of the encoded value mentioned in 2 or the length of all data that you're willing to send to the server/servlet.
On the Servlet side, you can use request.getParameter() method (passing the parameter key) to obtain its value. For multipart/form-data, you can then use request.getInputStream().
I hope this helps. A brilliant example, written by BalusC on StackOverflow, on how to fire HTTP POST in Java can be found here.

Email sending in a Java Webapplication

I'm writing a webapp in Java. In this webapp I will send emails to the users. When I execute the application I get an error message. I use the same source code in another Java program. In that program I get no errors.
Source code:
public class MailUtil {
public static Session getGMailSession(String user, String pass){
final Properties props = new Properties();
//Eigenschaften zum Sende einer Mail mit GMail
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.smtp.port", "465");
props.setProperty("mail.smtp.socketFactory.port", "465");
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.smtp.socketFactory.fallback", "false");
return Session.getInstance(props, new javax.mail.Authenticator(){
#Override protected PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication (props.getProperty("mail.pop3.user"),props.getProperty("mail.pop3.password"));
}//endof Methode getPasswordAuthentication
});//endOf getInstance
}//endOf Methode getGMailSession
//Die Methode postMail versendet eine Mail
public static void postMail(String recipient, String subject, String message){
Session session = MailUtil.getGMailSession("user", "password");
try{
Message msg = new MimeMessage(session);
msg.setSubject(subject);
msg.setContent(message, "text/plain");
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
Transport.send(msg);
}
catch(MessagingException e){
System.out.println("Error in this Method");
System.out.println("Cause: " +e.getMessage());
e.printStackTrace();
}
}
}
And here is the error message:
10:27:50,014 INFO [stdout] (default task-16) **Error in this Method**
10:27:50,014 INFO [stdout] (default task-16) Cause: failed to connect, no user name specified?
10:27:50,015 ERROR [stderr] (default task-16) javax.mail.AuthenticationFailedException: failed to connect, no user name specified?
10:27:50,016 ERROR [stderr] (default task-16) at javax.mail.Service.connect(Service.java:376)
10:27:50,016 ERROR [stderr] (default task-16) at javax.mail.Service.connect(Service.java:226)
10:27:50,016 ERROR [stderr] (default task-16) at javax.mail.Service.connect(Service.java:175)
10:27:50,017 ERROR [stderr] (default task-16) at javax.mail.Transport.send0(Transport.java:253)
10:27:50,017 ERROR [stderr] (default task-16) at javax.mail.Transport.send(Transport.java:124)
10:27:50,017 ERROR [stderr] (default task-16) at de.hskl.lernanalyse.utilities.MailUtil.postMail(MailUtil.java:50)
10:27:50,018 ERROR [stderr] (default task-16) at de.hskl.lernanalyse.controller.TokenGenController.doGeneriereLink(TokenGenController.java:77)
10:27:50,018 ERROR [stderr] (default task-16) at de.hskl.lernanalyse.controller.TokenGenController.doSendeEmail(TokenGenController.java:108)
10:27:50,018 ERROR [stderr] (default task-16) at de.hskl.lernanalyse.controller.TokenGenController$Proxy$_$$_WeldClientProxy.doSendeEmail(Unknown Source)
10:27:50,019 ERROR [stderr] (default task-16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:27:50,025 ERROR [stderr] (default task-16) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
10:27:50,025 ERROR [stderr] (default task-16) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:27:50,026 ERROR [stderr] (default task-16) at java.lang.reflect.Method.invoke(Method.java:606)
10:27:50,026 ERROR [stderr] (default task-16) at javax.el.ELUtil.invokeMethod(ELUtil.java:308)
10:27:50,026 ERROR [stderr] (default task-16) at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
10:27:50,027 ERROR [stderr] (default task-16) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
10:27:50,027 ERROR [stderr] (default task-16) at com.sun.el.parser.AstValue.invoke(AstValue.java:269)
10:27:50,027 ERROR [stderr] (default task-16) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
10:27:50,027 ERROR [stderr] (default task-16) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
10:27:50,028 ERROR [stderr] (default task-16) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
10:27:50,029 ERROR [stderr] (default task-16) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
10:27:50,029 ERROR [stderr] (default task-16) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
10:27:50,030 ERROR [stderr] (default task-16) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
10:27:50,031 ERROR [stderr] (default task-16) at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
10:27:50,031 ERROR [stderr] (default task-16) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
10:27:50,032 ERROR [stderr] (default task-16) at javax.faces.component.UICommand.broadcast(UICommand.java:315)
10:27:50,032 ERROR [stderr] (default task-16) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
10:27:50,033 ERROR [stderr] (default task-16) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
10:27:50,033 ERROR [stderr] (default task-16) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
10:27:50,034 ERROR [stderr] (default task-16) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
10:27:50,035 ERROR [stderr] (default task-16) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
10:27:50,035 ERROR [stderr] (default task-16) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
10:27:50,035 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
10:27:50,036 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
10:27:50,037 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
10:27:50,037 ERROR [stderr] (default task-16) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
10:27:50,038 ERROR [stderr] (default task-16) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
10:27:50,039 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
10:27:50,039 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
10:27:50,040 ERROR [stderr] (default task-16) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
10:27:50,041 ERROR [stderr] (default task-16) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
10:27:50,041 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
10:27:50,042 ERROR [stderr] (default task-16) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
10:27:50,042 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
10:27:50,043 ERROR [stderr] (default task-16) at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
10:27:50,043 ERROR [stderr] (default task-16) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
10:27:50,045 ERROR [stderr] (default task-16) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
10:27:50,045 ERROR [stderr] (default task-16) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
10:27:50,053 ERROR [stderr] (default task-16) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
10:27:50,053 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
10:27:50,054 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
10:27:50,054 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
10:27:50,055 ERROR [stderr] (default task-16) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
10:27:50,055 ERROR [stderr] (default task-16) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
10:27:50,056 ERROR [stderr] (default task-16) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
10:27:50,056 ERROR [stderr] (default task-16) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
10:27:50,056 ERROR [stderr] (default task-16) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
10:27:50,057 ERROR [stderr] (default task-16) at java.lang.Thread.run(Thread.java:745)
You have missed the ,
msg.setFrom(username);
method ,which should be configured to send the email from your account.
As docs says.
Set the "From" attribute in this Message. The value of this attribute
is obtained from the property "mail.user". If this property is absent,
the system property "user.name" is used.
And also read this thread JavaMail API, Gmail-Auth and setFrom
First, fix all of these common mistakes.
Second, read this JavaMail FAQ entry on Gmail.
If you still can't get it to work and are getting the same error, tell us what debugging you've done to prove that you're specifying a user name when connecting. You might want to look at these debugging tips.

Categories