Sergei Zhylinski

Ranch Hand
+ Follow
since Nov 15, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
23
Received in last 30 days
0
Total given
35
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sergei Zhylinski

Now I think that no. The beans.xml configuration file is not used to declare beans. It mainly indicates that the archive is a candidate for bean scan. The CDI implementations use only bean scan similar to component scan in Spring. It dosn't assume explicitely registering any of the beans in the config.
Hello,

I'm familiarizing myself with CDI. I've started with the standalone applications. I'm using Jboss Weld for this. I can't really create several beans of the same type. Spring framework in contrast allows to register several beans in XML configuration file of the same type but with different bean names/ids:



After that I'm able to retrieve a bean from the context by its name:



But all the tutorials found in the net devoted to CDI and Weld have similar code example:



Is it possible to create several performers and put them into CDI META-INF/beans.xml file?
Hello to Everyone,

I'm learning about the SOAP actor and mustUnderstand attributes.

I use the following maretials:
1) The Java EE 5 Tutorial (SAAJ topic) (https://docs.oracle.com/cd/E19159-01/819-3669/bnbij/index.html)
2) SOAP 1.1 (sections 4.2.2, 4.2.3) (https://www.w3.org/TR/2000/NOTE-SOAP-20000508/)
3) Java Web Services. Up and Running [M. Kalin]

The actor attribute is used by intermediaries that are capable of both receiving and sending messages. As I understand the intermediary is not a simple soap handler but a standalone web service endpoint with its own WSDL.

Unfortunately the sources I use are lack of complete examples. Could someone show the entire working example of a client that sends a message to a receiver through one intermediary? How does an intermediary forwards messages to other receivers?
Hi to everyone,

I downloaded Enthuware trial tests. One of tasks was to choose a correct JAX-RS resources implementation by EJB component. The right answers were:



But I can't create such a resource by myself. The beans are deployed and registered on containers successfully but when I try to access them through a client (browser) I am always getting 404 error.

Is this sample is a correct EJB implementation? Must the bean be packaged is a ejb or war module, what are the other ways to create JAX-RS root resources as EJB 3.1 beans?
Hi to everyone,

Could someone please help with the issue. I would like to get acquainted with REST in different application servers. At the moment I'm deploying a simple REST application on Glassfish 3.1.2.

As per section 2.3.2 JSR 311, JAX-RS, Java API for RESTful Web Services 1.0: ""When using a JAX-RS aware servlet container, the 'servlet-class' element of the 'web.xml' descriptor SHOULD name the application supplied subclass of 'Application'. <...> When using a non-JAX-RS aware servlet container, the 'servlet-class' element of the 'web.xml' descriptor SHOULD name the JAX-RS implementation-supplied Servlet class. The application-supplied subclass of 'Application' is identified using an 'init-param' with a 'param-name' of 'javax.ws.rs.Application'."

I assume that Glassfish 3 is JAX-RS aware servlet container and try do the following.

My web.xml descriptor:



Class 'com.sze.EchoApplication':



The only 'com.sze.Echo' resource:



But when I send the request like 'http://127.0.0.1:8080/testprj/services/echo?input=some_input' II'm always receiving the error:



The code above does is executed successfuly on JBoss EAP 6/Wildfly.

7 years ago
HI Everyone,

I know that the default welcome file list in the deployment descriptor includes not only index.htm(l) but index.jsp too. A user can create servlet mapping manually to make a servlet catch requests targeted to JSP pages too:


<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.4">
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>testproject.TestServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
</web-app>



I wonder whether it is userful. JSP is a servlet as well. When a request comes to a JSP page a container generates code and stores it somewhere (particularly, Tomcat puts it into $CATALINA_HOME\work directory). So when a mapping exists that makes a servlet catch JSP page requests, the container will not generate code for a JSP page and will not run it. Could someone please suggest when it is appropriate to create such mappings?
8 years ago

Kirk Rohani wrote:

I don't understand why I can create SomeClass<T> and pass in a string literal into the constructor and assign it to a variable of type <T> and it infers/figures out that it is a string but as you proved I cannot create a generic method and assign a string literal it to a variable of type <R>.

That is really what I am wanting to understand, why it works with a generic class but not a generic method??



Type inference works for generic methods and generic class instantiations and is used by a compiler: "Type inference takes place in code which is creating an instance of a generic type, or which is calling a method of a generic type. It doesn't take place in the declaration of a generic type.
".



Reference 'sc' has a raw type. A raw type (in comparson to parameterized type 'SomeClass<String>') is used for legacy code, when a library doesn't support java 5 or higher. The compiler sees that it is a legacy code (not because it uses type inference for a class) and compiles it, but with warnings. But I think there are no such libraries so I suggest not using raw types at all. JVM is not aware of generics. The compiler will replace all type parameters by their bounds (the bound for 'T' or 'T extends Object' is 'Object') in generic types definitions and erase type arguments in parameterized references. All the JVM will see is:



That is why your code will work:



To use type inference during generic class instantiation a diamond should be used:

Hi,

Your code leads to an evident compile time error. Your type parameter 'R' says that the generic method can take any type argument, 'String', 'CharSequence', 'Number', 'Object'. Lets simplify your code with only one type parameter. I'll create a method inside a regular class:



I explicitly say that the generic method has a bounded type parameter 'R extends Object'. Also I explicitly provide a type argument 'Number' to my generic method. As you can see not only strings can be passed to the generic method. It doesn't matter if the generic method is invoked inside class definition or outside it.
Hi Everyone,

