I am trying to create a ColdFusion CFX using java. I am starting very simple to make sure everything works, but so far nothing has.
This is my java class (employee.java)
public class employee implements CustomTag
{
public void processRequest( Request request, Response response )
throws Exception
{
String strName = request.getAttribute( "NAME" ) ;
response.write( "Hello, " + strName ) ;
}
}
I am trying to compile it with the following command:
C:\Progra~1\Java\jdk-14.0.1\bin\javac -classpath C:\ColdFusion2018\cfusion\wwwroot\WEB-INF\lib\cfx.jar employee.java
But when I do, I get the following errors:
employee.java:2: error: cannot find symbol
public class employee implements CustomTag
^
symbol: class CustomTag
employee.java:4: error: cannot find symbol
public void processRequest( Request request, Response response )
^
symbol: class Request
location: class employee
employee.java:4: error: cannot find symbol
public void processRequest( Request request, Response response )
^
symbol: class Response
location: class employee
3 errors
I tried moving the cfx.jar file into the same directory as my java class but this had no effect.
What am I doing wrong ?
Related
I'm facing an issue when executing a simple program in Javalite where I'm testing an API GET call.
The method fetches the URL and reads the response code. But JavaLite is throwing as exception:
org.javalite.http.HttpException: Failed URL: "https://google.in"
Could someone help me understanding this issue?
My code is:
package com.java.lite;
import org.javalite.http.Get;
import org.javalite.http.Http;
import org.testng.annotations.Test;
public class GetCallTest {
#Test
public void getCall() throws Exception {
System.out.println(ConfigPropertyFile.getPropertyValues()); //This line is executed
Get get = Http.get(ConfigPropertyFile.getPropertyValues()); //URL being call from another class where I defined a static method.
System.out.println("Response code" + get.responseCode());
System.out.println("Response message = `enter code here`" + get.responseMessage());
}
}
The URL you are trying returns a redirect to https://www.google.co.in/
Please try:
System.out.println(Http.get("https://www.google.co.in/").text());
and you will get a text of the Google home page.
I am developing a module in prestashop 1.6, i extend AdminController class, every thing is nice.but when i want to display the form that permit to add new instance an error message is displayed :
Fatal error: Undefined class constant 'self::TYPE_STRING' in C:\xampp\htdocs\prestashop\classes\controller\AdminController.php on line 1418
self::TYPE_STRING is a constant from ObjectModel, not AdminController.
I don't know why you'd want use it inside AdminController, but if really need to, change it to : ObjectModel::TYPE_STRING.
Keyword self referes to the current class you're in (in this it is AdminController)
With PHP you can create the missing constant with code like this:
class Test {
private const TYPE_STRING = 'string value';
public function getString() {
return self::TYPE_STRING;
}
}
I have the following Problem.
I tried to create a web service a standard cmis Webservice Interface on IBM, Domino with wsdl2java (with cxf). After creating all java classes I tried to get answers from the webservice with the eclipse Java Client. It works find. After this test I import the generated java classes into a Domino Database.
Now I have the problem to run the webservice, because the following error message:
class org.oasis_open.docs.ns.cmis.messaging._200908.GetTypeDefinition
do not have a property of the name {URL..}repositoryId
In the JAVA Class the following code:
public class GetTypeDefinition {
#XmlElement(required = true)
protected String repositoryId;
#XmlElement(required = true)
protected String typeId;
#XmlElementRef(name = "extension", namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", type = JAXBElement.class)
protected JAXBElement<CmisExtensionType> extension;
The Domino JAVA Env. does not understand the Tag #XmlElement(required = true) without the name, namespace and the type definition.
If I add in the same line the following code:
#XmlElement(required = true, name = "repositoryId", namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", type = String.class)
protected String repositoryId;
it works (error then in the next line:
GetTypeDefinition do not have a property of the name {URL}typeId
Now the question is: why? Can I generate the java classes with an other tool (not with cxf wsdl2java) or do I need other parameters to get the complete code?
In the generated JAVA Classes are round about 170 lines with the problematic code.
Have somebody an Idea to solve the problem on the Domino Server (x64 9.0)?
I am using javax.ws.rs.Path class in my REST class to configure path. It is behaving strange ... My configuration is something like this... This is not actual files, but I have shown a replication to make you understand my configurations.
Class1
#Path("/v2")
public class BoxResource {
#POST
#Path("/ie/box")
public Response createbox(...) {
...
}
}
Class2
#Path("/v2/ie")
public class BagResource {
#POST
#Path("/bag")
public Response createbag(...) {
...
}
}
When I make a HTTP request like /v2/ie/box, it throws the Server configuration error. But if I change my Class2 like below , it works fine.
#Path("/v2/ie/bag")
public class BagResource {
#POST
public Response createbag(...) {
}
}
Why is it like .. Does configuration of #path at class level and method level differs?
A request to /v2/ie/box is mapped to Class2 because is has
#Path("/v2/ie")
as a class annotation.
The longest Path wins in this case. Class1 is never looked at since it has the shorter class annotation #Path("/v2").
Since Class2 has no method that maps to the remaining /box, you will get a 404 Not Found.
Recommendation
Use #Path annotations only on the methods: #Path("/v2/ie/bag") and #Path("/v2/ie/box") OR
use one resource class with a class annotation of #Path("/v2/ie") and method annotations of #Path("/bag") and #Path("/box").
Edit
See also section "3.7 Matching Requests to Resource Methods" of the JAX-RS 2.0 spec.
I've generated testsuits via "cake bake testsuit" and used localhost/test.php for my app.
So, the is an error when I tried to run one of test (else tests are valid):
Fatal error: Class 'ErrorHandler' not found in Z:\home\prodvigator\www\cake\libs\object.php on line 201
This models and controllers are generated by scaffold and I don't think that an error is in this sources.
Using:
CakePHP 1.3
The latest SimpleTest
In my case, deleting all the files in the folder /app/tmp/cache/persistent solved the problem.
try checking the generated tests for an error that gets written at the top of the file.
sometimes i've been known to find something like this in both model and controller tests.
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /projectname/cake/console/templates/default/classes/test.ctp on line 22
In my case, the error was:
Fatal error: Uncaught Error: Class 'ErrorHandler' not found in C:\[path]\core\cake\libs\object.php on line 211
( ! ) Error: Class 'ErrorHandler' not found in C:\[path]\core\cake\libs\object.php on line 211
The error was happening to me when trying to visit http://localhost/user_accounts/index
I already had the view created at app\views\user_accounts\index.ctp with the following content:
<div>
Text from div
</div>
I had created the corresponding controller as well at app\controllers\user_accounts_controller.php:
<?php
class UserAccountsController extends AppController {
public function index() {
// Render the view in /views/user_accounts/index.ctp
$this->render();
}
}
?>
Since I was not associating a model to this controller, I was missing this: var $uses = array();. It would have saved me time if the error had been more explicit, something such as "You do not have a model associated to this controller".
The fix was:
<?php
class UserAccountsController extends AppController {
// Use this controller without a need for a corresponding Model file.
var $uses = array();
public function index() {
// Render the view in /views/user_accounts/index.ctp
$this->render();
}
}
?>