- This topic has 8 replies, 3 voices, and was last updated 9 years, 8 months ago by support-tony.
-
AuthorPosts
-
eugenejsnParticipantThis snippet:
public final static void test(Object bean…{
Class beanClass = bean.getClass();
try {
Method[] beanMethods = beanClass.getMethods();actually worked on IBM RAD 8/Websphere 8.
Now I migrated it over to MyEclipse Blue 2014/JBoss AS 7.1.1. The line
Method[] beanMethods = beanClass.getMethods();
silently failed.
Do I miss some libraries? or else?
Thanks
Eugene
support-tonyKeymasterEugene,
I’m afraid I couldn’t replicate the problem. I used that code snippet in a simple Web application, running on JBoss 7.1 and got the output I expected.
Please answer some questions:
- How, exactly are you running the snippet?
- When you say that it fails silently, what do you mean? That it returns null or that it doesn’t return what you expect?
- Could you attach a simple project that shows the problem?
- When you say it worked with RAD and WebSphere, do you mean that the same project ran successfully on WebSphere when launched from RAD, but failed on JBoss when launched from MyEclipse?
eugenejsnParticipant–When you say it worked with RAD and WebSphere, do you mean that the same project ran successfully on WebSphere when launched from RAD, but failed on JBoss when launched from MyEclipse?
–Yes.
Here is the layout of my projects.
WebApp
L (contains the WebContent root, WEB-INF, src, etc)WebApp/src/TestController.java
TestObj obj = new TestObj(); //This is a POJO
Class beanClass = obj.getClass();
Method[] beanMethods = beanClass.getMethods();The above snippet will work, IF I place the TestObj in the WebApp/src/.
In reality, I have another project inside the workspace, called ClassDomain which contains the java classes.
Now I move the TestObj.java to ClassDomain/src/, i.e.,
ClassDomain/src/TestObj.java
Then backto WebApp/src/TestController.java
import domain_path_here.TestObj;
TestObj obj = new TestObj(); //This is a POJO
Class beanClass = obj.getClass();
Method[] beanMethods = beanClass.getMethods();This line Method[] beanMethods = beanClass.getMethods();
will fail for no specific reason. (I do not get any message back, it simply faied). I used the debugger to trace it, it always failed at this line. But no message.Now the WebApp project setting:
Project Reference: ClassDomain
Libraries: Web App Libraries
EAR LIbraries
JBoss & Runtime
Java EE 7 Generic Lib
ClassDomain
JRE System LibMyEclipse/Deployment Assembly
L /src (WEB-INF/classes)
/WebContent (/)ClassDomain project setting:
Project Reference:
Libraries: Web App Libraries
EAR LIbraries
JBoss & Runtime
Java EE 7 Generic Lib
ClassDomain
JRE System LibMyEclipse/Deployment Assembly
L /src (/)This looks like a project reference issue. But import domain_path_here.TestObj; indicate no error.
I believe somehow I did not set the project reference properly. For instance, I create another java project TestDomain inside the same workspace, then create a simple class Test.java and reference this project from the WebApp project. Go to the TestController.java and tries to import this class Test.java, it indicates that the Test is undefined even if I tries the Importing.
If respond to me by end of Friday, would be appreciated so that I can continue working on it on the weekend.
Thanks
Eugene
support-tonyKeymasterEugene,
I’m looking at this outside normal work hours so haven’t got time to investigate it in more detail, sorry. But i just want to ask again what you mean by “fail”. If you are stepping through with the debugger, what happens when you step over the beanClass.getMethods call? Is there an exception? Does it return null or an empty array? The statement that it fails doesn’t really tell me very much to be able to investigate this, though I’ll try to replicate your set up when I get back to work.
If you can set up a couple of simple projects to replicate the issue and attach them, that might help.
boby147MemberThis line Method[] beanMethods = beanClass.getMethods();
will fail for no specific reason. (I do not get any message back, it simply faied). I used the debugger to trace it, it always failed at this line. But no message.
eugenejsnParticipantThanks Tony for the hard work.
If you put an Oracle
private BLOB imgFile;
on the TestObj as I mentioned earlier.
Then the reflection lookup from the controller class will fail the getMethods function for no specific reason.
Thanks
support-tonyKeymasterEugene,
Just checking in on this topic, will try to do more on Monday. I’m confused about what is meant by “fail” when you say the getMethods call is failing. You seem to say that there is no exception, no message, but then how do you know that the method call fails? During execution, a failure is indicated by some exception or the return of a value that you know cannot possibly be correct (though one has to be careful there) or the program suddenly ending at the point of the call, though, even there, there would likely be some core dump.
So how do you know that the call is failing?
eugenejsnParticipantHi Tony,
Once again, thanks for your good effort.
At this point I decide to close this issue. It could be a complex issue. I’ll find some workaround for this.
I have two high priority issues which I posted on the forum. One is the JSP debugging does not stop at the break point, though I follow the normal procedure to set it up (https://www.genuitec.com/forums/topic/debug-does-not-stop-on-jsp/).
The second issue is Output A Java Project’s Classes to WEB-INF/classes (https://www.genuitec.com/forums/topic/output-a-java-project-s-classes-to-web-inf-classes/).
Thanks
Eugene
support-tonyKeymasterEuguene,
Was just about to start looking at this again but I’ll close it as requested. However, I’m still confused by the term “fail”, for the reasons I mentioned. If you can expand on how you know the call fails, please PM me.
-
AuthorPosts