Win a copy of Spring Boot in Practice this week in the Spring forum!

peter tong

Ranch Hand
+ Follow
since Mar 15, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
1
Total given
63
Given in last 30 days
7
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by peter tong

I follow the tutorial in
https://www.codejava.net/java-ee/web-services/java-crud-restful-web-services-examples-with-jersey-and-tomcat

it can succesffully be run,
Then I create a similar services called  TrainingHistResource, mostly copy from ProductResource in the example, but when I run
http://localhost:8080/EhrmsWs/rest/trainingHist
in postman,
it returns


<h1>HTTP Status 404 – Not Found</h1>



Type Status Report


Message Not Found


Description The origin server did not find a current representation for the target resource or is not
willing to disclose that one exists.




why?

the web.xml is as follow:


the TrainingHistResource.java is as follow:


For comparison, if the request is
http://localhost:8080/EhrmsWs/rest/products
it can go to ProductResource.java successfully

ProductResource.java code is as follow:




21 hours ago
I already has an java web application (a .ear), do I need to create a separate web application (a war) to function as a web service for the .net webapp to call?
or I can just turn some function in my existing .ear as a web service for .net web app to call?
e.g, my application ABC.ear has a function
public boolean updateHistory(){
......
}

can the .net application call this function directly?
or I need to write a separate application (.war) for this function updateHistory and turn it as a web service?
1 week ago
we have an web application build with java, and we want to provide an function for an .net web application to call, and then change the database in our system, how should we start?
I know web service can do that, but is this mean I need to build a new java application for the web service? or I can integrate the web service in my existing java web application?
1 week ago


I have set the DriverManager.setLoginTimeout(10), I expect if the connection cannot success within 10 seconds, it will give up and return a null conn, but the actual result is it wait for about 2 minutes 30 seconds and then return exception, why?
how to make the connection just try for 10 seconds, and if still cannot connect success within 10 seconds, then give up and return null connection?

the error log is


16:01:19,521 INFO  [com.frw.database.DatabaseConnectionFactory] (default task-49) ComConfig.CHUBB_URL:jdbc:sqlserver://xx.xx.xx.xx:1464; DatabaseName=Director
16:01:19,521 INFO  [com.frw.database.DatabaseConnectionFactory] (default task-49) ComConfig.CHUBB_QUERY_USER:DirectorQueryUser
16:03:49,603 ERROR [com.frw.database.DatabaseConnectionFactory] (default task-49) createChubbQueryConnection: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host xx.xx.xx.xx, port 1464 has failed. Error: "Connection timed out: no further information.. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".


2 weeks ago
for specific example



1) if createConnection has exception, then do I need to write a catch block to close the conn?

Another problem, as I have set  DriverManager.setLoginTimeout(10);
if over 10 seconds and still cannot connect, then will it throws exception and go to the catch block
logger.error("error in createConnection()");
?
2 weeks ago
for java try with resource, if there is exception inside the try block, will the connection be closed() automatically?

or need to close in catch block?
2 weeks ago
In jaspersoft studio, I select a field and in Font, I can choose PMingLiu_ExtB, but when preview in jaspersoft studio, the font cannot print properly, but change to some strange symbols

1) if jaspestudio has no PMingLiu_ExtB, why it let me to choose?

2) how to make preview can show the PMingLiu_ExtB properly? I see some font extension solution, but it seem it only for using font that the dropdown list does not provide?




Could help to explain the "booo:and:fooo1o".split("o*", -1) result?
6 months ago
Thanks but I cannot catch the last "0*" explanation....

"You would have had an empty String at the start of some of those arrays if you hadn't used a negative limit for String#split()."
I have try to use some positive limit but no empty String at the start of the resulting arrays.
6 months ago
as stated, given different Greedy quantifiers, how to explain the output?
especially the last "*" quantifiers, why there is two "" empty string matched?



result is


---
8
"b"
""
""
":and:f"
""
""
"1"
""
-use ?-
16
"b"
""
""
""
":"
"a"
"n"
"d"
":"
"f"
""
""
""
"1"
""
""
-use + -
4
"b"
":and:f"
"1"
""
-use * -
12
"b"
""
":"
"a"
"n"
"d"
":"
"f"
""
"1"
""
""

6 months ago

Tim Holloway wrote:

peter tong wrote:

Himai Minh wrote:First of all, have you tried @Autowired instead of @Inject?
Secondly, do you have @ComponentScan (basePackages = "....") //where basePackage is the name of the base package such as "com.example" ?



Oh, yes, after change to @Autowired, apple1 can be injected

But why @Inject cannot?
My classpath has javaee-web-api-8.0-sources.jar.



Because @Inject is a CDI annotation, not a Spring annotation.

@Autowired tells Spring to consult its BeanFactory, construct the bean to be injected (if it's not already existing) and set the property value to reference that bean. @Inject references the CDI container, not Spring.



"@Inject references the CDI container, not Spring.", yes, I try to use @Inject and test in wildfly server, then even @Inject can do what I want.
1 year ago

Himai Minh wrote:First of all, have you tried @Autowired instead of @Inject?
Secondly, do you have @ComponentScan (basePackages = "....") //where basePackage is the name of the base package such as "com.example" ?



Oh, yes, after change to @Autowired, apple1 can be injected

But why @Inject cannot?
My classpath has javaee-web-api-8.0-sources.jar.
1 year ago
I have no used @SpringBootApplication annotation, in fact I am new in spring, I expect Spring container will create and manage the TestController class as it has @Controller annotation and will instantiate, inject its member field.
I have checked my application pom, it has not use spring boot. the pom is as follow:


Is this related?
1 year ago
when enter url http://localhost:8080/MySpringMvc/home/test1, I expect apple1 will be injected but not, its value is null, why?







1 year ago
Oh yes, in \.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xml, I found something



I have deleted and added the server in tomcat many times, but don't know why this settings is still in tmp0\conf\server.xml
1 year ago