Search This Blog

Showing posts with label Exceptions. Show all posts
Showing posts with label Exceptions. Show all posts

Wednesday, 22 January 2014

org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file :


Recently i faced this Exception while working on a basic spring example...later to my surprize it turned out to be one stupid experience ;-) ...thus thought of sharing the same with an intent that it could save someone else's time...


org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/F:/Projects_Spring/demoProject_dec22/src/mySpring.xml at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:225) at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:186) at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.Main.main(Main.java:73)
Caused by: org.eclipse.wst.xsl.jaxp.debug.invoker.TransformationException: No embedded stylesheet instruction for file: file:/F:/Projects_Spring/demoProject_dec22/src/mySpring.xml at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:214) ... 2 more



It's an Eclipse bug, I've noticed it too. Make sure that you're running the right Eclipse Runtime config (i.e. if you're clicking on the little green "Play" button on the top, thinking it will re-run the last (valid) Runtime you've ran, re-check (by clicking on the down arrow next to it) to make sure no new Runtime has been created).
What I've noticed it that even though I create a perfectlly valid run-time pointing to a Java main class and everyting, which I run a few times and all is ok, after a while, if I select an xml file (because I wanted to edit it for example) and then leave it selected as I click on my run button, Eclipse will create a new XSLT Transformation run time for that xml file and try to run it, failing with the exception you report. The solution is to erase that run time, make sure I have no xml file selected, and re-run the correct run time.

Monday, 11 November 2013

Erros in building service - Error occurred during initialization of VM , Could not reserve enough space for object heap


#### ERROR --

[Console output redirected to file:D:\MTSTravel\.metadata\.plugins\com.liferay.ide.eclipse.sdk\sdk.log]
Buildfile: D:\xxxxxx\plugins-sdk-6.1.1\portlets\mts-portlet\build.xml
build-service:
     [java] Java Result: 1
     [echo] Error occurred during initialization of VM
     [echo] Could not reserve enough space for object heap
     [echo] Error: Could not create the Java Virtual Machine.
     [echo] Error: A fatal exception has occurred. Program will exit.

BUILD FAILED
D:\xxxxxx\plugins-sdk-6.1.1\build-common-plugin.xml:207: Service Builder generated exceptions.
Total time: 6 seconds




#### SOLUTION --

I faced this ExceptionThis is what resolved the issue for me , thus sharing hereby expecting it could be of some help to you as well...

SDK ,change the file build-common-plugin.xml from
<jvmarg value="-Xms512m" />
<jvmarg value="-Xmx1024m" />
to
<jvmarg value="-Xms128m" />
<jvmarg value="-Xmx512m" />

Thursday, 26 September 2013

java.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to net.sf.json.JSONObject


Sep 27, 2013 11:42:56 AM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerExceptionSEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP containerjava.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to net.sf.json.JSONObject

 The Exception is very clear ..
org.json.simple.JSONObject cannot be cast to net.sf.json.JSONObject
since ,  we are using making use of two diff libs here ..

 The problem here is that the "jsonParser.parse("-string-");" will return a org.json.simple.JSONObject (json-simple-1.1.1.jar) && we are trying to store in into a JsonObject vreated via net.sf.json.JSONObject (json-lib-2.2.jar)

 Solution -simply remove the use of "net.sf.json.JSONObject" to create a JsonObject & INSTEAD use org.json.simple.JSONObject create a JsonObject.


 Hence, your code will also be slightly modified given the way you extract key-values going further..

 BEFORE-- 

  //## here the requisite jar(json-simple-1.1.1.jar) for JsonParser is included in the jersey bundle itself..
org.json.simple.parser.JSONParser jsonParser = new JSONParser();

// ## Included json-lib-2.2.jar for using JsonObject ,etc..
net.sf.json.JSONObject jsonObj;
try {
jsonObj = (JSONObject) jsonParser.parse(requestParam);
name = jsonObj.getString("name");
phone = jsonObj.getString("phone");
email = jsonObj.getString("email");

} catch (ParseException e) {
e.printStackTrace();
}

AFTER --

//## here the requisite jar(json-simple-x.x.jar) for JsonParser is included in the jersey bundle itself..
org.json.simple.parser.JSONParser jsonParser = new JSONParser();