I am learning Criteria API, particularly the 'in' keyword. Possible usages of this keyword in JPQL in 'where' clause are:
1. to check whether a single-valued path expression is a member of a collection ("select e from Employee e where e.age in (23, 24, 25)")
2. in a subquery (select e from Employee e where e.department in ("select d from Department d where d.name = 'Personnel Department')")

The 'in' keyword can also be used with the 'from' keyword where it represents a member of the collection in the multivalued association (i.e. one-to-many). A sample JPQL query is like this "select d, e from Department d, in(d.employees) e". Found in Java EE tutorial

The first two cases are quit straightforward to write via Criteria API. Could someone please advise, how to write the third query using Criteria API?
Hi Everyone,

I'm experiencing an issue with maven goals order, that are registered to one phase "clean" that belongs to the clean lifecycle. I have a little project on EJB. All the beans (indeed, only one stateless bean there) are to be deployed on TomEE AS. So I use tomee-maven-plugin to stop/start the server, deploy/undeploy the jar module. My pom.xml is as follows:



The goal "tomee:stop" stops the server, the goal "tomee:start" starts the server, the goals "tomee:deploy" and "tomee:undeploy" deploy and undeploy my module respectively.

When I execute



It starts the server and deploys application. I can see the result via this command:



But when I try to stop the server and clean the project (mvn clean) first I obtain the error message:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mvn-firstejb-tomee 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ mvn-firstejb-tomee ---
[INFO] Deleting D:\Tmp_f\mvn-firstejb-tomee\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.720s
[INFO] Finished at: Sun May 31 15:01:37 GMT+03:00 2015
[INFO] Final Memory: 4M/115M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project mvn-firstejb-tomee: Failed to clean project: Failed to delete D:\Tmp_f\mvn-firstejb-tomee\target\mvn-firstejb-tomee.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException



There are two goals registered to the clean phase of my project. One goal ("tomee:stop") belongs to tomee-maven-plugin and the other("clean:clean") belongs to maven-clean-plugin. I generated effective pom for my project and got that maven-clean-plugin goes after tomee-maven-plugin, so as I understand, it should be executed after tomee plugin:



But nevertheless, maven-clean-plugin is executed first (see the error message above). But the jar module is locked by the server and cannot be deleted.

As per this link: "The goals that are configured will be added to the goals already bound to the lifecycle from the packaging selected. If more than one goal is bound to a particular phase, the order used is that those from the packaging are executed first, followed by those configured in the POM."

So the goal "clean:clean" is already bound to the clean phase of the clean lifecycle by jar packaging specification. That is why it is executed first.

Could someone please suggest whether it is possible to run goals, specified in the pom.xml before the goals that are assumed by packaging as defaults and what is the workaround for my issue?
8 years ago
Thanks for everyone, who has read the topic and is willing to help. I managed to cope with this by myself. I should have read this article first. I have also found the topic on CodeRanch about this issue. So my remote client should look as follows:



Thanks again.
Hi Everyone,

Could someone please help to cope with JNDI naming in WildFly? I have deployed a simple stateless session bean into WildFly AS. The output of the server is as follows:

java:global/firstejb/EmployeeServiceBean!com.sze.ejb.EmployeeService
java:app/firstejb/EmployeeServiceBean!com.sze.ejb.EmployeeService
java:module/EmployeeServiceBean!com.sze.ejb.EmployeeService
java:jboss/exported/firstejb/EmployeeServiceBean!com.sze.ejb.EmployeeService
java:global/firstejb/EmployeeServiceBean
java:app/firstejb/EmployeeServiceBean
java:module/EmployeeServiceBean

My bean is a simple transaction scoped stateless session bean with container-managed transaction demarcation:



It has a remote view, so the clients are able to get a reference to it from a separate JVM. My remote client has the following code:



This code works fine with OpenEJB when I specify an OpenEJB context factory. But in WildFly I am always getting the following error:

javax.naming.NameNotFoundException: global/firstejb/EmployeeServiceBean!com.sze.ejb.EmployeeService -- service jboss.naming.context.java.jboss.exported.global.firstejb."EmployeeServiceBean!com.sze.ejb.EmployeeService"
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:202)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Hi Everyone,

Could someone, who has experience with MySQL, help? My question relates to intention locking in InnoDB storage engine, MySQL. I am trying to get full understanding on how InnoDB manages transaction levels and currently reading the MySQL 5.6 Reference Manual, InnoDB Lock Modes section. And I am confused with intention shared and exclusive locks. It is written there that intention locks are table level locks and they indicate that a statement in a transaction willing to acquire a row level lock either for read (shared) or write (exclusive).

My questions are:
1) may I say that intention locking is entirely implicit table level locking; locks of this type are released immediately after the row level shared or exclusive lock was obtained (the execution of "select ... lock in share mode" or "select ... for update", etc. finishes);
2) is it possible to emulate session interaction via command line in order to see, how intention locking work?

Kaxhif Khan wrote:Just let me watch for the answers ... but syntax of assert statement is 1) assert boolean; 2) assert boolean: "message"; so from these two syntax perspective i guess they all are correct.



The usage of the assertions can be (1) correct, (2) appropriate. Correct usage means that the Java syntax, related to assertions is not violated and the compiler doesn't generate any errors. Appropriate usage of the assertions means that although it may be correct it violates the recommendations on where to use assertions in the code.

Anirudh, I would suggest reading this article from the official Oracle website, "Putting Assertions Into Your Code" section. You may also find this information in the preparation books. And then you may post the answers by yourself so that other participants can check and give some other advice.
Hi,

Thanks for your reply. I managed to cope with it finally. It neither belongs to Maven, Gradle nor to an IDE. It was our custom project file.
9 years ago