// ## Included json-lib-2.2.jar for using JsonObject ,etc..
org.json.simple.JSONObject jsonObj = new JSONObject();
try {
jsonObj = (JSONObject) jsonParser.parse(requestParam);
name = jsonObj.get("name").toString();
phone = jsonObj.get("phone").toString();
email = jsonObj.get("email").toString();

/*phone = jsonObj.getString("phone");
email = jsonObj.getString("email");*/

} catch (ParseException e) {
e.printStackTrace();
}

Monday, 26 August 2013

ANDROID: Connection to http://localhost:8080 refused

I wanted to make an Http Connection to my own WebServices(REST) exposed on another apache- tomcat server , but was getting this error :-
Connection to http://localhost:8080 refused
here's my code:
try{
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://localhost:8080/RestProject/rest/hello/Details");
HttpResponse httpResponse = httpClient.execute(httpGet);
InputStream content = httpResponse.getEntity().getContent();
BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;

}
}

i checked the exposed webservices url it was working fine from the browser , but was surprised to see that my android app was unable to access the same ,being on the same machine..

hereby im sharing the solution that resolved my problem ,hoping it would help you too,

Actually, If you are referring to a localhost from your device(emulator) than use the http://10.0.2.2/ instead of the http://127.0.0.1/ or http://localhost/.
Because your Android emulator is running on a Virtual Machine(QEMU) and you can not connect to a server directly running on your PC.

So your code snippet should be like this:
try{
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://10.0.2.2:8080/RestProject/rest/hello/Details");
HttpResponse httpResponse = httpClient.execute(httpGet);
InputStream content = httpResponse.getEntity().getContent();
BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;

}
}

ie use 10.0.2.2 instead of localhost or 127.0.0.1.



Tuesday, 20 August 2013

Unable to compile class for JSP

----------------------------------------------------------------------------------------------------------------------------------------
Aug 20, 2013 9:08:55 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 2,062 in the generated java file
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit

----------------------------------------------------------------------------------------------------------------------------------------

TRY USING : 
<jsp:include page="/html/crm/customer/child.jsp"/>       
INSTEAD OF
<%@ include file="/html/crm/customer/child.jsp"%> 


Actually, if you think about it there is an extra performance hit with every action tag (@include file) .
For eg: say there are two files Child.jsp & Parent.jsp
where, Parent.jsp needs to include Child.jsp

--------------------( /html/.../Parent.jsp )----------------------------------------------------------------------------------
Try 
<jsp:include page="/html/.../Child.jsp"/>  
rather 
<%@include file="/html/.../Child.jsp"%> 
----------------------------------------------------------------------------------------------------------------------------------------
In case facing this Exception(above mentioned). But the only problem is that u need to remove all the dependencies of Parent from Child.
say,  boolean isAdmin= true;  is defined in Parent.jsp but Child.jsp is also being using this value.Otherwise ,in that case you might again get an exception saying : variable isAdmin in Child.jsp cannot be resolved . 

Because , the include directive(<%@include file=""%>) inserts the source of Child.jsp at translation time but the action tag(<jsp:include page=""/>) inserts the response of Child.jsp at runtime.

ANDROID: An established connection was aborted by the software in your host machine

----------------------------------------------------------------------------------------------
[2013-08-20 22:52:31 - ddmlib]An established connection was aborted by the software in your host machine
java.io.IOException: An established connection was aborted by the software in your host machine
    at sun.nio.ch.SocketDispatcher.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(Unknown Source)
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
    at sun.nio.ch.IOUtil.write(Unknown Source)
    at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
    at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
    at com.android.ddmlib.Client.sendAndConsume(Client.java:573)
    at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:349)
    at com.android.ddmlib.Client.requestAllocationStatus(Client.java:419)
    at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:840)
    at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:808)
    at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:767)
    at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:635)
    at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:42)
    at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:563)

----------------------------------------------------------------------------------------------

These problem can be simply solved by closing Eclipse and restarting it again. Eclipse sometimes fails to establish a connection with the Emulator, so this can happen in some cases.

for eg:
This problem may occur if you have two devices connected to the computer at the same time. Adb does not support reaching both devices via command/console. So, if you debug your app after connecting and disconnecting the second device you will most probably have this problem. One solution might be restarting adb and/or eclipse if necessary. It can be quite annoying sometimes and I am afraid there is no other solution to that.

Also, If you develop in multiple IDE's or other programs that connect to AVD you should try closing them too.